[commit: ghc] wip/T15548: Introduce `integerLibrary :: DynFlags -> IntegerLibrary` (db82a5d)

git at git.haskell.org git at git.haskell.org
Tue Aug 21 05:39:50 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T15548
Link       : http://ghc.haskell.org/trac/ghc/changeset/db82a5dc9e33d3ed94d1328211b33bad65e19e5e/ghc

>---------------------------------------------------------------

commit db82a5dc9e33d3ed94d1328211b33bad65e19e5e
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Mon Aug 20 14:51:44 2018 -0700

    Introduce `integerLibrary :: DynFlags -> IntegerLibrary`
    
    which is initialized via `cIntegerLibraryType`, but can be overriden by
    an API user.
    
    The only place where this is used is in `CorePrep`, to decide whether to
    use the `S#` constructor.
    
    Also removes the unused `cIntegerLibrary`.


>---------------------------------------------------------------

db82a5dc9e33d3ed94d1328211b33bad65e19e5e
 compiler/coreSyn/CorePrep.hs | 4 ++--
 compiler/ghc.mk              | 2 --
 compiler/main/DynFlags.hs    | 4 ++++
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/coreSyn/CorePrep.hs
index 9c2954d..0349c8c 100644
--- a/compiler/coreSyn/CorePrep.hs
+++ b/compiler/coreSyn/CorePrep.hs
@@ -1538,13 +1538,13 @@ lookupMkNaturalName dflags hsc_env
       lookupGlobal hsc_env mkNaturalName
 
 lookupIntegerSDataConName :: DynFlags -> HscEnv -> IO (Maybe DataCon)
-lookupIntegerSDataConName dflags hsc_env = case cIntegerLibraryType of
+lookupIntegerSDataConName dflags hsc_env = case integerLibrary dflags of
     IntegerGMP -> guardIntegerUse dflags $ liftM (Just . tyThingDataCon) $
                   lookupGlobal hsc_env integerSDataConName
     IntegerSimple -> return Nothing
 
 lookupNaturalSDataConName :: DynFlags -> HscEnv -> IO (Maybe DataCon)
-lookupNaturalSDataConName dflags hsc_env = case cIntegerLibraryType of
+lookupNaturalSDataConName dflags hsc_env = case integerLibrary dflags of
     IntegerGMP -> guardNaturalUse dflags $ liftM (Just . tyThingDataCon) $
                   lookupGlobal hsc_env naturalSDataConName
     IntegerSimple -> return Nothing
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 9bc6b3f..8a4cc43 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -84,8 +84,6 @@ compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
 	@echo 'cBooterVersion        = "$(GhcVersion)"'                     >> $@
 	@echo 'cStage                :: String'                             >> $@
 	@echo 'cStage                = show (STAGE :: Int)'                 >> $@
-	@echo 'cIntegerLibrary       :: String'                             >> $@
-	@echo 'cIntegerLibrary       = "$(INTEGER_LIBRARY)"'                >> $@
 	@echo 'cIntegerLibraryType   :: IntegerLibrary'                     >> $@
 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
 	@echo 'cIntegerLibraryType   = IntegerGMP'                          >> $@
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 66c67c3..61838a0 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -848,6 +848,9 @@ data DynFlags = DynFlags {
   ghcLink               :: GhcLink,
   hscTarget             :: HscTarget,
   settings              :: Settings,
+  integerLibrary        :: IntegerLibrary,
+    -- ^ IntegerGMP or IntegerSimple. Set at configure time, but may be overriden
+    --   by GHC-API users
   llvmTargets           :: LlvmTargets,
   llvmPasses            :: LlvmPasses,
   verbosity             :: Int,         -- ^ Verbosity level: see Note [Verbosity levels]
@@ -1753,6 +1756,7 @@ defaultDynFlags mySettings (myLlvmTargets, myLlvmPasses) =
         ghcMode                 = CompManager,
         ghcLink                 = LinkBinary,
         hscTarget               = defaultHscTarget (sTargetPlatform mySettings),
+        integerLibrary          = cIntegerLibraryType,
         verbosity               = 0,
         optLevel                = 0,
         debugLevel              = 0,



More information about the ghc-commits mailing list