Implement function-sections for Haskell code, #8405
authorSimon Brenner <olsner@gmail.com>
Thu, 12 Nov 2015 10:10:54 +0000 (11:10 +0100)
committerBen Gamari <ben@smart-cactus.org>
Thu, 12 Nov 2015 10:10:54 +0000 (11:10 +0100)
commit4a32bf925b8aba7885d9c745769fe84a10979a53
tree73869f4df99cdb434e7fdd10f67cc9ea96022f4c
parent9bea234dbe3b36957acc42f74f0d54ddc05ad139
Implement function-sections for Haskell code, #8405

This adds a flag -split-sections that does similar things to
-split-objs, but using sections in single object files instead of
relying on the Satanic Splitter and other abominations. This is very
similar to the GCC flags -ffunction-sections and -fdata-sections.

The --gc-sections linker flag, which allows unused sections to actually
be removed, is added to all link commands (if the linker supports it) so
that space savings from having base compiled with sections can be
realized.

Supported both in LLVM and the native code-gen, in theory for all
architectures, but really tested on x86 only.

In the GHC build, a new SplitSections variable enables -split-sections
for relevant parts of the build.

Test Plan: validate with both settings of SplitSections

Reviewers: dterei, Phyx, austin, simonmar, thomie, bgamari

Reviewed By: simonmar, thomie, bgamari

Subscribers: hsyl20, erikd, kgardas, thomie

Differential Revision: https://phabricator.haskell.org/D1242

GHC Trac Issues: #8405
36 files changed:
compiler/cmm/Cmm.hs
compiler/cmm/CmmBuildInfoTables.hs
compiler/cmm/CmmInfo.hs
compiler/cmm/CmmParse.y
compiler/cmm/CmmUtils.hs
compiler/cmm/PprCmmDecl.hs
compiler/codeGen/StgCmm.hs
compiler/codeGen/StgCmmUtils.hs
compiler/ghc.mk
compiler/llvmGen/LlvmCodeGen/Base.hs
compiler/llvmGen/LlvmCodeGen/CodeGen.hs
compiler/llvmGen/LlvmCodeGen/Data.hs
compiler/llvmGen/LlvmCodeGen/Ppr.hs
compiler/main/DriverPipeline.hs
compiler/main/DynFlags.hs
compiler/main/HscMain.hs
compiler/main/SysTools.hs
compiler/nativeGen/AsmCodeGen.hs
compiler/nativeGen/Dwarf.hs
compiler/nativeGen/Dwarf/Types.hs
compiler/nativeGen/PPC/CodeGen.hs
compiler/nativeGen/PPC/Ppr.hs
compiler/nativeGen/PprBase.hs
compiler/nativeGen/SPARC/CodeGen.hs
compiler/nativeGen/SPARC/CodeGen/Gen32.hs
compiler/nativeGen/SPARC/Ppr.hs
compiler/nativeGen/X86/CodeGen.hs
compiler/nativeGen/X86/Ppr.hs
docs/users_guide/phases.rst
driver/utils/merge_sections.ld [new file with mode: 0644]
mk/config.mk.in
rts/ghc.mk
rules/build-package-way.mk
rules/build-package.mk
rules/distdir-way-opts.mk
utils/mkUserGuidePart/Options/Linking.hs