[Git][ghc/ghc][wip/angerman/fix-hadrian-cross-macos] No Undefined Oriented Programming

Moritz Angermann gitlab at gitlab.haskell.org
Fri Jun 19 13:43:12 UTC 2020



Moritz Angermann pushed to branch wip/angerman/fix-hadrian-cross-macos at Glasgow Haskell Compiler / GHC


Commits:
fa0cc8d3 by Moritz Angermann at 2020-06-19T21:15:46+08:00
No Undefined Oriented Programming

- - - - -


18 changed files:

- hadrian/src/Builder.hs
- hadrian/src/Expression.hs
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Packages.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Gmp.hs
- hadrian/src/Rules/Program.hs
- hadrian/src/Rules/Rts.hs
- hadrian/src/Settings/Builders/Cabal.hs
- hadrian/src/Settings/Builders/Common.hs
- hadrian/src/Settings/Builders/DeriveConstants.hs
- hadrian/src/Settings/Builders/Ghc.hs
- hadrian/src/Settings/Builders/Hsc2Hs.hs
- hadrian/src/Settings/Builders/RunTest.hs
- hadrian/src/Settings/Default.hs
- hadrian/src/Settings/Packages.hs
- hadrian/src/Settings/Warnings.hs


Changes:

=====================================
hadrian/src/Builder.hs
=====================================
@@ -237,7 +237,7 @@ instance H.Builder Builder where
                     writeFileChanged output stdout
             case builder of
                 Ar Pack stage -> do
-                    useTempFile <- flag stage ArSupportsAtFile
+                    useTempFile <- flag (Staged stage ArSupportsAtFile)
                     if useTempFile then runAr                path buildArgs
                                    else runArWithoutTempFile path buildArgs
 


=====================================
hadrian/src/Expression.hs
=====================================
@@ -122,7 +122,7 @@ notStage0 = notM stage0
 --   compiler's RTS ways. See Note [Linking ghc-bin against threaded stage0 RTS]
 --   in Settings.Packages for details.
 threadedBootstrapper :: Predicate
-threadedBootstrapper = expr (flag undefined BootstrapThreadedRts)
+threadedBootstrapper = expr (flag (Global BootstrapThreadedRts))
 
 -- | Is a certain package /not/ built right now?
 notPackage :: Package -> Predicate


=====================================
hadrian/src/Oracles/Flag.hs
=====================================
@@ -1,7 +1,7 @@
 {-# LANGUAGE MultiWayIf #-}
 
 module Oracles.Flag (
-    Flag (..), flag, getFlag, platformSupportsSharedLibs,
+    Flag (..), FlagName (..), flag, getFlag, platformSupportsSharedLibs,
     ghcWithNativeCodeGen, targetSupportsSMP
     ) where
 
@@ -12,27 +12,30 @@ import Base
 import Context
 import Oracles.Setting
 
-data Flag = ArSupportsAtFile
-          | CrossCompiling
-          | CcLlvmBackend
-          | GhcUnregisterised
-          | TablesNextToCode
-          | GmpInTree
-          | GmpFrameworkPref
-          | LeadingUnderscore
-          | SolarisBrokenShld
-          | WithLibdw
-          | WithLibnuma
-          | HaveLibMingwEx
-          | UseSystemFfi
-          | BootstrapThreadedRts
+data FlagName = ArSupportsAtFile
+              | CrossCompiling
+              | CcLlvmBackend
+              | GhcUnregisterised
+              | TablesNextToCode
+              | GmpInTree
+              | GmpFrameworkPref
+              | LeadingUnderscore
+              | SolarisBrokenShld
+              | WithLibdw
+              | WithLibnuma
+              | HaveLibMingwEx
+              | UseSystemFfi
+              | BootstrapThreadedRts
+
+data Flag = Global FlagName
+          | Staged Stage FlagName
 
 -- Note, if a flag is set to empty string we treat it as set to NO. This seems
 -- fragile, but some flags do behave like this.
-flag :: Stage -> Flag -> Action Bool
-flag s f = do
-    let key = case f of
-            ArSupportsAtFile     -> "ar-supports-at-file-" ++ stageString s
+flag :: Flag -> Action Bool
+flag f = do
+    let configName flagName = case flagName of
+            ArSupportsAtFile     -> "ar-supports-at-file"
             CrossCompiling       -> "cross-compiling"
             CcLlvmBackend        -> "cc-llvm-backend"
             GhcUnregisterised    -> "ghc-unregisterised"
@@ -46,6 +49,11 @@ flag s f = do
             HaveLibMingwEx       -> "have-lib-mingw-ex"
             UseSystemFfi         -> "use-system-ffi"
             BootstrapThreadedRts -> "bootstrap-threaded-rts"
+
+    let key = case f of
+            Global fn   -> configName fn
+            Staged s fn -> configName fn ++ "-" ++ stageString s
+
     value <- lookupValueOrError configFile key
     when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag "
         ++ quote (key ++ " = " ++ value) ++ " cannot be parsed."
@@ -53,9 +61,7 @@ flag s f = do
 
 -- | Get a configuration setting.
 getFlag :: Flag -> Expr Context b Bool
-getFlag f = do
-    stage <- getStage
-    expr $ flag stage f
+getFlag = expr . flag
 
 platformSupportsSharedLibs :: Action Bool
 platformSupportsSharedLibs = do
@@ -63,13 +69,13 @@ platformSupportsSharedLibs = do
                                        , "x86_64-unknown-mingw32"
                                        , "i386-unknown-mingw32" ]
     solaris       <- anyTargetPlatform [ "i386-unknown-solaris2" ]
-    solarisBroken <- flag undefined SolarisBrokenShld
+    solarisBroken <- flag (Global SolarisBrokenShld)
     return $ not (badPlatform || solaris && solarisBroken)
 
 -- | Does the target support the threaded runtime system?
 targetSupportsSMP :: Action Bool
 targetSupportsSMP = do
-  unreg <- flag undefined GhcUnregisterised
+  unreg <- flag (Global GhcUnregisterised)
   armVer <- targetArmVersion
   goodArch <- anyTargetArch ["i386", "x86_64", "sparc", "powerpc", "arm", "aarch64", "s390x"]
   if   -- The THREADED_RTS requires `BaseReg` to be in a register and the
@@ -85,5 +91,5 @@ ghcWithNativeCodeGen :: Action Bool
 ghcWithNativeCodeGen = do
     goodArch <- anyTargetArch ["i386", "x86_64", "sparc", "powerpc"]
     badOs    <- anyTargetOs ["ios", "aix"]
-    ghcUnreg <- flag undefined GhcUnregisterised
+    ghcUnreg <- flag (Global GhcUnregisterised)
     return $ goodArch && not badOs && not ghcUnreg


=====================================
hadrian/src/Packages.hs
=====================================
@@ -129,7 +129,7 @@ setPath pkg path = pkg { pkgPath = path }
 -- 'Library', the function simply returns its name.
 programName :: Context -> Action String
 programName Context {..} = do
-    cross <- flag stage CrossCompiling
+    cross <- flag (Staged stage CrossCompiling)
     targetPlatform <- setting TargetPlatformFull
     let prefix = if cross then targetPlatform ++ "-" else ""
     -- TODO: Can we extract this information from Cabal files?
@@ -212,7 +212,7 @@ libffiBuildPath stage = buildPath $ Context
 -- | Name of the 'libffi' library.
 libffiLibraryName :: Action FilePath
 libffiLibraryName = do
-    useSystemFfi <- flag undefined UseSystemFfi
+    useSystemFfi <- flag (Global UseSystemFfi)
     return $ case (useSystemFfi, windowsHost) of
         (True , False) -> "ffi"
         (False, False) -> "Cffi"


=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -115,7 +115,7 @@ bindistRules = do
     phony "binary-dist-dir" $ do
         -- We 'need' all binaries and libraries
         targets <- mapM pkgTarget =<< stagePackages Stage1
-        cross <- flag undefined CrossCompiling
+        cross <- flag (Global CrossCompiling)
         need targets
         unless cross $ needIservBins
 


=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -234,7 +234,7 @@ generateGhcPlatformH = do
     hostArch       <- chooseSetting HostArch      TargetArch
     hostOs         <- chooseSetting HostOs        TargetOs
     hostVendor     <- chooseSetting HostVendor    TargetVendor
