[Git][ghc/ghc][master] hadrian: Ensure that way-flags are passed to CC
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Wed Aug 2 10:01:23 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00
hadrian: Ensure that way-flags are passed to CC
Previously the way-specific compilation flags (e.g. `-DDEBUG`,
`-DTHREADED_RTS`) would not be passed to the CC invocations. This meant
that C dependency files would not correctly reflect
dependencies predicated on the way, resulting in the rather
painful #23554.
Closes #23554.
- - - - -
3 changed files:
- hadrian/src/Settings/Builders/Common.hs
- hadrian/src/Settings/Builders/Ghc.hs
- hadrian/src/Settings/Packages.hs
Changes:
=====================================
hadrian/src/Settings/Builders/Common.hs
=====================================
@@ -7,7 +7,7 @@ module Settings.Builders.Common (
module UserSettings,
cIncludeArgs, ldArgs, cArgs, cppArgs, cWarnings,
packageDatabaseArgs, bootPackageDatabaseArgs,
- getStagedCCFlags
+ getStagedCCFlags, wayCcArgs
) where
import Hadrian.Haskell.Cabal.Type
@@ -72,3 +72,12 @@ bootPackageDatabaseArgs = do
getStagedCCFlags :: Args
getStagedCCFlags = prgFlags . ccProgram . tgtCCompiler <$> getStagedTarget
+
+wayCcArgs :: Args
+wayCcArgs = do
+ way <- getWay
+ mconcat [ (Threaded `wayUnit` way) ? arg "-DTHREADED_RTS"
+ , (Debug `wayUnit` way) ? arg "-DDEBUG"
+ , (way == debug || way == debugDynamic) ? arg "-DTICKY_TICKY"
+ ]
+
=====================================
hadrian/src/Settings/Builders/Ghc.hs
=====================================
@@ -238,11 +238,14 @@ wayGhcArgs = do
mconcat [ if Dynamic `wayUnit` way
then pure ["-fPIC", "-dynamic"]
else arg "-static"
- , (Threaded `wayUnit` way) ? arg "-optc-DTHREADED_RTS"
- , (Debug `wayUnit` way) ? arg "-optc-DDEBUG"
, (Profiling `wayUnit` way) ? arg "-prof"
- , (way == debug || way == debugDynamic) ?
- pure ["-ticky", "-DTICKY_TICKY"] ]
+ , (way == debug || way == debugDynamic) ? arg "-ticky"
+ , wayCcArgs
+ -- We must pass CPP flags via -optc as well to ensure that they
+ -- are passed to the preprocessor when, e.g., compiling Cmm
+ -- sources.
+ , map ("-optc"++) <$> wayCcArgs
+ ]
-- | Args related to correct handling of packages, such as setting
-- -this-unit-id and passing -package-id for dependencies
=====================================
hadrian/src/Settings/Packages.hs
=====================================
@@ -6,6 +6,7 @@ import Oracles.Setting
import Oracles.Flag
import Packages
import Settings
+import Settings.Builders.Common (wayCcArgs)
import GHC.Toolchain.Target
import GHC.Platform.ArchOS
@@ -315,6 +316,7 @@ rtsPackageArgs = package rts ? do
let cArgs = mconcat
[ rtsWarnings
+ , wayCcArgs
, arg "-fomit-frame-pointer"
-- RTS *must* be compiled with optimisations. The INLINE_HEADER macro
-- requires that functions are inlined to work as expected. Inlining
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cca74dab6809f8cf7ffc2ec9df689e06aa425110
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cca74dab6809f8cf7ffc2ec9df689e06aa425110
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/20230802/59a9c320/attachment-0001.html>
More information about the ghc-commits
mailing list