[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:47:51 UTC 2024



Cheng Shao pushed to branch wip/cbits-split-sections at Glasgow Haskell Compiler / GHC


Commits:
91a1be6e by Cheng Shao at 2024-05-23T17:47:35+00:00
hadrian: build cbits with -ffunction-sections -fdata-sections when split sections is enabled

- - - - -
62e149c1 by Cheng Shao at 2024-05-23T17:47:41+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/d536403af30600a2b7ec615498408ce3fe21f532...62e149c1548e36f66ae35efe4e62f79a29ac7b21

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d536403af30600a2b7ec615498408ce3fe21f532...62e149c1548e36f66ae35efe4e62f79a29ac7b21
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/e857d0e8/attachment-0001.html>


More information about the ghc-commits mailing list