-    ghcUnreg       <- getFlag    GhcUnregisterised
+    ghcUnreg       <- getFlag (Global GhcUnregisterised)
     return . unlines $
         [ "#if !defined(__GHCPLATFORM_H__)"
         , "#define __GHCPLATFORM_H__"
@@ -290,14 +290,14 @@ generateSettings = do
         , ("ld is GNU ld", expr $ lookupValueOrError configFile "ld-is-gnu-ld")
         , ("ar command", expr $ settingsFileSetting SettingsFileSetting_ArCommand)
         , ("ar flags", expr $ lookupValueOrError configFile "ar-args")
-        , ("ar supports at file", yesNo <$> getFlag ArSupportsAtFile)
+        , ("ar supports at file", yesNo <$> getFlag (Global ArSupportsAtFile))
         , ("ranlib command", expr $ settingsFileSetting SettingsFileSetting_RanlibCommand)
         , ("touch command", expr $ settingsFileSetting SettingsFileSetting_TouchCommand)
         , ("dllwrap command", expr $ settingsFileSetting SettingsFileSetting_DllWrapCommand)
         , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand)
         , ("libtool command", expr $ settingsFileSetting SettingsFileSetting_LibtoolCommand)
         , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit })))
-        , ("cross compiling", yesNo <$> getFlag CrossCompiling)
+        , ("cross compiling", yesNo <$> getFlag (Global CrossCompiling))
         , ("target platform string", getSetting TargetPlatform)
         , ("target os", getSetting TargetOsHaskell)
         , ("target arch", getSetting TargetArchHaskell)
@@ -307,7 +307,7 @@ generateSettings = do
         , ("target has .ident directive", expr $ lookupValueOrError configFile "target-has-ident-directive")
         , ("target has subsections via symbols", expr $ lookupValueOrError configFile "target-has-subsections-via-symbols")
         , ("target has RTS linker", expr $ lookupValueOrError configFile "target-has-rts-linker")
-        , ("Unregisterised", yesNo <$> getFlag GhcUnregisterised)
+        , ("Unregisterised", yesNo <$> getFlag (Global GhcUnregisterised))
         , ("LLVM target", getSetting LlvmTarget)
         , ("LLVM llc command", expr $ settingsFileSetting SettingsFileSetting_LlcCommand)
         , ("LLVM opt command", expr $ settingsFileSetting SettingsFileSetting_OptCommand)
@@ -318,12 +318,12 @@ generateSettings = do
         , ("Use native code generator", expr $ yesNo <$> ghcWithNativeCodeGen)
         , ("Support SMP", expr $ yesNo <$> targetSupportsSMP)
         , ("RTS ways", unwords . map show <$> getRtsWays)
-        , ("Tables next to code", yesNo <$> getFlag TablesNextToCode)
-        , ("Leading underscore", yesNo <$> getFlag LeadingUnderscore)
+        , ("Tables next to code", yesNo <$> getFlag (Global TablesNextToCode))
+        , ("Leading underscore", yesNo <$> getFlag (Global LeadingUnderscore))
         , ("Use LibFFI", expr $ yesNo <$> useLibFFIForAdjustors)
         , ("Use Threads", expr $ yesNo . ghcThreaded <$> flavour)
         , ("Use Debugging", expr $ yesNo . ghcDebugged <$> flavour)
-        , ("RTS expects libdw", yesNo <$> getFlag WithLibdw)
+        , ("RTS expects libdw", yesNo <$> getFlag (Global WithLibdw))
         ]
     let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")"
     pure $ case settings of


=====================================
hadrian/src/Rules/Gmp.hs
=====================================
@@ -13,7 +13,7 @@ import Hadrian.BuildPath
 -- their paths.
 gmpObjects :: Stage -> Action [FilePath]
 gmpObjects s = do
-  isInTree <- flag s GmpInTree
+  isInTree <- flag (Staged s GmpInTree)
   if not isInTree
     then return []
     else do
@@ -62,7 +62,7 @@ gmpRules = do
             librariesP = takeDirectory packageP
             stageP     = takeDirectory librariesP
 
-        isInTree <- flag undefined GmpInTree
+        isInTree <- flag (Global GmpInTree)
 
         if isInTree
         then do


