summaryrefslogtreecommitdiff
path: root/hadrian/src/Settings/Builders/SplitSections.hs
diff options
context:
space:
mode:
Diffstat (limited to 'hadrian/src/Settings/Builders/SplitSections.hs')
-rw-r--r--hadrian/src/Settings/Builders/SplitSections.hs36
1 files changed, 36 insertions, 0 deletions
diff --git a/hadrian/src/Settings/Builders/SplitSections.hs b/hadrian/src/Settings/Builders/SplitSections.hs
new file mode 100644
index 0000000000..215d164b55
--- /dev/null
+++ b/hadrian/src/Settings/Builders/SplitSections.hs
@@ -0,0 +1,36 @@
+-- | Settings required when split-sections is enabled.
+module Settings.Builders.SplitSections where
+
+import Expression
+import Packages
+import Settings
+import Flavour.Type
+
+import Oracles.Setting
+
+-- | Does it make sense to enable or disable split sections?
+splitSectionsArgs :: Args
+splitSectionsArgs = do
+ pkg <- getPackage
+ osx <- expr isOsxTarget
+ notSt0 <- notStage0
+ flav <- expr flavour
+ if ( ghcSplitSections flav
+ -- Flavour enables split-sections
+ && not osx
+ -- OS X doesn't support split sections
+ && notSt0
+ -- Disable for stage 0 because we aren't going to ship
+ -- the resulting binaries and consequently there is no
+ -- reason to minimize size.
+ && (pkg /= ghc)
+ -- Disable section splitting for the GHC library.
+ -- It takes too long and there is little benefit.
+ ) then
+ ( mconcat
+ [ builder (Ghc CompileHs) ? arg "-fsplit-sections"
+ , builder MergeObjects ? ifM (expr isWinTarget)
+ (pure ["-t", "driver/utils/merge_sections_pe.ld"])
+ (pure ["-t", "driver/utils/merge_sections.ld"])
+ ]
+ ) else mempty