summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-03-28 12:08:01 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-06 13:01:28 -0400
commitd2ae0a3a1a8e31e5d769f1aea95e85793043cb3a (patch)
tree37951c698d81838d84b4104936371d39e013b4b1
parent295c35c5cfda67c11222f99fb338d3cac52abac1 (diff)
downloadhaskell-d2ae0a3a1a8e31e5d769f1aea95e85793043cb3a.tar.gz
Build ar archives with -L when "joining" objects
Since there may be .o files which are in fact archives.
-rw-r--r--compiler/GHC/Driver/Pipeline/Execute.hs4
-rw-r--r--compiler/GHC/Settings.hs4
-rw-r--r--compiler/GHC/Settings/IO.hs2
-rw-r--r--distrib/configure.ac.in1
-rw-r--r--hadrian/bindist/Makefile1
-rw-r--r--hadrian/src/Rules/Generate.hs1
-rw-r--r--mk/config.mk.in1
-rw-r--r--rts/include/ghc.mk1
8 files changed, 14 insertions, 1 deletions
diff --git a/compiler/GHC/Driver/Pipeline/Execute.hs b/compiler/GHC/Driver/Pipeline/Execute.hs
index 902ef68f3a..8a185bf4ec 100644
--- a/compiler/GHC/Driver/Pipeline/Execute.hs
+++ b/compiler/GHC/Driver/Pipeline/Execute.hs
@@ -1179,8 +1179,10 @@ joinObjectFiles hsc_env o_files output_fn
| otherwise = do
withAtomicRename output_fn $ \tmp_ar ->
- liftIO $ runAr logger dflags Nothing $ map Option $ ["rc", tmp_ar] ++ o_files
+ liftIO $ runAr logger dflags Nothing $ map Option $ ["qc" ++ dashL, tmp_ar] ++ o_files
where
+ dashLSupported = sArSupportsDashL (settings dflags)
+ dashL = if dashLSupported then "L" else ""
can_merge_objs = isJust (pgm_lm (hsc_dflags hsc_env))
dflags = hsc_dflags hsc_env
tmpfs = hsc_tmpfs hsc_env
diff --git a/compiler/GHC/Settings.hs b/compiler/GHC/Settings.hs
index 2014a437ca..92bfa75699 100644
--- a/compiler/GHC/Settings.hs
+++ b/compiler/GHC/Settings.hs
@@ -23,6 +23,7 @@ module GHC.Settings
, sLdIsGnuLd
, sGccSupportsNoPie
, sUseInplaceMinGW
+ , sArSupportsDashL
, sPgm_L
, sPgm_P
, sPgm_F
@@ -91,6 +92,7 @@ data ToolSettings = ToolSettings
, toolSettings_ldIsGnuLd :: Bool
, toolSettings_ccSupportsNoPie :: Bool
, toolSettings_useInplaceMinGW :: Bool
+ , toolSettings_arSupportsDashL :: Bool
-- commands for particular phases
, toolSettings_pgm_L :: String
@@ -197,6 +199,8 @@ sGccSupportsNoPie :: Settings -> Bool
sGccSupportsNoPie = toolSettings_ccSupportsNoPie . sToolSettings
sUseInplaceMinGW :: Settings -> Bool
sUseInplaceMinGW = toolSettings_useInplaceMinGW . sToolSettings
+sArSupportsDashL :: Settings -> Bool
+sArSupportsDashL = toolSettings_arSupportsDashL . sToolSettings
sPgm_L :: Settings -> String
sPgm_L = toolSettings_pgm_L . sToolSettings
diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs
index 08e60776a3..8e23706410 100644
--- a/compiler/GHC/Settings/IO.hs
+++ b/compiler/GHC/Settings/IO.hs
@@ -96,6 +96,7 @@ initSettings top_dir = do
ldSupportsBuildId <- getBooleanSetting "ld supports build-id"
ldSupportsFilelist <- getBooleanSetting "ld supports filelist"
ldIsGnuLd <- getBooleanSetting "ld is GNU ld"
+ arSupportsDashL <- getBooleanSetting "ar supports -L"
let globalpkgdb_path = installed "package.conf.d"
ghc_usage_msg_path = installed "ghc-usage.txt"
@@ -167,6 +168,7 @@ initSettings top_dir = do
, toolSettings_ldIsGnuLd = ldIsGnuLd
, toolSettings_ccSupportsNoPie = gccSupportsNoPie
, toolSettings_useInplaceMinGW = useInplaceMinGW
+ , toolSettings_arSupportsDashL = arSupportsDashL
, toolSettings_pgm_L = unlit_path
, toolSettings_pgm_P = (cpp_prog, cpp_args)
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index 6f9237cb32..d5b99cbb8a 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -228,6 +228,7 @@ AC_SUBST(TargetWordBigEndian)
dnl ** how to invoke `ar' and `ranlib'
#
FP_PROG_AR_SUPPORTS_ATFILE
+FP_PROG_AR_SUPPORTS_DASH_L
FP_PROG_AR_NEEDS_RANLIB
RanlibCmd="$RANLIB"
AC_SUBST([RanlibCmd])
diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile
index e9b1ce1cf7..bac7011a84 100644
--- a/hadrian/bindist/Makefile
+++ b/hadrian/bindist/Makefile
@@ -121,6 +121,7 @@ lib/settings :
@echo ',("ar command", "$(SettingsArCommand)")' >> $@
@echo ',("ar flags", "$(ArArgs)")' >> $@
@echo ',("ar supports at file", "$(ArSupportsAtFile)")' >> $@
+ @echo ',("ar supports -L", "$(ArSupportsDashL)")' >> $@
@echo ',("ranlib command", "$(SettingsRanlibCommand)")' >> $@
@echo ',("otool command", "$(SettingsOtoolCommand)")' >> $@
@echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index 9350b1b2ca..db220a98c4 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -311,6 +311,7 @@ generateSettings = do
, ("ar command", expr $ settingsFileSetting SettingsFileSetting_ArCommand)
, ("ar flags", expr $ lookupSystemConfig "ar-args")
, ("ar supports at file", expr $ yesNo <$> flag ArSupportsAtFile)
+ , ("ar supports -L", expr $ yesNo <$> flag ArSupportsDashL)
, ("ranlib command", expr $ settingsFileSetting SettingsFileSetting_RanlibCommand)
, ("otool command", expr $ settingsFileSetting SettingsFileSetting_OtoolCommand)
, ("install_name_tool command", expr $ settingsFileSetting SettingsFileSetting_InstallNameToolCommand)
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 1559e98ea3..06e1dabd96 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -682,6 +682,7 @@ endif
AR = @ArCmd@
AR_OPTS = @ArArgs@
ArSupportsAtFile = @ArSupportsAtFile@
+ArSupportsDashL = @ArSupportsDashL@
AR_STAGE0 = @AR_STAGE0@
AR_STAGE1 = $(AR)
diff --git a/rts/include/ghc.mk b/rts/include/ghc.mk
index 2fc14d5bef..f5a198bcdd 100644
--- a/rts/include/ghc.mk
+++ b/rts/include/ghc.mk
@@ -209,6 +209,7 @@ $(includes_SETTINGS) : rts/include/Makefile | $$(dir $$@)/.
@echo ',("ar command", "$(SettingsArCommand)")' >> $@
@echo ',("ar flags", "$(ArArgs)")' >> $@
@echo ',("ar supports at file", "$(ArSupportsAtFile)")' >> $@
+ @echo ',("ar supports -L", "$(ArSupportsDashL)")' >> $@
@echo ',("ranlib command", "$(SettingsRanlibCommand)")' >> $@
@echo ',("otool command", "$(SettingsOtoolCommand)")' >> $@
@echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@