=====================================
hadrian/src/Rules/Program.hs
=====================================
@@ -97,7 +97,7 @@ buildProgram bin ctx@(Context{..}) rs = do
   -- so we use pkgRegisteredLibraryFile instead.
   registerPackages =<< contextDependencies ctx
 
-  cross <- flag stage CrossCompiling
+  cross <- flag (Staged stage CrossCompiling)
   -- For cross compiler, copy @stage0/bin/<pgm>@ to @stage1/bin/@.
   case (cross, stage) of
     (True, s) | s > Stage0 -> do


=====================================
hadrian/src/Rules/Rts.hs
=====================================
@@ -46,7 +46,7 @@ withLibffi stage action = needLibffi stage
 copyLibffiHeaders :: Stage -> Action ()
 copyLibffiHeaders stage = do
     rtsPath      <- rtsBuildPath stage
-    useSystemFfi <- flag stage UseSystemFfi
+    useSystemFfi <- flag (Staged stage UseSystemFfi)
     (fromStr, headers) <- if useSystemFfi
         then ("system",) <$> libffiSystemHeaders
         else needLibffi stage
@@ -114,7 +114,7 @@ rtsLibffiLibrary stage way = do
 needRtsLibffiTargets :: Stage -> Action [FilePath]
 needRtsLibffiTargets stage = do
     rtsPath      <- rtsBuildPath stage
-    useSystemFfi <- flag stage UseSystemFfi
+    useSystemFfi <- flag (Staged stage UseSystemFfi)
 
     -- Header files (in the rts build dir).
     let headers = fmap (rtsPath -/-) libffiHeaderFiles


=====================================
hadrian/src/Settings/Builders/Cabal.hs
=====================================
@@ -24,7 +24,7 @@ cabalBuilderArgs = builder (Cabal Setup) ? do
             -- we might have issues with stripping on Windows, as I can't see a
             -- consumer of 'stripCmdPath'.
             -- TODO: See https://github.com/snowleopard/hadrian/issues/549.
-            , flag stage CrossCompiling ? pure [ "--disable-executable-stripping"
+            , flag (Staged stage CrossCompiling) ? pure [ "--disable-executable-stripping"
                                                , "--disable-library-stripping" ]
             -- We don't want to strip the debug RTS
             , S.package rts ? pure [ "--disable-executable-stripping"
@@ -125,7 +125,7 @@ configureArgs = do
         , conf "--with-gmp-includes"      $ arg =<< getSetting GmpIncludeDir
         , conf "--with-gmp-libraries"     $ arg =<< getSetting GmpLibDir
         , conf "--with-curses-libraries"  $ arg =<< getSetting CursesLibDir
-        , flag stage CrossCompiling ? (conf "--host" $ arg =<< getSetting TargetPlatformFull)
+        , flag (Staged stage CrossCompiling) ? (conf "--host" $ arg =<< getSetting TargetPlatformFull)
         , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage
         , notStage0 ? (arg =<< ("--ghc-option=-ghcversion-file=" ++) <$> expr ((-/-) <$> topDirectory <*> ghcVersionH stage))]
 


=====================================
hadrian/src/Settings/Builders/Common.hs
=====================================
@@ -35,8 +35,8 @@ cIncludeArgs = do
             , arg $ "-I" ++ libPath
             , arg $ "-I" ++ path
             , pure . map ("-I"++) . filter (/= "") $ [iconvIncludeDir, gmpIncludeDir]
-            , flag undefined UseSystemFfi ? arg ("-I" ++ ffiIncludeDir)
-            , flag undefined WithLibdw ? if not (null libdwIncludeDir) then arg ("-I" ++ libdwIncludeDir) else mempty
+            , flag (Global UseSystemFfi) ? arg ("-I" ++ ffiIncludeDir)
+            , flag (Global WithLibdw) ? if not (null libdwIncludeDir) then arg ("-I" ++ libdwIncludeDir) else mempty
             -- Add @incDirs@ in the build directory, since some files generated
             -- with @autoconf@ may end up in the build directory.
             , pure [ "-I" ++ path        -/- dir | dir <- incDirs ]
@@ -55,9 +55,9 @@ cArgs = mempty
 cWarnings :: Args
 cWarnings = mconcat
     [ arg "-Wall"
-    , flag undefined CcLlvmBackend ? arg "-Wno-unknown-pragmas"
-    , notM (flag undefined CcLlvmBackend) ? not windowsHost ? arg "-Werror=unused-but-set-variable"
-    , notM (flag undefined CcLlvmBackend) ? arg "-Wno-error=inline" ]
+    , flag (Global CcLlvmBackend) ? arg "-Wno-unknown-pragmas"
+    , notM (flag (Global CcLlvmBackend)) ? not windowsHost ? arg "-Werror=unused-but-set-variable"
+    , notM (flag (Global CcLlvmBackend)) ? arg "-Wno-error=inline" ]
 
 packageDatabaseArgs :: Args
 packageDatabaseArgs = do


