summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-03-24 21:00:44 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-06 13:01:28 -0400
commit3ac80a8609418f9f1e9aa025b182fb3445f14428 (patch)
tree207223dc28b689120628585b3fa0fd3554d1ae5c /hadrian
parent41fcb5cd756f52cd313d90a73f556fa5f3890818 (diff)
downloadhaskell-3ac80a8609418f9f1e9aa025b182fb3445f14428.tar.gz
hadrian: Produce ar archives with L modifier on Windows
Since object files may in fact be archive files, we must ensure that their contents are merged rather than constructing an archive-of-an-archive. See #21068.
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/cfg/system.config.in1
-rw-r--r--hadrian/src/Oracles/Flag.hs2
-rw-r--r--hadrian/src/Settings/Builders/Ar.hs8
3 files changed, 10 insertions, 1 deletions
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in
index 0c2a76b7ac..6544261cd3 100644
--- a/hadrian/cfg/system.config.in
+++ b/hadrian/cfg/system.config.in
@@ -40,6 +40,7 @@ python = @PythonCmd@
#============================
ar-supports-at-file = @ArSupportsAtFile@
+ar-supports-dash-l = @ArSupportsDashL@
cc-llvm-backend = @CcLlvmBackend@
hs-cpp-args = @HaskellCPPArgs@
diff --git a/hadrian/src/Oracles/Flag.hs b/hadrian/src/Oracles/Flag.hs
index 7da72546e3..40ae3e8f9b 100644
--- a/hadrian/src/Oracles/Flag.hs
+++ b/hadrian/src/Oracles/Flag.hs
@@ -12,6 +12,7 @@ import Base
import Oracles.Setting
data Flag = ArSupportsAtFile
+ | ArSupportsDashL
| CrossCompiling
| CcLlvmBackend
| GhcUnregisterised
@@ -34,6 +35,7 @@ flag :: Flag -> Action Bool
flag f = do
let key = case f of
ArSupportsAtFile -> "ar-supports-at-file"
+ ArSupportsDashL -> "ar-supports-dash-l"
CrossCompiling -> "cross-compiling"
CcLlvmBackend -> "cc-llvm-backend"
GhcUnregisterised -> "ghc-unregisterised"
diff --git a/hadrian/src/Settings/Builders/Ar.hs b/hadrian/src/Settings/Builders/Ar.hs
index a4b08d6358..08379f07f8 100644
--- a/hadrian/src/Settings/Builders/Ar.hs
+++ b/hadrian/src/Settings/Builders/Ar.hs
@@ -8,7 +8,13 @@ import Settings.Builders.Common
arBuilderArgs :: Args
arBuilderArgs = mconcat
[ builder (Ar Pack) ? mconcat
- [ arg "q"
+ [ -- When building on platforms which don't support object merging
+ -- we must use the -L flag supported by llvm-ar, which ensures that
+ -- .a files added to the archive are merged into the resulting archive,
+ -- not added as a single file. This requires that we are using llvm-ar
+ --
+ -- See Note [Object merging] in GHC.Driver.Pipeline.Execute for details.
+ ifM ((&&) <$> notStage0 <*> expr (flag ArSupportsDashL)) (arg "qL") (arg "q")
, arg =<< getOutput
]
, builder (Ar Unpack) ? mconcat