diff --git a/hadrian/doc/flavours.md b/hadrian/doc/flavours.md index 0ab2b6343628ae083641a6bbb56782b7fc221ab2..c7f02ca4a5f6643a5416dcf9c8ea0e6c30c4792b 100644 --- a/hadrian/doc/flavours.md +++ b/hadrian/doc/flavours.md @@ -299,6 +299,10 @@ The supported transformers are listed below: <td><code>fully_static</code></td> <td>Produce fully statically-linked executables and build libraries suitable for static linking.</td> </tr> + <tr> + <td><code>host_fully_static</code></td> + <td>Ensure host executables are fully static, while still permitting shared target libraries.</td> + </tr> <tr> <td><code>collect_timings</code></td> <td>Collects timings while building the stage2+ compiler by adding the diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs index 868284c33179cdc732ff6b14219c9c3acdde695d..793a55a036cf226952c4401fbb8321b11f7a3248 100644 --- a/hadrian/src/Flavour.hs +++ b/hadrian/src/Flavour.hs @@ -60,6 +60,7 @@ flavourTransformers = M.fromList , "omit_pragmas" =: omitPragmas , "ipe" =: enableIPE , "fully_static" =: fullyStatic + , "host_fully_static" =: hostFullyStatic , "collect_timings" =: collectTimings , "assertions" =: enableAssertions , "debug_ghc" =: debugGhc Stage2 @@ -371,6 +372,23 @@ fullyStatic flavour = , builder (Ghc LinkHs) ? pure [ "-optl", "-static" ] ] +-- | Ensure stage0 executables and libraries are fully static. Useful +-- for building cross GHC bindists that still contain shared target +-- libraries. +hostFullyStatic :: Flavour -> Flavour +hostFullyStatic flavour = + addArgs staticExec $ disableDynamicGhcPrograms flavour + where + -- Unlike 'fullyStatic', we need to ensure these flags are only + -- applied to host code. + staticExec :: Args + staticExec = stage0 ? mconcat + [ + builder (Ghc CompileHs) ? pure [ "-fPIC", "-static" ] + , builder (Ghc CompileCWithGhc) ? pure [ "-fPIC", "-optc", "-static"] + , builder (Ghc LinkHs) ? pure [ "-optl", "-static" ] + ] + -- | Build stage2 dependencies with options to enable collection of compiler -- stats. collectTimings :: Flavour -> Flavour