summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Pipeline.hs
diff options
context:
space:
mode:
authorAdam Sandberg Ericsson <adam@sandbergericsson.se>2020-05-03 11:49:46 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-07-07 13:56:02 -0400
commitf496c9550098ffaa3bf25a3447c138626d79bae0 (patch)
treea0be56bcc35f868f33b60bede633707065aec782 /compiler/GHC/Driver/Pipeline.hs
parentcdfeb3f24f76e8fd30452016676e56fbc827789a (diff)
downloadhaskell-f496c9550098ffaa3bf25a3447c138626d79bae0.tar.gz
add -flink-rts flag to link the rts when linking a shared or static library #18072
By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared.
Diffstat (limited to 'compiler/GHC/Driver/Pipeline.hs')
-rw-r--r--compiler/GHC/Driver/Pipeline.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/GHC/Driver/Pipeline.hs b/compiler/GHC/Driver/Pipeline.hs
index 15cce2f11d..83e637401e 100644
--- a/compiler/GHC/Driver/Pipeline.hs
+++ b/compiler/GHC/Driver/Pipeline.hs
@@ -1937,7 +1937,14 @@ linkStaticLib dflags o_files dep_units = do
output_exists <- doesFileExist full_output_fn
(when output_exists) $ removeFile full_output_fn
- pkg_cfgs <- getPreloadUnitsAnd dflags dep_units
+ pkg_cfgs_init <- getPreloadUnitsAnd dflags dep_units
+
+ let pkg_cfgs
+ | gopt Opt_LinkRts dflags
+ = pkg_cfgs_init
+ | otherwise
+ = filter ((/= rtsUnitId) . unitId) pkg_cfgs_init
+
archives <- concatMapM (collectArchives dflags) pkg_cfgs
ar <- foldl mappend