[commit: ghc] master: Add support for OSX ld's -filelist flag (c53ea7c)
Ian Lynagh
igloo at earth.li
Tue Mar 19 02:43:11 CET 2013
Repository : http://darcs.haskell.org/ghc.git/
On branch : master
https://github.com/ghc/ghc/commit/c53ea7c7467a149ff753b907535025634c62dda4
>---------------------------------------------------------------
commit c53ea7c7467a149ff753b907535025634c62dda4
Author: Ian Lynagh <ian at well-typed.com>
Date: Mon Mar 18 22:48:43 2013 +0000
Add support for OSX ld's -filelist flag
Without it, when linking the split objects for Language.Haskell.TH.Syntax,
the commandline was too long when listing all the files directly.
>---------------------------------------------------------------
aclocal.m4 | 32 ++++++++++++++++++++++++++++++++
compiler/main/DriverPipeline.hs | 6 ++++++
compiler/main/DynFlags.hs | 1 +
compiler/main/SysTools.lhs | 2 ++
configure.ac | 1 +
distrib/configure.ac.in | 1 +
settings.in | 1 +
7 files changed, 44 insertions(+)
diff --git a/aclocal.m4 b/aclocal.m4
index e225030..2cfa2f1 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1003,6 +1003,38 @@ AC_SUBST([LdHasNoCompactUnwind])
])# FP_PROG_LD_NO_COMPACT_UNWIND
+# FP_PROG_LD_FILELIST
+# -------------------
+
+# Sets the output variable LdHasFilelist to YES if ld supports
+# -filelist, or NO otherwise.
+AC_DEFUN([FP_PROG_LD_FILELIST],
+[
+AC_CACHE_CHECK([whether ld understands -filelist], [fp_cv_ld_has_filelist],
+[
+ echo 'int foo() { return 0; }' > conftest1.c
+ echo 'int bar() { return 0; }' > conftest2.c
+ ${CC-cc} -c conftest1.c
+ ${CC-cc} -c conftest2.c
+ echo conftest1.o > conftest.o-files
+ echo conftest2.o >> conftest.o-files
+ if ${LdCmd} -r -filelist conftest.o-files -o conftest.o > /dev/null 2>&1
+ then
+ fp_cv_ld_has_filelist=yes
+ else
+ fp_cv_ld_has_filelist=no
+ fi
+ rm -rf conftest*
+])
+if test "$fp_cv_ld_has_filelist" = yes; then
+ LdHasFilelist=YES
+else
+ LdHasFilelist=NO
+fi
+AC_SUBST([LdHasFilelist])
+])# FP_PROG_LD_FILELIST
+
+
# FP_PROG_AR
# ----------
# Sets fp_prog_ar to a (non-Cygwin) path to ar. Exits if no ar can be found
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index fdae0fa..bdc2e8e 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -2134,6 +2134,12 @@ joinObjectFiles dflags o_files output_fn = do
script <- newTempName dflags "ldscript"
writeFile script $ "INPUT(" ++ unwords o_files ++ ")"
ld_r [SysTools.FileOption "" script]
+ else if sLdSupportsFilelist mySettings
+ then do
+ filelist <- newTempName dflags "filelist"
+ writeFile filelist $ unlines o_files
+ ld_r [SysTools.Option "-Wl,-filelist",
+ SysTools.FileOption "-Wl," filelist]
else do
ld_r (map (SysTools.FileOption "") o_files)
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index dbec98a..17484e0 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -758,6 +758,7 @@ data Settings = Settings {
sSystemPackageConfig :: FilePath,
sLdSupportsCompactUnwind :: Bool,
sLdSupportsBuildId :: Bool,
+ sLdSupportsFilelist :: Bool,
sLdIsGnuLd :: Bool,
-- commands for particular phases
sPgm_L :: String,
diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs
index 79af4f6..bacd53e 100644
--- a/compiler/main/SysTools.lhs
+++ b/compiler/main/SysTools.lhs
@@ -243,6 +243,7 @@ initSysTools mbMinusB
++ tntc_gcc_args)
ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind"
ldSupportsBuildId <- getBooleanSetting "ld supports build-id"
+ ldSupportsFilelist <- getBooleanSetting "ld supports filelist"
ldIsGnuLd <- getBooleanSetting "ld is GNU ld"
perl_path <- getSetting "perl command"
@@ -315,6 +316,7 @@ initSysTools mbMinusB
sSystemPackageConfig = pkgconfig_path,
sLdSupportsCompactUnwind = ldSupportsCompactUnwind,
sLdSupportsBuildId = ldSupportsBuildId,
+ sLdSupportsFilelist = ldSupportsFilelist,
sLdIsGnuLd = ldIsGnuLd,
sPgm_L = unlit_path,
sPgm_P = (cpp_prog, cpp_args),
diff --git a/configure.ac b/configure.ac
index 535a619..f2c85bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -557,6 +557,7 @@ FP_PROG_LD_ReduceMemoryOverheads
FP_PROG_LD_IS_GNU
FP_PROG_LD_BUILD_ID
FP_PROG_LD_NO_COMPACT_UNWIND
+FP_PROG_LD_FILELIST
FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 09b5457..6b20f84 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -77,6 +77,7 @@ FP_PROG_LD_ReduceMemoryOverheads
FP_PROG_LD_IS_GNU
FP_PROG_LD_BUILD_ID
FP_PROG_LD_NO_COMPACT_UNWIND
+FP_PROG_LD_FILELIST
#
dnl ** Check gcc version and flags we need to pass it **
diff --git a/settings.in b/settings.in
index c749f23..25699ac 100644
--- a/settings.in
+++ b/settings.in
@@ -6,6 +6,7 @@
("ld flags", "@SettingsLdFlags@"),
("ld supports compact unwind", "@LdHasNoCompactUnwind@"),
("ld supports build-id", "@LdHasBuildId@"),
+ ("ld supports filelist", "@LdHasFilelist@"),
("ld is GNU ld", "@LdIsGNULd@"),
("ar command", "@SettingsArCommand@"),
("ar flags", "@ArArgs@"),
More information about the ghc-commits
mailing list