diff --git a/hadrian/doc/flavours.md b/hadrian/doc/flavours.md index 24c2945995d01d8366cec2c0f7fb1420b6df54f0..7a3e75cf3049cebfea70c05cf5e8c329d57bfd65 100644 --- a/hadrian/doc/flavours.md +++ b/hadrian/doc/flavours.md @@ -294,6 +294,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 b4f92fbd62bc3e9db97153ed9fbf08eaf95fc874..d48772276427e462b75ec0b2e6fae75585da5412 100644 --- a/hadrian/src/Flavour.hs +++ b/hadrian/src/Flavour.hs @@ -57,6 +57,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 @@ -354,6 +355,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