Skip to content
Snippets Groups Projects
Commit 03da9015 authored by Cheng Shao's avatar Cheng Shao :beach:
Browse files

driver: build C/C++ with -ffunction-sections -fdata-sections when split sections is enabled

When -fsplit-sections is passed to GHC, pass -ffunction-sections
-fdata-sections to gcc/clang when building C/C++. Previously,
-fsplit-sections was only respected by the NCG/LLVM backends, but not
the unregisterised backend; the GHC driver did not pass
-fdata-sections and -ffunction-sections to the C compiler, which
resulted in excessive executable sizes.

Fixes #23381.

-------------------------
Metric Decrease:
    size_hello_artifact
    size_hello_unicode
-------------------------

(cherry picked from commit 02b1f91e)
(cherry picked from commit 74cdf564)
parent 6de1c17d
No related branches found
No related tags found
No related merge requests found
......@@ -513,6 +513,13 @@ runCcPhase cc_phase pipe_env hsc_env location input_fn = do
, not $ target32Bit (targetPlatform dflags)
]
-- if -fsplit-sections is enabled, we should also
-- build with these flags.
++ (if gopt Opt_SplitSections dflags &&
platformOS (targetPlatform dflags) /= OSDarwin
then ["-ffunction-sections", "-fdata-sections"]
else [])
-- Stub files generated for foreign exports references the runIO_closure
-- and runNonIO_closure symbols, which are defined in the base package.
-- These symbols are imported into the stub.c file via RtsAPI.h, and the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment