[Git][ghc/ghc][wip/T22060] compiler: Drop --build-id=none hack

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Tue Aug 16 19:58:28 UTC 2022



Ben Gamari pushed to branch wip/T22060 at Glasgow Haskell Compiler / GHC


Commits:
5aa2a581 by Ben Gamari at 2022-08-16T15:58:21-04:00
compiler: Drop --build-id=none hack

Since 2011 the object-joining implementation has had a hack to pass
`--build-id=none` to `ld` when supported, seemingly to work around a
linker bug. This hack is now unnecessary and may break downstream users
who expect objects to have valid build-ids. Remove it.

Closes #22060.

- - - - -


10 changed files:

- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Settings.hs
- compiler/GHC/Settings/IO.hs
- hadrian/bindist/Makefile
- hadrian/cfg/system.config.in
- hadrian/src/Rules/Generate.hs
- − m4/fp_prog_ld_build_id.m4
- mk/config.mk.in
- rts/include/ghc.mk


Changes:

=====================================
compiler/GHC/Driver/Pipeline/Execute.hs
=====================================
@@ -1184,17 +1184,10 @@ joinObjectFiles hsc_env o_files output_fn
   let toolSettings' = toolSettings dflags
       ldIsGnuLd = toolSettings_ldIsGnuLd toolSettings'
       ld_r args = GHC.SysTools.runMergeObjects (hsc_logger hsc_env) (hsc_tmpfs hsc_env) (hsc_dflags hsc_env) (
-                        map GHC.SysTools.Option ld_build_id
-                     ++ [ GHC.SysTools.Option "-o",
+                        [ GHC.SysTools.Option "-o",
                           GHC.SysTools.FileOption "" output_fn ]
                      ++ args)
 
-      -- suppress the generation of the .note.gnu.build-id section,
-      -- which we don't need and sometimes causes ld to emit a
-      -- warning:
-      ld_build_id | toolSettings_ldSupportsBuildId toolSettings' = ["--build-id=none"]
-                  | otherwise                                    = []
-
   if ldIsGnuLd
      then do
           script <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "ldscript"


=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -81,7 +81,6 @@ module GHC.Driver.Session (
         sTopDir,
         sGlobalPackageDatabasePath,
         sLdSupportsCompactUnwind,
-        sLdSupportsBuildId,
         sLdSupportsFilelist,
         sLdIsGnuLd,
         sGccSupportsNoPie,


=====================================
compiler/GHC/Settings.hs
=====================================
@@ -18,7 +18,6 @@ module GHC.Settings
   , sTopDir
   , sGlobalPackageDatabasePath
   , sLdSupportsCompactUnwind
-  , sLdSupportsBuildId
   , sLdSupportsFilelist
   , sLdIsGnuLd
   , sGccSupportsNoPie
@@ -87,7 +86,6 @@ data Settings = Settings
 -- platform-specific and platform-agnostic.
 data ToolSettings = ToolSettings
   { toolSettings_ldSupportsCompactUnwind :: Bool
-  , toolSettings_ldSupportsBuildId       :: Bool
   , toolSettings_ldSupportsFilelist      :: Bool
   , toolSettings_ldIsGnuLd               :: Bool
   , toolSettings_ccSupportsNoPie         :: Bool
@@ -189,8 +187,6 @@ sGlobalPackageDatabasePath = fileSettings_globalPackageDatabase . sFileSettings
 
 sLdSupportsCompactUnwind :: Settings -> Bool
 sLdSupportsCompactUnwind = toolSettings_ldSupportsCompactUnwind . sToolSettings
-sLdSupportsBuildId :: Settings -> Bool
-sLdSupportsBuildId = toolSettings_ldSupportsBuildId . sToolSettings
 sLdSupportsFilelist :: Settings -> Bool
 sLdSupportsFilelist = toolSettings_ldSupportsFilelist . sToolSettings
 sLdIsGnuLd :: Settings -> Bool


=====================================
compiler/GHC/Settings/IO.hs
=====================================
@@ -94,7 +94,6 @@ initSettings top_dir = do
       cc_args  = words cc_args_str ++ unreg_cc_args
       cxx_args = words cxx_args_str
   ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind"
-  ldSupportsBuildId       <- getBooleanSetting "ld supports build-id"
   ldSupportsFilelist      <- getBooleanSetting "ld supports filelist"
   ldIsGnuLd               <- getBooleanSetting "ld is GNU ld"
   arSupportsDashL         <- getBooleanSetting "ar supports -L"
@@ -163,7 +162,6 @@ initSettings top_dir = do
 
     , sToolSettings = ToolSettings
       { toolSettings_ldSupportsCompactUnwind = ldSupportsCompactUnwind
-      , toolSettings_ldSupportsBuildId       = ldSupportsBuildId
       , toolSettings_ldSupportsFilelist      = ldSupportsFilelist
       , toolSettings_ldIsGnuLd               = ldIsGnuLd
       , toolSettings_ccSupportsNoPie         = gccSupportsNoPie


=====================================
hadrian/bindist/Makefile
=====================================
@@ -91,7 +91,6 @@ lib/settings :
 	@echo ',("ld command", "$(SettingsLdCommand)")' >> $@
 	@echo ',("ld flags", "$(SettingsLdFlags)")' >> $@
 	@echo ',("ld supports compact unwind", "$(LdHasNoCompactUnwind)")' >> $@
-	@echo ',("ld supports build-id", "$(LdHasBuildId)")' >> $@
 	@echo ',("ld supports filelist", "$(LdHasFilelist)")' >> $@
 	@echo ',("ld is GNU ld", "$(LdIsGNULd)")' >> $@
 	@echo ',("Merge objects command", "$(SettingsMergeObjectsCommand)")' >> $@


=====================================
hadrian/cfg/system.config.in
=====================================
@@ -136,7 +136,6 @@ conf-merge-objects-args-stage3  = @MergeObjsArgs@
 
 gcc-extra-via-c-opts = @GccExtraViaCOpts@
 ld-has-no-compact-unwind = @LdHasNoCompactUnwind@
-ld-has-build-id = @LdHasBuildId@
 ld-has-filelist = @LdHasFilelist@
 ld-is-gnu-ld = @LdIsGNULd@
 ar-args = @ArArgs@


=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -311,7 +311,6 @@ generateSettings = do
         , ("ld command", expr $ settingsFileSetting SettingsFileSetting_LdCommand)
         , ("ld flags", expr $ settingsFileSetting SettingsFileSetting_LdFlags)
         , ("ld supports compact unwind", expr $ lookupSystemConfig "ld-has-no-compact-unwind")
-        , ("ld supports build-id", expr $ lookupSystemConfig "ld-has-build-id")
         , ("ld supports filelist", expr $ lookupSystemConfig "ld-has-filelist")
         , ("ld is GNU ld", expr $ lookupSystemConfig "ld-is-gnu-ld")
         , ("Merge objects command", expr $ settingsFileSetting SettingsFileSetting_MergeObjectsCommand)


=====================================
m4/fp_prog_ld_build_id.m4 deleted
=====================================
@@ -1,20 +0,0 @@
-# FP_PROG_LD_BUILD_ID
-# ------------
-# Sets the output variable LdHasBuildId to YES if ld supports
-# --build-id, or NO otherwise.
-AC_DEFUN([FP_PROG_LD_BUILD_ID],
-[
-AC_CACHE_CHECK([whether ld understands --build-id], [fp_cv_ld_build_id],
-[echo 'int foo() { return 0; }' > conftest.c
-${CC-cc} -c conftest.c
-if ${LdCmd} -r --build-id=none -o conftest2.o conftest.o > /dev/null 2>&1; then
-   fp_cv_ld_build_id=yes
-else
-   fp_cv_ld_build_id=no
-fi
-rm -rf conftest*])
-FP_CAPITALIZE_YES_NO(["$fp_cv_ld_build_id"], [LdHasBuildId])
-AC_SUBST([LdHasBuildId])
-])# FP_PROG_LD_BUILD_ID
-
-


=====================================
mk/config.mk.in
=====================================
@@ -724,10 +724,6 @@ OPT = @OptCmd@
 # overflowing command-line length limits.
 LdIsGNULd		= @LdIsGNULd@
 
-# Set to YES if ld has the --build-id flag.  Sometimes we need to
-# disable it with --build-id=none.
-LdHasBuildId	        = @LdHasBuildId@
-
 # Set to YES if ld has the --no_compact_unwind flag. See #5019
 # and GHC.Driver.Pipeline.
 LdHasNoCompactUnwind	= @LdHasNoCompactUnwind@


=====================================
rts/include/ghc.mk
=====================================
@@ -202,7 +202,6 @@ $(includes_SETTINGS) : rts/include/Makefile | $$(dir $$@)/.
 	@echo ',("ld command", "$(SettingsLdCommand)")' >> $@
 	@echo ',("ld flags", "$(SettingsLdFlags)")' >> $@
 	@echo ',("ld supports compact unwind", "$(LdHasNoCompactUnwind)")' >> $@
-	@echo ',("ld supports build-id", "$(LdHasBuildId)")' >> $@
 	@echo ',("ld supports filelist", "$(LdHasFilelist)")' >> $@
 	@echo ',("ld is GNU ld", "$(LdIsGNULd)")' >> $@
 	@echo ',("Merge objects command", "$(SettingsMergeObjectsCommand)")' >> $@



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5aa2a581b68576d6cb57f6ebc21f5a8356a3bb79

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5aa2a581b68576d6cb57f6ebc21f5a8356a3bb79
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/20220816/ae3f0f19/attachment-0001.html>


More information about the ghc-commits mailing list