summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2008-07-24 15:50:01 +0000
committerSimon Marlow <marlowsd@gmail.com>2008-07-24 15:50:01 +0000
commit1a50b338952e91251197d4cf4c4f0a0e266e99a7 (patch)
tree2a9ac897e64bc8d4ee2d08b912f15ce4094c3675
parentc29b47b74c7625c66d81405907e303ea66bdb061 (diff)
downloadhaskell-1a50b338952e91251197d4cf4c4f0a0e266e99a7.tar.gz
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.
-rw-r--r--compiler/main/DriverPipeline.hs10
-rw-r--r--compiler/main/Packages.lhs34
2 files changed, 29 insertions, 15 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 9b0cd0e95c..983bebef6f 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -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
diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs
index c98992ac24..b6c320fcad 100644
--- a/compiler/main/Packages.lhs
+++ b/compiler/main/Packages.lhs
@@ -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