Ticket #5240: 0001-Rework-fix-for-5240-to-avoid-spamming-the-output-wit.patch

File 0001-Rework-fix-for-5240-to-avoid-spamming-the-output-wit.patch, 6.6 KB (added by pgj, 2 years ago)
  • aclocal.m4

    From c30f06c6f9b4580b22ca150873469d52a7c1d1cc Mon Sep 17 00:00:00 2001
    From: Gabor Pali <pali.gabor@gmail.com>
    Date: Sun, 20 May 2012 07:36:47 +0000
    Subject: [PATCH] Rework fix for #5240 to avoid spamming the output with
     linker warnings.
    
    ---
     aclocal.m4                      |   71 ++++++++++++++++++++++++++------------
     compiler/ghc.mk                 |    4 ++
     compiler/main/DriverPipeline.hs |   11 ++++++
     configure.ac                    |    4 +-
     mk/config.mk.in                 |    6 +++
     5 files changed, 71 insertions(+), 25 deletions(-)
    
    diff --git a/aclocal.m4 b/aclocal.m4
    index f05dfe9..1513c4c 100644
    a b AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS], 
    459459    fi 
    460460 
    461461    # Reduce memory usage when linking. See trac #5240. 
    462     if test -n "$LdHashSize31" 
    463     then 
    464         $3="$$3 -Wl,$LdHashSize31" 
    465         $4="$$4     $LdHashSize31" 
     462    if test "$LdHashSize31" = "YES"; then 
     463        $4="$$4     --hash-size=31" 
    466464    fi 
    467     if test -n "$LdReduceMemoryOverheads" 
    468     then 
    469         $3="$$3 -Wl,$LdReduceMemoryOverheads" 
    470         $4="$$4     $LdReduceMemoryOverheads" 
     465    if test "$LdReduceMemoryOverheads" = "YES"; then 
     466        $4="$$4     --reduce-memory-overheads" 
    471467    fi 
    472468 
    473469    rm -f conftest.c conftest.o 
    AC_SUBST([LdXFlag]) 
    880876])# FP_PROG_LD_X 
    881877 
    882878 
    883 # FP_PROG_LD_HashSize31 
    884 # ------------ 
    885 # Sets the output variable LdHashSize31 to --hash-size=31 if ld supports 
    886 # this flag. Otherwise the variable's value is empty. 
    887 AC_DEFUN([FP_PROG_LD_HashSize31], 
     879# FP_PROG_LD_HASHSIZE31 
     880# --------------------- 
     881 
     882# Sets the output variable LdHashSize31 to YES if ld supports 
     883# this flag. Otherwise the variable's value is NO. 
     884AC_DEFUN([FP_PROG_LD_HASHSIZE31], 
    888885[ 
    889 FP_PROG_LD_FLAG([--hash-size=31],[LdHashSize31]) 
    890 ])# FP_PROG_LD_HashSize31 
     886AC_CACHE_CHECK([whether ld understands --hash-size=31], [fp_cv_ld_hashsize31], 
     887[echo 'foo() {}' > conftest.c 
     888${CC-cc} -c conftest.c 
     889if ${LdCmd} --hash-size=31 -o conftest2.o conftest.o > /dev/null 2>&1; then 
     890   fp_cv_ld_hashsize31=yes 
     891else 
     892   fp_cv_ld_hashsize31=no 
     893fi 
     894rm -rf conftest*]) 
     895if test "$fp_cv_ld_hashsize31" = "yes"; then 
     896  LdHashSize31=YES 
     897else 
     898  LdHashSize31=NO 
     899fi 
     900AC_SUBST([LdHashSize31]) 
     901])# FP_PROG_LD_HASHSIZE31 
    891902 
    892903 
    893 # FP_PROG_LD_ReduceMemoryOverheads 
    894 # ------------ 
    895 # Sets the output variable LdReduceMemoryOverheads to 
    896 # --reduce-memory-overheads if ld supports this flag. 
    897 # Otherwise the variable's value is empty. 
    898 AC_DEFUN([FP_PROG_LD_ReduceMemoryOverheads], 
     904# FP_PROG_LD_REDUCEMEMORYOVERHEADS 
     905# -------------------------------- 
     906 
     907# Sets the output variable LdReduceMemoryOverheads to YES if ld supports 
     908# this flag. Otherwise the variable's value is NO. 
     909AC_DEFUN([FP_PROG_LD_REDUCEMEMORYOVERHEADS], 
    899910[ 
    900 FP_PROG_LD_FLAG([--reduce-memory-overheads],[LdReduceMemoryOverheads]) 
    901 ])# FP_PROG_LD_ReduceMemoryOverheads 
     911AC_CACHE_CHECK([whether ld understands --reduce-memory-overheads], [fp_cv_ld_reduce_memory_overheads], 
     912[echo 'foo() {}' > conftest.c 
     913${CC-cc} -c conftest.c 
     914if ${LdCmd} --reduce-memory-overheads -o conftest2.o conftest.o > /dev/null 2>&1; then 
     915   fp_cv_ld_reduce_memory_overheads=yes 
     916else 
     917   fp_cv_ld_reduce_memory_overheads=no 
     918fi 
     919rm -rf conftest*]) 
     920if test "$fp_cv_ld_reduce_memory_overheads" = "yes"; then 
     921  LdReduceMemoryOverheads=YES 
     922else 
     923  LdReduceMemoryOverheads=NO 
     924fi 
     925AC_SUBST([LdReduceMemoryOverheads]) 
     926])# FP_PROG_LD_REDUCEMEMORYOVERHEADS 
    902927 
    903928 
    904929# FP_PROG_LD_BUILD_ID 
  • compiler/ghc.mk

    diff --git a/compiler/ghc.mk b/compiler/ghc.mk
    index a3005db..b4c9ed2 100644
    a b endif 
    105105        @echo 'cRAWCPP_FLAGS         = "$(RAWCPP_FLAGS)"'                   >> $@ 
    106106        @echo 'cLdHasNoCompactUnwind :: String'                             >> $@ 
    107107        @echo 'cLdHasNoCompactUnwind = "$(LdHasNoCompactUnwind)"'           >> $@ 
     108        @echo 'cLdHashSize31         :: String'                             >> $@ 
     109        @echo 'cLdHashSize31         = "$(LdHashSize31)"'                   >> $@ 
     110        @echo 'cLdReduceMemoryOverheads :: String'                          >> $@ 
     111        @echo 'cLdReduceMemoryOverheads = "$(LdReduceMemoryOverheads)"'     >> $@ 
    108112        @echo 'cLdIsGNULd            :: String'                             >> $@ 
    109113        @echo 'cLdIsGNULd            = "$(LdIsGNULd)"'                      >> $@ 
    110114        @echo 'cLdHasBuildId         :: String'                             >> $@ 
  • compiler/main/DriverPipeline.hs

    diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
    index 335df4f..baaf37b 100644
    a b linkBinary dflags o_files dep_packages = do 
    17751775                          then ["-Wl,-no_compact_unwind"] 
    17761776                          else []) 
    17771777 
     1778                      -- Reduce linker memory usage dramatically by setting the 
     1779                      -- hash size to 31 and enabling the "reduce memory 
     1780                      -- overheads" option (if possible).  See #5240. 
     1781                      ++ (if cLdHashSize31 == "YES" 
     1782                          then ["-Wl,--hash-size=31"] 
     1783                          else []) 
     1784 
     1785                      ++ (if cLdReduceMemoryOverheads == "YES" 
     1786                          then ["-Wl,--reduce-memory-overheads"] 
     1787                          else []) 
     1788 
    17781789                      -- '-Wl,-read_only_relocs,suppress' 
    17791790                      -- ld gives loads of warnings like: 
    17801791                      --     ld: warning: text reloc in _base_GHCziArr_unsafeArray_info to _base_GHCziArr_unsafeArray_closure 
  • configure.ac

    diff --git a/configure.ac b/configure.ac
    index aeea6a4..e56f120 100644
    a b dnl ** look to see if we have a C compiler using an llvm back end. 
    533533dnl 
    534534FP_CC_LLVM_BACKEND 
    535535 
    536 FP_PROG_LD_HashSize31 
    537 FP_PROG_LD_ReduceMemoryOverheads 
     536FP_PROG_LD_HASHSIZE31 
     537FP_PROG_LD_REDUCEMEMORYOVERHEADS 
    538538 
    539539FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS]) 
    540540FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0]) 
  • mk/config.mk.in

    diff --git a/mk/config.mk.in b/mk/config.mk.in
    index 1cf8685..eef63b2 100644
    a b LdHasBuildId = @LdHasBuildId@ 
    735735# and compiler/main/DriverPipeline.hs. 
    736736LdHasNoCompactUnwind    = @LdHasNoCompactUnwind@ 
    737737 
     738# Set to YES if ld has the --hash-size flag.  See #5240. 
     739LdHashSize31            = @LdHashSize31@ 
     740 
     741# Set to YES if ld has the --reduce-memory-overheads flag.  See #5240. 
     742LdReduceMemoryOverheads = @LdReduceMemoryOverheads@ 
     743 
    738744# On MSYS, building with SplitObjs=YES fails with  
    739745#   ar: Bad file number 
    740746# see #3201.  We need to specify a smaller max command-line size