Commit 1a50b338 authored by Simon Marlow's avatar Simon Marlow

Don't prematurely link shared libraries against the RTS package

We want to be able to pick the RTS flavour (e.g. -threaded) when we
link the final program.
parent c29b47b7
......@@ -1433,13 +1433,19 @@ linkDynLib dflags o_files dep_packages = do
let verb = getVerbFlag dflags
let o_file = outputFile dflags
pkg_lib_paths <- getPackageLibraryPath dflags dep_packages
-- We don't want to link our dynamic libs against the RTS package,
-- because the RTS lib comes in several flavours and we want to be
-- able to pick the flavour when a binary is linked.
pkgs <- getPreloadPackagesAnd dflags dep_packages
let pkgs_no_rts = filter ((/= rtsPackageId) . packageConfigId) pkgs
let pkg_lib_paths = collectLibraryPaths pkgs_no_rts
let pkg_lib_path_opts = map ("-L"++) pkg_lib_paths
let lib_paths = libraryPaths dflags
let lib_path_opts = map ("-L"++) lib_paths
pkg_link_opts <- getPackageLinkOpts dflags dep_packages
let pkg_link_opts = collectLinkOpts dflags pkgs_no_rts
-- probably _stub.o files
extra_ld_inputs <- readIORef v_Ld_inputs
......
......@@ -26,6 +26,8 @@ module Packages (
getPackageFrameworks,
getPreloadPackagesAnd,
collectIncludeDirs, collectLibraryPaths, collectLinkOpts,
-- * Utils
isDllName
)
......@@ -604,21 +606,29 @@ pprPkg p = text (display (package p))
-- use.
getPackageIncludePath :: DynFlags -> [PackageId] -> IO [String]
getPackageIncludePath dflags pkgs = do
ps <- getPreloadPackagesAnd dflags pkgs
return (nub (filter notNull (concatMap includeDirs ps)))
getPackageIncludePath dflags pkgs =
collectIncludeDirs `fmap` getPreloadPackagesAnd dflags pkgs
collectIncludeDirs :: [PackageConfig] -> [FilePath]
collectIncludeDirs ps = nub (filter notNull (concatMap includeDirs ps))
getPackageLibraryPath :: DynFlags -> [PackageId] -> IO [String]
getPackageLibraryPath dflags pkgs = do
ps <- getPreloadPackagesAnd dflags pkgs
return (nub (filter notNull (concatMap libraryDirs ps)))
getPackageLibraryPath dflags pkgs =
collectLibraryPaths `fmap` getPreloadPackagesAnd dflags pkgs
collectLibraryPaths :: [PackageConfig] -> [FilePath]
collectLibraryPaths ps = nub (filter notNull (concatMap libraryDirs ps))
getPackageLinkOpts :: DynFlags -> [PackageId] -> IO [String]
getPackageLinkOpts dflags pkgs = do
ps <- getPreloadPackagesAnd dflags pkgs
let tag = buildTag dflags
rts_tag = rtsBuildTag dflags
let
getPackageLinkOpts dflags pkgs =
collectLinkOpts dflags `fmap` getPreloadPackagesAnd dflags pkgs
collectLinkOpts :: DynFlags -> [PackageConfig] -> [String]
collectLinkOpts dflags ps = concat (map all_opts ps)
where
tag = buildTag dflags
rts_tag = rtsBuildTag dflags
mkDynName | opt_Static = id
| otherwise = (++ ("-ghc" ++ cProjectVersion))
libs p = map (mkDynName . addSuffix) (hsLibraries p)
......@@ -631,8 +641,6 @@ getPackageLinkOpts dflags pkgs = do
expandTag t | null t = ""
| otherwise = '_':t
return (concat (map all_opts ps))
getPackageExtraCcOpts :: DynFlags -> [PackageId] -> IO [String]
getPackageExtraCcOpts dflags pkgs = do
ps <- getPreloadPackagesAnd dflags pkgs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment