[Git][ghc/ghc][wip/romes/merge-tools-supports-response-files] Configure MergeObjs supports response files rather than Ld

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Mon Jun 26 11:43:53 UTC 2023



Rodrigo Mesquita pushed to branch wip/romes/merge-tools-supports-response-files at Glasgow Haskell Compiler / GHC


Commits:
69fa79ee by Rodrigo Mesquita at 2023-06-26T12:43:44+01: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
@@ -88,7 +88,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
@@ -191,8 +191,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
=====================================
@@ -104,7 +104,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"
 
@@ -173,7 +173,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
=====================================
@@ -349,7 +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
-    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
=====================================
@@ -649,7 +649,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
=====================================
@@ -177,7 +177,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 ',("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)")' >> $@
+	@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
=====================================
@@ -139,7 +139,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
=====================================
@@ -449,10 +449,10 @@ 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)
+        , ("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/69fa79eef1606af5431d987b0206f9d43b4cfe39

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/69fa79eef1606af5431d987b0206f9d43b4cfe39
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/20230626/c4a088f7/attachment-0001.html>


More information about the ghc-commits mailing list