[Git][ghc/ghc][master] Configure MergeObjs supports response files rather than Ld
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Thu Jun 29 01:11:41 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
fcf310e7 by Rodrigo Mesquita at 2023-06-28T21:11:21-04:00
Configure MergeObjs supports response files rather than Ld
The previous configuration script to test whether Ld supported response
files was
* Incorrect (see #23542)
* Used, in practice, to check if the *merge objects tool* supported
response files.
This commit modifies the macro to run the merge objects tool (rather
than Ld), using a response file, and checking the result with $NM
Fixes #23542
- - - - -
11 changed files:
- compiler/GHC/Settings.hs
- compiler/GHC/Settings/IO.hs
- compiler/GHC/SysTools/Tasks.hs
- configure.ac
- distrib/configure.ac.in
- hadrian/bindist/Makefile
- hadrian/bindist/config.mk.in
- hadrian/cfg/system.config.in
- hadrian/src/Rules/Generate.hs
- − m4/fp_ld_supports_response_files.m4
- + m4/fp_merge_objects_supports_response_files.m4
Changes:
=====================================
compiler/GHC/Settings.hs
=====================================
@@ -19,7 +19,7 @@ module GHC.Settings
, sGlobalPackageDatabasePath
, sLdSupportsCompactUnwind
, sLdSupportsFilelist
- , sLdSupportsResponseFiles
+ , sMergeObjsSupportsResponseFiles
, sLdIsGnuLd
, sGccSupportsNoPie
, sUseInplaceMinGW
@@ -89,7 +89,7 @@ data Settings = Settings
data ToolSettings = ToolSettings
{ toolSettings_ldSupportsCompactUnwind :: Bool
, toolSettings_ldSupportsFilelist :: Bool
- , toolSettings_ldSupportsResponseFiles :: Bool
+ , toolSettings_mergeObjsSupportsResponseFiles :: Bool
, toolSettings_ldIsGnuLd :: Bool
, toolSettings_ccSupportsNoPie :: Bool
, toolSettings_useInplaceMinGW :: Bool
@@ -195,8 +195,8 @@ sLdSupportsCompactUnwind :: Settings -> Bool
sLdSupportsCompactUnwind = toolSettings_ldSupportsCompactUnwind . sToolSettings
sLdSupportsFilelist :: Settings -> Bool
sLdSupportsFilelist = toolSettings_ldSupportsFilelist . sToolSettings
-sLdSupportsResponseFiles :: Settings -> Bool
-sLdSupportsResponseFiles = toolSettings_ldSupportsResponseFiles . sToolSettings
+sMergeObjsSupportsResponseFiles :: Settings -> Bool
+sMergeObjsSupportsResponseFiles = toolSettings_mergeObjsSupportsResponseFiles . sToolSettings
sLdIsGnuLd :: Settings -> Bool
sLdIsGnuLd = toolSettings_ldIsGnuLd . sToolSettings
sGccSupportsNoPie :: Settings -> Bool
=====================================
compiler/GHC/Settings/IO.hs
=====================================
@@ -107,7 +107,7 @@ initSettings top_dir = do
ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind"
ldSupportsFilelist <- getBooleanSetting "ld supports filelist"
- ldSupportsResponseFiles <- getBooleanSetting "ld supports response files"
+ mergeObjsSupportsResponseFiles <- getBooleanSetting "Merge objects supports response files"
ldIsGnuLd <- getBooleanSetting "ld is GNU ld"
arSupportsDashL <- getBooleanSetting "ar supports -L"
@@ -175,7 +175,7 @@ initSettings top_dir = do
, sToolSettings = ToolSettings
{ toolSettings_ldSupportsCompactUnwind = ldSupportsCompactUnwind
, toolSettings_ldSupportsFilelist = ldSupportsFilelist
- , toolSettings_ldSupportsResponseFiles = ldSupportsResponseFiles
+ , toolSettings_mergeObjsSupportsResponseFiles = mergeObjsSupportsResponseFiles
, toolSettings_ldIsGnuLd = ldIsGnuLd
, toolSettings_ccSupportsNoPie = gccSupportsNoPie
, toolSettings_useInplaceMinGW = useInplaceMinGW
=====================================
compiler/GHC/SysTools/Tasks.hs
=====================================
@@ -363,7 +363,7 @@ runMergeObjects logger tmpfs dflags args =
, "does not support object merging." ]
optl_args = map Option (getOpts dflags opt_lm)
args2 = args0 ++ args ++ optl_args
- if toolSettings_ldSupportsResponseFiles (toolSettings dflags)
+ if toolSettings_mergeObjsSupportsResponseFiles (toolSettings dflags)
then do
mb_env <- getGccEnv args2
runSomethingResponseFile logger tmpfs dflags id "Merge objects" p args2 mb_env
=====================================
configure.ac
=====================================
@@ -646,7 +646,7 @@ 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
+FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES
GHC_LLVM_TARGET_SET_VAR
# we intend to pass trough --targets to llvm as is.
=====================================
distrib/configure.ac.in
=====================================
@@ -174,7 +174,7 @@ 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
+FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES
AC_SUBST(CONF_CC_OPTS_STAGE0)
AC_SUBST(CONF_CC_OPTS_STAGE1)
=====================================
hadrian/bindist/Makefile
=====================================
@@ -91,10 +91,10 @@ lib/settings : config.mk
@echo ',("Haskell CPP flags", "$(SettingsHaskellCPPFlags)")' >> $@
@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)")' >> $@
+ @echo ',("Merge objects supports response files", "$(MergeObjsSupportsResponseFiles)")' >> $@
@echo ',("ar command", "$(SettingsArCommand)")' >> $@
@echo ',("ar flags", "$(ArArgs)")' >> $@
@echo ',("ar supports at file", "$(ArSupportsAtFile)")' >> $@
=====================================
hadrian/bindist/config.mk.in
=====================================
@@ -235,7 +235,7 @@ GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64 s390x), at UseL
# See Note [tooldir: How GHC finds mingw on Windows]
LdHasFilelist = @LdHasFilelist@
-LdSupportsResponseFiles = @LdSupportsResponseFiles@
+MergeObjsSupportsResponseFiles = @MergeObjsSupportsResponseFiles@
LdHasBuildId = @LdHasBuildId@
LdHasFilelist = @LdHasFilelist@
LdIsGNULd = @LdIsGNULd@
=====================================
hadrian/cfg/system.config.in
=====================================
@@ -136,7 +136,7 @@ conf-merge-objects-args-stage3 = @MergeObjsArgs@
ld-has-no-compact-unwind = @LdHasNoCompactUnwind@
ld-has-filelist = @LdHasFilelist@
-ld-supports-response-files = @LdSupportsResponseFiles@
+merge-objs-supports-response-files = @MergeObjsSupportsResponseFiles@
ld-is-gnu-ld = @LdIsGNULd@
ar-args = @ArArgs@
=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -450,10 +450,10 @@ generateSettings = do
, ("Haskell CPP flags", expr $ settingsFileSetting SettingsFileSetting_HaskellCPPFlags)
, ("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)
+ , ("Merge objects supports response files", expr $ lookupSystemConfig "merge-objs-supports-response-files")
, ("ar command", expr $ settingsFileSetting SettingsFileSetting_ArCommand)
, ("ar flags", expr $ lookupSystemConfig "ar-args")
, ("ar supports at file", expr $ yesNo <$> flag ArSupportsAtFile)
=====================================
m4/fp_ld_supports_response_files.m4 deleted
=====================================
@@ -1,19 +0,0 @@
-# FP_LD_SUPPORTS_RESPONSE_FILES
-# --------------------
-# See if whether we are using a version of ld 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
- printf -- "-o\nconftest\nconftest.o\n" > args.txt
- if "$LD" -shared @args.txt > /dev/null 2>&1 || "$LD" -dylib @args.txt > /dev/null 2>&1
- then
- LdSupportsResponseFiles=YES
- AC_MSG_RESULT([yes])
- else
- LdSupportsResponseFiles=NO
- AC_MSG_RESULT([no])
- fi
- rm -f conftest.c conftest args.txt
- AC_SUBST(LdSupportsResponseFiles)
-])
=====================================
m4/fp_merge_objects_supports_response_files.m4
=====================================
@@ -0,0 +1,22 @@
+# FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES
+# --------------------
+# See if whether we are using a version of the merge objects tool which supports response files.
+AC_DEFUN([FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES], [
+ AC_MSG_CHECKING([whether $LD supports response files])
+ echo 'int funA(int x) {return x;}' > conftesta.c
+ echo 'int funB(int x) {return x;}' > conftestb.c
+ "$CC" -c -o conftesta.o conftesta.c > /dev/null 2>&1
+ "$CC" -c -o conftestb.o conftestb.c > /dev/null 2>&1
+ printf -- "-o\nconftest.o\nconftesta.o\nconftestb.o\n" > args.txt
+ "$MergeObjsCmd" "$MergeObjsArgs" @args.txt > /dev/null 2>&1
+ if ("$NM" conftest.o | grep "funA" > /dev/null 2>&1) && ("$NM" conftest.o | grep "funB" > /dev/null 2>&1)
+ then
+ MergeObjsSupportsResponseFiles=YES
+ AC_MSG_RESULT([yes])
+ else
+ MergeObjsSupportsResponseFiles=NO
+ AC_MSG_RESULT([no])
+ fi
+ rm -f conftesta.c conftestb.c conftesta.o conftestb.o conftest.o args.txt
+ AC_SUBST(MergeObjsSupportsResponseFiles)
+])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fcf310e7c90f547f3d6b6b265d4f60730f910a3f
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fcf310e7c90f547f3d6b6b265d4f60730f910a3f
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230628/24cdc5ef/attachment-0001.html>
More information about the ghc-commits
mailing list