summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriella Gonzalez <gabriella@mercury.com>2023-02-01 13:44:44 -0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-03-06 17:06:50 -0500
commit5ed77deb1b49bff7bae9660487ee4a40a496476d (patch)
treeff53bb9ff50c50657fc9513a0bb7184f0f3a1403
parent232cfc241c14ba6a49d9552a90a94857255e455d (diff)
downloadhaskell-5ed77deb1b49bff7bae9660487ee4a40a496476d.tar.gz
Enable response files for linker if supported
-rw-r--r--compiler/GHC/Settings.hs4
-rw-r--r--compiler/GHC/Settings/IO.hs2
-rw-r--r--compiler/GHC/SysTools/Tasks.hs5
-rw-r--r--configure.ac2
-rw-r--r--hadrian/bindist/Makefile1
-rw-r--r--hadrian/cfg/system.config.in1
-rw-r--r--hadrian/src/Rules/Generate.hs1
-rw-r--r--m4/fp_ld_supports_response_files.m419
8 files changed, 31 insertions, 4 deletions
diff --git a/compiler/GHC/Settings.hs b/compiler/GHC/Settings.hs
index 291c77b860..c2b34b0c10 100644
--- a/compiler/GHC/Settings.hs
+++ b/compiler/GHC/Settings.hs
@@ -19,6 +19,7 @@ module GHC.Settings
, sGlobalPackageDatabasePath
, sLdSupportsCompactUnwind
, sLdSupportsFilelist
+ , sLdSupportsResponseFiles
, sLdIsGnuLd
, sGccSupportsNoPie
, sUseInplaceMinGW
@@ -87,6 +88,7 @@ data Settings = Settings
data ToolSettings = ToolSettings
{ toolSettings_ldSupportsCompactUnwind :: Bool
, toolSettings_ldSupportsFilelist :: Bool
+ , toolSettings_ldSupportsResponseFiles :: Bool
, toolSettings_ldIsGnuLd :: Bool
, toolSettings_ccSupportsNoPie :: Bool
, toolSettings_useInplaceMinGW :: Bool
@@ -189,6 +191,8 @@ sLdSupportsCompactUnwind :: Settings -> Bool
sLdSupportsCompactUnwind = toolSettings_ldSupportsCompactUnwind . sToolSettings
sLdSupportsFilelist :: Settings -> Bool
sLdSupportsFilelist = toolSettings_ldSupportsFilelist . sToolSettings
+sLdSupportsResponseFiles :: Settings -> Bool
+sLdSupportsResponseFiles = toolSettings_ldSupportsResponseFiles . sToolSettings
sLdIsGnuLd :: Settings -> Bool
sLdIsGnuLd = toolSettings_ldIsGnuLd . sToolSettings
sGccSupportsNoPie :: Settings -> Bool
diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs
index 06952774fd..31c3164bc1 100644
--- a/compiler/GHC/Settings/IO.hs
+++ b/compiler/GHC/Settings/IO.hs
@@ -95,6 +95,7 @@ initSettings top_dir = do
cxx_args = words cxx_args_str
ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind"
ldSupportsFilelist <- getBooleanSetting "ld supports filelist"
+ ldSupportsResponseFiles <- getBooleanSetting "ld supports response files"
ldIsGnuLd <- getBooleanSetting "ld is GNU ld"
arSupportsDashL <- getBooleanSetting "ar supports -L"
@@ -163,6 +164,7 @@ initSettings top_dir = do
, sToolSettings = ToolSettings
{ toolSettings_ldSupportsCompactUnwind = ldSupportsCompactUnwind
, toolSettings_ldSupportsFilelist = ldSupportsFilelist
+ , toolSettings_ldSupportsResponseFiles = ldSupportsResponseFiles
, toolSettings_ldIsGnuLd = ldIsGnuLd
, toolSettings_ccSupportsNoPie = gccSupportsNoPie
, toolSettings_useInplaceMinGW = useInplaceMinGW
diff --git a/compiler/GHC/SysTools/Tasks.hs b/compiler/GHC/SysTools/Tasks.hs
index 66f0346886..463cf39145 100644
--- a/compiler/GHC/SysTools/Tasks.hs
+++ b/compiler/GHC/SysTools/Tasks.hs
@@ -29,7 +29,6 @@ import GHC.Utils.Outputable
import GHC.Utils.Misc
import GHC.Utils.Logger
import GHC.Utils.TmpFs
-import GHC.Utils.Constants (isWindowsHost)
import GHC.Utils.Panic
import Data.List (tails, isPrefixOf)
@@ -350,9 +349,7 @@ runMergeObjects logger tmpfs dflags args =
, "does not support object merging." ]
optl_args = map Option (getOpts dflags opt_lm)
args2 = args0 ++ args ++ optl_args
- -- N.B. Darwin's ld64 doesn't support response files. Consequently we only
- -- use them on Windows where they are truly necessary.
- if isWindowsHost
+ if toolSettings_ldSupportsResponseFiles (toolSettings dflags)
then do
mb_env <- getGccEnv args2
runSomethingResponseFile logger tmpfs dflags id "Merge objects" p args2 mb_env
diff --git a/configure.ac b/configure.ac
index 99a91e42d6..a0df24a50a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -663,6 +663,8 @@ FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0])
FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1])
FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2])
+FP_LD_SUPPORTS_RESPONSE_FILES()
+
GHC_LLVM_TARGET_SET_VAR
# we intend to pass trough --targets to llvm as is.
LLVMTarget_CPP=` echo "$LlvmTarget"`
diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile
index f36ffa57c0..274772e80a 100644
--- a/hadrian/bindist/Makefile
+++ b/hadrian/bindist/Makefile
@@ -92,6 +92,7 @@ lib/settings : config.mk
@echo ',("ld flags", "$(SettingsLdFlags)")' >> $@
@echo ',("ld supports compact unwind", "$(LdHasNoCompactUnwind)")' >> $@
@echo ',("ld supports filelist", "$(LdHasFilelist)")' >> $@
+ @echo ',("ld supports response files", "$(LdSupportsResponseFiles)")' >> $@
@echo ',("ld is GNU ld", "$(LdIsGNULd)")' >> $@
@echo ',("Merge objects command", "$(SettingsMergeObjectsCommand)")' >> $@
@echo ',("Merge objects flags", "$(SettingsMergeObjectsFlags)")' >> $@
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in
index 6a891b4363..57c57aa057 100644
--- a/hadrian/cfg/system.config.in
+++ b/hadrian/cfg/system.config.in
@@ -140,6 +140,7 @@ conf-merge-objects-args-stage3 = @MergeObjsArgs@
gcc-extra-via-c-opts = @GccExtraViaCOpts@
ld-has-no-compact-unwind = @LdHasNoCompactUnwind@
ld-has-filelist = @LdHasFilelist@
+ld-supports-response-files = @LdSupportsResponseFiles@
ld-is-gnu-ld = @LdIsGNULd@
ar-args = @ArArgs@
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index fbd6f8d9aa..1e905438eb 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -427,6 +427,7 @@ generateSettings = do
, ("ld flags", expr $ settingsFileSetting SettingsFileSetting_LdFlags)
, ("ld supports compact unwind", expr $ lookupSystemConfig "ld-has-no-compact-unwind")
, ("ld supports filelist", expr $ lookupSystemConfig "ld-has-filelist")
+ , ("ld supports response files", expr $ lookupSystemConfig "ld-supports-response-files")
, ("ld is GNU ld", expr $ lookupSystemConfig "ld-is-gnu-ld")
, ("Merge objects command", expr $ settingsFileSetting SettingsFileSetting_MergeObjectsCommand)
, ("Merge objects flags", expr $ settingsFileSetting SettingsFileSetting_MergeObjectsFlags)
diff --git a/m4/fp_ld_supports_response_files.m4 b/m4/fp_ld_supports_response_files.m4
new file mode 100644
index 0000000000..5596169dcb
--- /dev/null
+++ b/m4/fp_ld_supports_response_files.m4
@@ -0,0 +1,19 @@
+# FP_LD_SUPPORTS_RESPONSE_FILES
+# --------------------
+# See if whether we are using a version of ld64 on darwin platforms which
+# supports response files.
+AC_DEFUN([FP_LD_SUPPORTS_RESPONSE_FILES], [
+ AC_MSG_CHECKING([whether $LD supports response files])
+ echo 'int main(void) {return 0;}' > conftest.c
+ $CC -c -o conftest.o conftest.c > /dev/null 2>&1
+ if $LD @<(printf '%q\n' -o conftest conftest.o) > /dev/null 2>&1
+ then
+ LdSupportsResponseFiles=YES
+ AC_MSG_RESULT([yes])
+ else
+ LdSupportsResponseFiles=NO
+ AC_MSG_RESULT([no])
+ fi
+ rm -f conftest.c conftest
+ AC_SUBST(LdSupportsResponseFiles)
+])