diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-11-04 18:18:30 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-05 10:12:16 -0400 |
commit | be3750a5a3cbc59a7b84f1f7603f308aee1cc80b (patch) | |
tree | 0c30a5633f67be2e13123c73e56e777a7077725a | |
parent | 59dfb00584e6d24d82d3f5338c6299bae48e0468 (diff) | |
download | haskell-be3750a5a3cbc59a7b84f1f7603f308aee1cc80b.tar.gz |
Allow CApi FFI calls in GHCi
At some point in the past this started working. I noticed this when
working on multiple home units and couldn't load GHC's dependencies into
the interpreter.
Fixes #7388
-rw-r--r-- | compiler/GHC/StgToByteCode.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T7388.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T7388.script | 2 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T7388.stdout | 1 | ||||
-rwxr-xr-x | testsuite/tests/ghci/scripts/all.T | 1 |
5 files changed, 12 insertions, 1 deletions
diff --git a/compiler/GHC/StgToByteCode.hs b/compiler/GHC/StgToByteCode.hs index e056dadc2b..e7d4df472d 100644 --- a/compiler/GHC/StgToByteCode.hs +++ b/compiler/GHC/StgToByteCode.hs @@ -1393,6 +1393,7 @@ generateCCall d0 s p (CCallSpec target cconv safety) result_ty args_r_to_l conv = case cconv of CCallConv -> FFICCall + CApiConv -> FFICCall StdCallConv -> FFIStdCall _ -> panic "GHC.StgToByteCode: unexpected calling convention" @@ -1935,7 +1936,7 @@ isSupportedCConv (CCallSpec _ cconv _) = case cconv of StdCallConv -> True -- convention to ensure that a warning PrimCallConv -> False -- is triggered when a new one is added JavaScriptCallConv -> False - CApiConv -> False + CApiConv -> True -- See bug #10462 unsupportedCConvException :: a diff --git a/testsuite/tests/ghci/scripts/T7388.hs b/testsuite/tests/ghci/scripts/T7388.hs new file mode 100644 index 0000000000..91ca1c7268 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T7388.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE CApiFFI #-} +module T7388 where + +import Foreign.C + +foreign import capi "stdio.h printf" printfb :: CString -> CInt -> IO () diff --git a/testsuite/tests/ghci/scripts/T7388.script b/testsuite/tests/ghci/scripts/T7388.script new file mode 100644 index 0000000000..7f02d86453 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T7388.script @@ -0,0 +1,2 @@ +:l T7388 +withCString "I am a working CApi FFI call\n" $ \str -> printfb str 0 diff --git a/testsuite/tests/ghci/scripts/T7388.stdout b/testsuite/tests/ghci/scripts/T7388.stdout new file mode 100644 index 0000000000..b9ac187b44 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T7388.stdout @@ -0,0 +1 @@ +I am a working CApi FFI call diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T index 80f3eb8f02..4db3ba2f7b 100755 --- a/testsuite/tests/ghci/scripts/all.T +++ b/testsuite/tests/ghci/scripts/all.T @@ -346,3 +346,4 @@ test('T20019', normal, ghci_script, ['T20019.script']) test('T20101', normal, ghci_script, ['T20101.script']) test('T20206', normal, ghci_script, ['T20206.script']) test('T20217', normal, ghci_script, ['T20217.script']) +test('T7388', normal, ghci_script, ['T7388.script']) |