summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-12-07 10:33:11 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2023-01-04 11:58:42 +0000
commit32255d055b768d51deb9d1f49681164cf7492011 (patch)
treefb9b6ab9c77366b59b19f1f07ac275300d21e348
parent21bedd84f2cde6aa17d09c610a2a309f3e2a7f10 (diff)
downloadhaskell-32255d055b768d51deb9d1f49681164cf7492011.tar.gz
compiler: Add -f[no-]split-sections flags
Here we add a `-fsplit-sections` flag which may some day replace `-split-sections`. This has the advantage of automatically providing a `-fno-split-sections` flag, which is useful for our packaging because we enable `-split-sections` by default but want to disable it in certain configurations.
-rw-r--r--compiler/GHC/Driver/Session.hs20
-rw-r--r--docs/users_guide/phases.rst4
2 files changed, 15 insertions, 9 deletions
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index 831267e2bf..07106c7c8c 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -2192,14 +2192,10 @@ dynamic_flags_deps = [
, make_ord_flag defGhcFlag "split-objs"
(NoArg $ addWarn "ignoring -split-objs")
+ -- N.B. We may someday deprecate this in favor of -fsplit-sections,
+ -- which has the benefit of also having a negating -fno-split-sections.
, make_ord_flag defGhcFlag "split-sections"
- (noArgM (\dflags -> do
- if platformHasSubsectionsViaSymbols (targetPlatform dflags)
- then do addWarn $
- "-split-sections is not useful on this platform " ++
- "since it always uses subsections via symbols. Ignoring."
- return dflags
- else return (gopt_set dflags Opt_SplitSections)))
+ (NoArg $ setGeneralFlag Opt_SplitSections)
-------- ghc -M -----------------------------------------------------
, make_ord_flag defGhcFlag "dep-suffix" (hasArg addDepSuffix)
@@ -3514,7 +3510,8 @@ fFlagsDeps = [
(addWarn "-compact-unwind is only implemented by the darwin platform. Ignoring.")
return dflags)),
flagSpec "show-error-context" Opt_ShowErrorContext,
- flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer
+ flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer,
+ flagSpec "split-sections" Opt_SplitSections
]
++ fHoleFlags
@@ -4800,6 +4797,13 @@ makeDynFlagsConsistent dflags
warn = "-dynamic-too is ignored when using -dynamic"
in loop dflags' warn
+ | gopt Opt_SplitSections dflags
+ , platformHasSubsectionsViaSymbols (targetPlatform dflags)
+ = let dflags' = gopt_unuset dflags Opt_SplitSections
+ warn = "-fsplit-sections is not useful on this platform " ++
+ "since it uses subsections-via-symbols. Ignoring."
+ in loop dflags' warn
+
-- Via-C backend only supports unregisterised ABI. Switch to a backend
-- supporting it if possible.
| backendUnregisterisedAbiOnly (backend dflags) &&
diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst
index aa171c2055..8d0c32f5c1 100644
--- a/docs/users_guide/phases.rst
+++ b/docs/users_guide/phases.rst
@@ -909,10 +909,12 @@ for example).
option for Apple's Linker (``-F`` already means something else for
GHC).
-.. ghc-flag:: -split-sections
+.. ghc-flag:: -fsplit-sections
+ -split-sections
:shortdesc: Split sections for link-time dead-code stripping
:type: dynamic
:category: linking
+ :reverse: -fno-split-sections
Place each generated function or data item into its own section in the
output file if the target supports arbitrary sections. The name of the