summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorSimon Brenner <olsner@gmail.com>2015-11-12 11:10:54 +0100
committerBen Gamari <ben@smart-cactus.org>2015-11-12 11:10:54 +0100
commit4a32bf925b8aba7885d9c745769fe84a10979a53 (patch)
tree73869f4df99cdb434e7fdd10f67cc9ea96022f4c /driver
parent9bea234dbe3b36957acc42f74f0d54ddc05ad139 (diff)
downloadhaskell-4a32bf925b8aba7885d9c745769fe84a10979a53.tar.gz
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
Diffstat (limited to 'driver')
-rw-r--r--driver/utils/merge_sections.ld26
1 files changed, 26 insertions, 0 deletions
diff --git a/driver/utils/merge_sections.ld b/driver/utils/merge_sections.ld
new file mode 100644
index 0000000000..8c82ca09b5
--- /dev/null
+++ b/driver/utils/merge_sections.ld
@@ -0,0 +1,26 @@
+/* Linker script to undo -split-sections and merge all sections together when
+ * linking relocatable object files for GHCi.
+ * ld -r normally retains the individual sections, which is what you would want
+ * if the intention is to eventually link into a binary with --gc-sections, but
+ * it doesn't have a flag for directly doing what we want. */
+SECTIONS
+{
+ .text : {
+ *(.text*)
+ }
+ .rodata.cst16 : {
+ *(.rodata.cst16*)
+ }
+ .rodata : {
+ *(.rodata*)
+ }
+ .data.rel.ro : {
+ *(.data.rel.ro*)
+ }
+ .data : {
+ *(.data*)
+ }
+ .bss : {
+ *(.bss*)
+ }
+}