Make -dynamic a proper way, so we read the .dyn_hi files
[ghc-hetmet.git] / compiler / main / Packages.lhs
index ace175d..7cb3337 100644 (file)
@@ -26,6 +26,7 @@ module Packages (
        getPreloadPackagesAnd,
 
         collectIncludeDirs, collectLibraryPaths, collectLinkOpts,
+        packageHsLibs,
 
        -- * Utils
        isDllName
@@ -37,7 +38,7 @@ where
 import PackageConfig   
 import ParsePkgConf    ( loadPackageConfig )
 import DynFlags                ( dopt, DynFlag(..), DynFlags(..), PackageFlag(..) )
-import StaticFlags     ( opt_Static )
+import StaticFlags
 import Config          ( cProjectVersion )
 import Name            ( Name, nameModule_maybe )
 import UniqFM
@@ -49,9 +50,7 @@ import Outputable
 
 import System.Environment ( getEnv )
 import Distribution.InstalledPackageInfo hiding (depends)
-import Distribution.Package hiding (depends)
-import Distribution.Text
-import Distribution.Version
+import Distribution.Package hiding (depends, PackageId)
 import FastString
 import ErrUtils         ( debugTraceMsg, putMsg, Message )
 import Exception
@@ -266,8 +265,8 @@ mungePackagePaths top_dir ps = map munge_pkg ps
   munge_paths = map munge_path
 
   munge_path p 
-         | Just p' <- maybePrefixMatch "$topdir"     p =            top_dir ++ p'
-         | Just p' <- maybePrefixMatch "$httptopdir" p = toHttpPath top_dir ++ p'
+         | Just p' <- stripPrefix "$topdir"     p =            top_dir ++ p'
+         | Just p' <- stripPrefix "$httptopdir" p = toHttpPath top_dir ++ p'
          | otherwise                               = p
 
   toHttpPath p = "file:///" ++ p
@@ -391,8 +390,7 @@ findWiredInPackages dflags pkgs preload this_package = do
                             (haskell98PackageId, [""]),
                             (thPackageId, [""]),
                             (dphSeqPackageId, [""]),
-                            (dphParPackageId, [""]),
-                            (ndpPackageId, ["-seq", "-par"]) ]
+                            (dphParPackageId, [""])]
 
         matches :: PackageConfig -> (PackageId, [String]) -> Bool
         pc `matches` (pid, suffixes)
@@ -640,14 +638,21 @@ getPackageLinkOpts dflags pkgs =
 collectLinkOpts :: DynFlags -> [PackageConfig] -> [String]
 collectLinkOpts dflags ps = concat (map all_opts ps)
   where
-        tag = buildTag dflags
-        rts_tag = rtsBuildTag dflags
+       libs p     = packageHsLibs dflags p ++ extraLibraries p
+       all_opts p = map ("-l" ++) (libs p) ++ ldOptions p
+
+packageHsLibs :: DynFlags -> PackageConfig -> [String]
+packageHsLibs dflags p = map (mkDynName . addSuffix) (hsLibraries p)
+  where
+        non_dyn_ways = filter ((/= WayDyn) . wayName) (ways dflags)
+        -- the name of a shared library is libHSfoo-ghc<version>.so
+        -- we leave out the _dyn, because it is superfluous
+
+        tag     = mkBuildTag (filter (not . wayRTSOnly) non_dyn_ways)
+        rts_tag = mkBuildTag non_dyn_ways
 
        mkDynName | opt_Static = id
                  | otherwise = (++ ("-ghc" ++ cProjectVersion))
-       libs p     = map (mkDynName . addSuffix) (hsLibraries p)
-                        ++ extraLibraries p
-       all_opts p = map ("-l" ++) (libs p) ++ ldOptions p
 
         addSuffix rts@"HSrts"    = rts       ++ (expandTag rts_tag)
         addSuffix other_lib      = other_lib ++ (expandTag tag)