[Git][ghc/ghc][master] 8 commits: Enable response files for linker if supported

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon Mar 6 22:07:07 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
5ed77deb by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Enable response files for linker if supported

- - - - -
1e0f6c89 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Synchronize `configure.ac` and `distrib/configure.ac.in`

- - - - -
70560952 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Fix `hadrian/bindist/config.mk.in`

… as suggested by @bgamari

- - - - -
b042b125 by sheaf at 2023-03-06T17:06:50-05:00
Apply 1 suggestion(s) to 1 file(s)
- - - - -
674b6b81 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Try to create somewhat portable `ld` command

I cannot figure out a good way to generate an `ld` command
that works on both Linux and macOS.  Normally you'd use something
like `AC_LINK_IFELSE` for this purpose (I think), but that won't
let us test response file support.

- - - - -
83b0177e by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Quote variables

… as suggested by @bgamari

- - - - -
845f404d by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Fix configure failure on alpine linux

- - - - -
c56a3ae6 by Gabriella Gonzalez at 2023-03-06T17:06:50-05:00
Small fixes to configure script

- - - - -


10 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


Changes:

=====================================
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


=====================================
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


=====================================
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


=====================================
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"`


=====================================
distrib/configure.ac.in
=====================================
@@ -180,6 +180,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
+
 AC_SUBST(CONF_CC_OPTS_STAGE0)
 AC_SUBST(CONF_CC_OPTS_STAGE1)
 AC_SUBST(CONF_CC_OPTS_STAGE2)


=====================================
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)")' >> $@


=====================================
hadrian/bindist/config.mk.in
=====================================
@@ -236,6 +236,7 @@ GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64 s390x), at UseL
 
 GccExtraViaCOpts = @GccExtraViaCOpts@
 LdHasFilelist = @LdHasFilelist@
+LdSupportsResponseFiles = @LdSupportsResponseFiles@
 LdHasBuildId = @LdHasBuildId@
 LdHasFilelist = @LdHasFilelist@
 LdIsGNULd = @LdIsGNULd@


=====================================
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@
 


=====================================
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)


=====================================
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 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 '%q\n' -o conftest conftest.o > 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)
+])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/232cfc241c14ba6a49d9552a90a94857255e455d...c56a3ae681becc7736e5a0e3d0461b8872a02707

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/232cfc241c14ba6a49d9552a90a94857255e455d...c56a3ae681becc7736e5a0e3d0461b8872a02707
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/20230306/b150967f/attachment-0001.html>


More information about the ghc-commits mailing list