From f496c9550098ffaa3bf25a3447c138626d79bae0 Mon Sep 17 00:00:00 2001 From: Adam Sandberg Ericsson Date: Sun, 3 May 2020 11:49:46 +0100 Subject: 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. --- compiler/GHC/SysTools.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'compiler/GHC/SysTools.hs') diff --git a/compiler/GHC/SysTools.hs b/compiler/GHC/SysTools.hs index ab83b3bf2a..0b71e8ccde 100644 --- a/compiler/GHC/SysTools.hs +++ b/compiler/GHC/SysTools.hs @@ -274,7 +274,9 @@ linkDynLib dflags0 o_files dep_packages pkgs_no_rts = case os of OSMinGW32 -> pkgs - _ -> + _ | gopt Opt_LinkRts dflags -> + pkgs + | otherwise -> filter ((/= rtsUnitId) . unitId) pkgs let pkg_link_opts = let (package_hs_libs, extra_libs, other_flags) = collectLinkOpts dflags pkgs_no_rts in package_hs_libs ++ extra_libs ++ other_flags -- cgit v1.2.1