=====================================
hadrian/src/Settings/Builders/DeriveConstants.hs
=====================================
@@ -41,7 +41,7 @@ includeCcArgs = do
     mconcat [ cArgs
             , cWarnings
             , getSettingList $ ConfCcArgs Stage1
-            , flag stage GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
+            , flag (Staged stage GhcUnregisterised) ? arg "-DUSE_MINIINTERPRETER"
             , arg "-Irts"
             , arg "-Iincludes"
             , arg $ "-I" ++ libPath


=====================================
hadrian/src/Settings/Builders/Ghc.hs
=====================================
@@ -78,7 +78,7 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
     st <- getStage
     distDir <- expr (Context.distDir st)
 
-    useSystemFfi <- getFlag UseSystemFfi
+    useSystemFfi <- getFlag (Global UseSystemFfi)
     buildPath <- getBuildPath
     libffiName' <- libffiName
     debugged <- ghcDebugged <$> expr flavour


=====================================
hadrian/src/Settings/Builders/Hsc2Hs.hs
=====================================
@@ -22,11 +22,11 @@ hsc2hsBuilderArgs = builder Hsc2Hs ? do
     tmpl <- (top -/-) <$> expr (templateHscPath Stage0)
     mconcat [ arg $ "--cc=" ++ ccPath
             , arg $ "--ld=" ++ ccPath
-            , not windowsHost ? notM (flag stage CrossCompiling) ? arg "--cross-safe"
+            , not windowsHost ? notM (flag (Staged stage CrossCompiling)) ? arg "--cross-safe"
             , pure $ map ("-I" ++) (words gmpDir)
             , map ("--cflag=" ++) <$> getCFlags
             , map ("--lflag=" ++) <$> getLFlags
-            , notStage0 ? flag stage CrossCompiling ? arg "--cross-compile"
+            , notStage0 ? flag (Staged stage CrossCompiling) ? arg "--cross-compile"
             , stage0    ? arg ("--cflag=-D" ++ hArch ++ "_HOST_ARCH=1")
             , stage0    ? arg ("--cflag=-D" ++ hOs   ++ "_HOST_OS=1"  )
             , notStage0 ? arg ("--cflag=-D" ++ tArch ++ "_HOST_ARCH=1")


=====================================
hadrian/src/Settings/Builders/RunTest.hs
=====================================
@@ -20,7 +20,7 @@ getBooleanSetting key = fromMaybe (error msg) <$> parseYesNo <$> getTestSetting
 -- | Extra flags to send to the Haskell compiler to run tests.
 runTestGhcFlags :: Action String
 runTestGhcFlags = do
-    unregisterised <- flag undefined GhcUnregisterised
+    unregisterised <- flag (Global GhcUnregisterised)
 
     let ifMinGhcVer ver opt = do v <- ghcCanonVersion
                                  if ver <= v then pure opt


=====================================
hadrian/src/Settings/Default.hs
=====================================
@@ -53,7 +53,7 @@ defaultPackages Stage3 = return []
 -- | Packages built in 'Stage0' by default. You can change this in "UserSettings".
 stage0Packages :: Action [Package]
 stage0Packages = do
-    cross <- flag undefined CrossCompiling
+    cross <- flag (Global CrossCompiling)
     return $ [ binary
              , cabal
              , compareSizes
@@ -88,7 +88,7 @@ stage1Packages :: Action [Package]
 stage1Packages = do
     intLib     <- integerLibrary =<< flavour
     libraries0 <- filter isLibrary <$> stage0Packages
-    cross      <- flag undefined CrossCompiling
+    cross      <- flag (Global CrossCompiling)
     return $ libraries0 -- Build all Stage0 libraries in Stage1
           ++ [ array
              , base


=====================================
hadrian/src/Settings/Packages.hs
=====================================
@@ -18,7 +18,7 @@ packageArgs = do
     let -- Do not bind the result to a Boolean: this forces the configure rule
         -- immediately and may lead to cyclic dependencies.
         -- See: https://gitlab.haskell.org/ghc/ghc/issues/16809.
-        cross = flag stage CrossCompiling
+        cross = flag (Staged stage CrossCompiling)
 
         -- Check if the bootstrap compiler has the same version as the one we
         -- are building. This is used to build cross-compilers
@@ -61,7 +61,7 @@ packageArgs = do
           , builder (Cabal Setup) ? mconcat
             [ arg "--disable-library-for-ghci"
             , anyTargetOs ["openbsd"] ? arg "--ld-options=-E"
-            , flag stage GhcUnregisterised ? arg "--ghc-option=-DNO_REGS"
+            , flag (Staged stage GhcUnregisterised) ? arg "--ghc-option=-DNO_REGS"
             , notM targetSupportsSMP ? arg "--ghc-option=-DNOSMP"
             , notM targetSupportsSMP ? arg "--ghc-option=-optc-DNOSMP"
             -- When building stage 1 or later, use thread-safe RTS functions if
@@ -125,7 +125,7 @@ packageArgs = do
         , package ghcPrim ? mconcat
           [ builder (Cabal Flags) ? arg "include-ghc-prim"
 
-          , builder (Cc CompileC) ? (not <$> flag stage CcLlvmBackend) ?
+          , builder (Cc CompileC) ? (not <$> flag (Staged stage CcLlvmBackend)) ?
             input "**/cbits/atomic.c"  ? arg "-Wno-sync-nand" ]
 
         --------------------------------- ghci ---------------------------------
@@ -226,13 +226,13 @@ gmpPackageArgs = do
 
         mconcat
           [ builder (Cabal Setup) ? mconcat
-            [ flag undefined GmpInTree ? arg "--configure-option=--with-intree-gmp"
-            , flag undefined GmpFrameworkPref ?
+            [ flag (Global GmpInTree) ? arg "--configure-option=--with-intree-gmp"
+            , flag (Global GmpFrameworkPref) ?
               arg "--configure-option=--with-gmp-framework-preferred"
 
               -- Ensure that the integer-gmp package registration includes
               -- knowledge of the system gmp's library and include directories.
-            , notM (flag undefined GmpInTree) ? mconcat
+            , notM (flag (Global GmpInTree)) ? mconcat
               [ if not (null librariesGmp) then arg ("--extra-lib-dirs=" ++ librariesGmp) else mempty
               , if not (null includesGmp) then arg ("--extra-include-dirs=" ++ includesGmp) else mempty
               ]
@@ -255,8 +255,8 @@ rtsPackageArgs = package rts ? do
     targetArch     <- getSetting TargetArch
     targetOs       <- getSetting TargetOs
     targetVendor   <- getSetting TargetVendor
-    ghcUnreg       <- yesNo <$> getFlag GhcUnregisterised
-    ghcEnableTNC   <- yesNo <$> getFlag TablesNextToCode
+    ghcUnreg       <- yesNo <$> getFlag (Global GhcUnregisterised)
+    ghcEnableTNC   <- yesNo <$> getFlag (Global TablesNextToCode)
     rtsWays        <- getRtsWays
     way            <- getWay
     path           <- getBuildPath
@@ -273,10 +273,10 @@ rtsPackageArgs = package rts ? do
     let ghcArgs = mconcat
           [ arg "-Irts"
           , arg $ "-I" ++ path
-          , flag undefined WithLibdw ? if not (null libdwIncludeDir) then arg ("-I" ++ libdwIncludeDir) else mempty
-          , flag undefined WithLibdw ? if not (null libdwLibraryDir) then arg ("-L" ++ libdwLibraryDir) else mempty
-          , flag undefined WithLibnuma ? if not (null libnumaIncludeDir) then arg ("-I" ++ libnumaIncludeDir) else mempty
-          , flag undefined WithLibnuma ? if not (null libnumaLibraryDir) then arg ("-L" ++ libnumaLibraryDir) else mempty
+          , flag (Global WithLibdw) ? if not (null libdwIncludeDir) then arg ("-I" ++ libdwIncludeDir) else mempty
+          , flag (Global WithLibdw) ? if not (null libdwLibraryDir) then arg ("-L" ++ libdwLibraryDir) else mempty
+          , flag (Global WithLibnuma) ? if not (null libnumaIncludeDir) then arg ("-I" ++ libnumaIncludeDir) else mempty
+          , flag (Global WithLibnuma) ? if not (null libnumaLibraryDir) then arg ("-L" ++ libnumaLibraryDir) else mempty
           , arg $ "-DRtsWay=\"rts_" ++ show way ++ "\""
           -- Set the namespace for the rts fs functions
           , arg $ "-DFS_NAMESPACE=rts"
@@ -291,8 +291,8 @@ rtsPackageArgs = package rts ? do
 
     let cArgs = mconcat
           [ rtsWarnings
-          , flag undefined UseSystemFfi ? arg ("-I" ++ ffiIncludeDir)
-          , flag undefined WithLibdw ? arg ("-I" ++ libdwIncludeDir)
+          , flag (Global UseSystemFfi) ? arg ("-I" ++ ffiIncludeDir)
+          , flag (Global WithLibdw) ? arg ("-I" ++ libdwIncludeDir)
           , arg "-fomit-frame-pointer"
           -- RTS *must* be compiled with optimisations. The INLINE_HEADER macro
           -- requires that functions are inlined to work as expected. Inlining
@@ -365,10 +365,10 @@ rtsPackageArgs = package rts ? do
             -- any warnings in the module. See:
             -- https://gitlab.haskell.org/ghc/ghc/wikis/working-conventions#Warnings
 
-            , (not <$> flag undefined CcLlvmBackend) ?
+            , (not <$> flag (Global CcLlvmBackend)) ?
               inputs ["**/Compact.c"] ? arg "-finline-limit=2500"
 
-            , input "**/RetainerProfile.c" ? flag undefined CcLlvmBackend ?
+            , input "**/RetainerProfile.c" ? flag (Global CcLlvmBackend) ?
               arg "-Wno-incompatible-pointer-types"
             , windowsHost ? arg ("-DWINVER=" ++ windowsVersion)
 
@@ -400,8 +400,8 @@ rtsPackageArgs = package rts ? do
           , "-DFFI_LIB="         ++ show libffiName
           , "-DLIBDW_LIB_DIR="   ++ show libdwLibraryDir ]
 
-        , builder HsCpp ? flag undefined WithLibdw ? arg "-DUSE_LIBDW"
-        , builder HsCpp ? flag undefined HaveLibMingwEx ? arg "-DHAVE_LIBMINGWEX" ]
+        , builder HsCpp ? flag (Global WithLibdw) ? arg "-DUSE_LIBDW"
+        , builder HsCpp ? flag (Global HaveLibMingwEx) ? arg "-DHAVE_LIBMINGWEX" ]
 
 -- Compile various performance-critical pieces *without* -fPIC -dynamic
 -- even when building a shared library.  If we don't do this, then the


=====================================
hadrian/src/Settings/Warnings.hs
=====================================
@@ -11,8 +11,8 @@ import Settings
 defaultGhcWarningsArgs :: Args
 defaultGhcWarningsArgs = mconcat
     [ notStage0 ? arg "-Wnoncanonical-monad-instances"
-    , notM (flag undefined CcLlvmBackend) ? arg "-optc-Wno-error=inline"
-    , flag undefined CcLlvmBackend ? arg "-optc-Wno-unknown-pragmas" ]
+    , notM (flag (Global CcLlvmBackend)) ? arg "-optc-Wno-error=inline"
+    , flag (Global CcLlvmBackend) ? arg "-optc-Wno-unknown-pragmas" ]
 
 -- | Package-specific warnings-related arguments, mostly suppressing various warnings.
 ghcWarningsArgs :: Args



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fa0cc8d3abfd4a817055826c5ca2a4e1a30941bc
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/20200619/ab2941a8/attachment-0001.html>


More information about the ghc-commits mailing list