summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/DriverPipeline.hs4
-rw-r--r--compiler/main/DynFlags.hs15
-rw-r--r--compiler/main/HscMain.hs2
-rw-r--r--compiler/main/SysTools.hs1
4 files changed, 20 insertions, 2 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 33770b92f6..a1d36a6b54 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1908,6 +1908,10 @@ linkBinary' staticLink dflags o_files dep_packages = do
then ["-Wl,-read_only_relocs,suppress"]
else [])
+ ++ (if sLdIsGnuLd mySettings
+ then ["-Wl,--gc-sections"]
+ else [])
+
++ o_files
++ lib_path_opts)
++ extra_ld_inputs
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index b8705603c7..39f4a0487f 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -391,6 +391,7 @@ data GeneralFlag
| Opt_EagerBlackHoling
| Opt_NoHsMain
| Opt_SplitObjs
+ | Opt_SplitSections
| Opt_StgStats
| Opt_HideAllPackages
| Opt_PrintBindResult
@@ -1283,7 +1284,10 @@ wayUnsetGeneralFlags _ WayDyn = [-- There's no point splitting objects
-- when we're going to be dynamically
-- linking. Plus it breaks compilation
-- on OSX x86.
- Opt_SplitObjs]
+ Opt_SplitObjs,
+ -- If splitobjs wasn't useful for this,
+ -- assume sections aren't either.
+ Opt_SplitSections]
wayUnsetGeneralFlags _ WayProf = []
wayUnsetGeneralFlags _ WayEventLog = []
@@ -2326,6 +2330,15 @@ dynamic_flags = [
then setGeneralFlag Opt_SplitObjs
else addWarn "ignoring -fsplit-objs"))
+ , defGhcFlag "split-sections"
+ (noArgM (\dflags -> do
+ if platformHasSubsectionsViaSymbols (targetPlatform dflags)
+ then do addErr $
+ "-split-sections is not useful on this platform " ++
+ "since it always uses subsections via symbols."
+ return dflags
+ else return (gopt_set dflags Opt_SplitSections)))
+
-------- ghc -M -----------------------------------------------------
, defGhcFlag "dep-suffix" (hasArg addDepSuffix)
, defGhcFlag "dep-makefile" (hasArg setDepMakefile)
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 53c6f626e5..a6d263781c 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -1434,7 +1434,7 @@ doCodeGen hsc_env this_mod data_tycons
-- we generate one SRT for the whole module.
let
pipeline_stream
- | gopt Opt_SplitObjs dflags
+ | gopt Opt_SplitObjs dflags || gopt Opt_SplitSections dflags
= {-# SCC "cmmPipeline" #-}
let run_pipeline us cmmgroup = do
let (topSRT', us') = initUs us emptySRT
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
index 879b035d03..303e8dee90 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -791,6 +791,7 @@ getLinkerInfo' dflags = do
-- GNU ld specifically needs to use less memory. This especially
-- hurts on small object files. Trac #5240.
-- Set DT_NEEDED for all shared libraries. Trac #10110.
+ -- TODO: Investigate if these help or hurt when using split sections.
return (GnuLD $ map Option ["-Wl,--hash-size=31",
"-Wl,--reduce-memory-overheads",
-- ELF specific flag