[Git][ghc/ghc][wip/js-supported-extensions] Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214)

Josh Meredith (@JoshMeredith) gitlab at gitlab.haskell.org
Tue May 23 14:54:52 UTC 2023



Josh Meredith pushed to branch wip/js-supported-extensions at Glasgow Haskell Compiler / GHC


Commits:
bae24c5f by Josh Meredith at 2023-05-23T14:54:33+00:00
Remove JavaScriptFFI from --supported-extensions for non-JS targets (#11214)

- - - - -


3 changed files:

- compiler/GHC/Driver/Session.hs
- testsuite/tests/th/TH_foreignCallingConventions.hs
- testsuite/tests/th/TH_foreignCallingConventions.stderr


Changes:

=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -2520,7 +2520,7 @@ supportedLanguageOverlays :: [String]
 supportedLanguageOverlays = map (flagSpecName . snd) safeHaskellFlagsDeps
 
 supportedExtensions :: ArchOS -> [String]
-supportedExtensions (ArchOS _ os) = concatMap toFlagSpecNamePair xFlags
+supportedExtensions (ArchOS arch os) = concatMap toFlagSpecNamePair xFlags
   where
     toFlagSpecNamePair flg
       -- IMPORTANT! Make sure that `ghc --supported-extensions` omits
@@ -2529,9 +2529,12 @@ supportedExtensions (ArchOS _ os) = concatMap toFlagSpecNamePair xFlags
       -- the rationale
       | isAIX, flagSpecFlag flg == LangExt.TemplateHaskell  = [noName]
       | isAIX, flagSpecFlag flg == LangExt.QuasiQuotes      = [noName]
+      -- "JavaScriptFFI" is only supported on the JavaScript backend
+      | notJS, flagSpecFlag flg == LangExt.JavaScriptFFI    = [noName]
       | otherwise = [name, noName]
       where
         isAIX = os == OSAIX
+        notJS = arch /= ArchJavaScript
         noName = "No" ++ name
         name = flagSpecName flg
 


=====================================
testsuite/tests/th/TH_foreignCallingConventions.hs
=====================================
@@ -1,6 +1,9 @@
 {-# LANGUAGE ForeignFunctionInterface, CApiFFI, GHCForeignImportPrim,
-             QuasiQuotes, TemplateHaskell, JavaScriptFFI, MagicHash,
-             UnliftedFFITypes #-}
+             QuasiQuotes, TemplateHaskell, MagicHash,
+             UnliftedFFITypes, CPP #-}
+#if defined(javascript_HOST_ARCH)
+{-# LANGUAGE JavaScriptFFI #-}
+#endif
 
 module TH_foreignCallingConventions where
 


=====================================
testsuite/tests/th/TH_foreignCallingConventions.stderr
=====================================
@@ -8,7 +8,7 @@ foreign import stdcall safe "bay" bay :: (GHC.Types.Int ->
                                          GHC.Types.IO GHC.Types.Int
 foreign import javascript unsafe "bax" bax :: GHC.Ptr.Ptr GHC.Types.Int ->
                                               GHC.Types.IO GHC.Base.String
-TH_foreignCallingConventions.hs:(13,2)-(24,2): Splicing declarations
+TH_foreignCallingConventions.hs:(16,2)-(27,2): Splicing declarations
     do let fi cconv safety lbl name ty
              = ForeignD (ImportF cconv safety lbl name ty)
        dec1 <- fi CCall Interruptible "&" (mkName "foo") <$> [t| Ptr () |]



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bae24c5f0235482ab50cdad2bbabe6aa94352edf

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bae24c5f0235482ab50cdad2bbabe6aa94352edf
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230523/6133def6/attachment-0001.html>


More information about the ghc-commits mailing list