Pass "--hash-size=31 --reduce-memory-overhead" to ld; fixes trac #5240
authorIan Lynagh <igloo@earth.li>
Sun, 27 Nov 2011 00:20:59 +0000 (00:20 +0000)
committerIan Lynagh <igloo@earth.li>
Sun, 27 Nov 2011 00:20:59 +0000 (00:20 +0000)
These reduce the amount of memory that ld takes when linking.

aclocal.m4
rules/build-package-way.mk

index 2bba7b7..f6f1f2b 100644 (file)
@@ -354,14 +354,14 @@ AC_DEFUN([FP_SETTINGS],
     if test "$windows" = YES
     then
         SettingsCCompilerCommand='$topdir/../mingw/bin/gcc.exe'
-        SettingsCCompilerFlags=''
+        SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2 $CONF_GCC_LINKER_OPTS_STAGE2"
         SettingsPerlCommand='$topdir/../perl/perl.exe'
         SettingsDllWrapCommand='$topdir/../mingw/bin/dllwrap.exe'
         SettingsWindresCommand='$topdir/../mingw/bin/windres.exe'
         SettingsTouchCommand='$topdir/touchy.exe'
     else
         SettingsCCompilerCommand="$WhatGccIsCalled"
-        SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
+        SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2 $CONF_GCC_LINKER_OPTS_STAGE2"
         SettingsPerlCommand="$PerlCmd"
         SettingsDllWrapCommand="/bin/false"
         SettingsWindresCommand="/bin/false"
@@ -424,6 +424,11 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
     then
         $2="$$2 -fno-stack-protector"
     fi
+
+    # Reduce memory usage when linking. See trac #5240.
+    $3="$$3 -Wl,--hash-size=31 -Wl,--reduce-memory-overheads"
+    $4="$$4     --hash-size=31     --reduce-memory-overheads"
+
     rm -f conftest.c conftest.o
     AC_MSG_RESULT([done])
 ])
index 00ce065..de1b713 100644 (file)
@@ -114,7 +114,7 @@ BINDIST_LIBS += $$($1_$2_GHCI_LIB)
 endif
 endif
 $$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
-       "$$(LD)" -r -o $$@ $$(EXTRA_LD_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
+       "$$(LD)" $$(CONF_LD_LINKER_OPTS_STAGE$4) -r -o $$@ $$(EXTRA_LD_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
 
 ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES"
 # Don't bother making ghci libs for bootstrapping packages