[Git][ghc/ghc][wip/cbits-split-sections] 2 commits: hadrian: build cbits with -ffunction-sections -fdata-sections when split sections is enabled
Cheng Shao (@TerrorJack)
gitlab at gitlab.haskell.org
Thu May 23 17:49:42 UTC 2024
Cheng Shao pushed to branch wip/cbits-split-sections at Glasgow Haskell Compiler / GHC
Commits:
60a08ced by Cheng Shao at 2024-05-23T17:49:22+00:00
hadrian: build cbits with -ffunction-sections -fdata-sections when split sections is enabled
-------------------------
Metric Decrease:
size_hello_artifact
size_hello_unicode
-------------------------
- - - - -
23031759 by Cheng Shao at 2024-05-23T17:49:34+00:00
driver: build .hc with -ffunction-sections -fdata-sections when split sections is enabled
- - - - -
2 changed files:
- compiler/GHC/Driver/Pipeline/Execute.hs
- hadrian/src/Settings/Builders/SplitSections.hs
Changes:
=====================================
compiler/GHC/Driver/Pipeline/Execute.hs
=====================================
@@ -463,6 +463,13 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do
then [ "-ffloat-store" ]
else []) ++
+ -- if -fsplit-sections is enabled, we should also build .hc
+ -- files with these flags.
+ (if gopt Opt_SplitSections dflags &&
+ platformOS (targetPlatform dflags) /= OSDarwin
+ then ["-ffunction-sections", "-fdata-sections"]
+ else []) ++
+
-- gcc's -fstrict-aliasing allows two accesses to memory
-- to be considered non-aliasing if they have different types.
-- This interacts badly with the C code we generate, which is
=====================================
hadrian/src/Settings/Builders/SplitSections.hs
=====================================
@@ -32,5 +32,12 @@ splitSectionsArgs = do
, builder MergeObjects ? ifM (expr isWinTarget)
(pure ["-T", "driver/utils/merge_sections_pe.ld"])
(pure ["-T", "driver/utils/merge_sections.ld"])
+ , builder (Cc CompileC) ? arg "-ffunction-sections" <> arg "-fdata-sections"
+ , builder (Ghc CompileCWithGhc) ? arg "-optc-ffunction-sections"
+ <> arg
+ "-optc-fdata-sections"
+ , builder (Ghc CompileCppWithGhc) ? arg "-optcxx-ffunction-sections"
+ <> arg
+ "-optcxx-fdata-sections"
]
) else mempty
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62e149c1548e36f66ae35efe4e62f79a29ac7b21...23031759df5b8c13482646f1f9c202a1c77dd7c6
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62e149c1548e36f66ae35efe4e62f79a29ac7b21...23031759df5b8c13482646f1f9c202a1c77dd7c6
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/20240523/e4b39e61/attachment-0001.html>
More information about the ghc-commits
mailing list