Make -dynamic a proper way, so we read the .dyn_hi files
[ghc-hetmet.git] / compiler / main / Packages.lhs
index c5784ce..7cb3337 100644 (file)
@@ -37,8 +37,8 @@ where
 
 import PackageConfig   
 import ParsePkgConf    ( loadPackageConfig )
-import DynFlags                ( dopt, DynFlag(..), DynFlags(..), PackageFlag(..), GhcLink(..) )
-import StaticFlags     ( opt_Static )
+import DynFlags                ( dopt, DynFlag(..), DynFlags(..), PackageFlag(..) )
+import StaticFlags
 import Config          ( cProjectVersion )
 import Name            ( Name, nameModule_maybe )
 import UniqFM
@@ -51,8 +51,6 @@ import Outputable
 import System.Environment ( getEnv )
 import Distribution.InstalledPackageInfo hiding (depends)
 import Distribution.Package hiding (depends, PackageId)
-import Distribution.Text
-import Distribution.Version
 import FastString
 import ErrUtils         ( debugTraceMsg, putMsg, Message )
 import Exception
@@ -267,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
@@ -390,7 +388,6 @@ findWiredInPackages dflags pkgs preload this_package = do
                             (basePackageId, [""]),
                             (rtsPackageId, [""]),
                             (haskell98PackageId, [""]),
-                            (sybPackageId, [""]),
                             (thPackageId, [""]),
                             (dphSeqPackageId, [""]),
                             (dphParPackageId, [""])]
@@ -563,7 +560,7 @@ mkPackageState dflags orig_pkg_db preload0 this_package = do
 
       -- add base & rts to the preload packages
       basicLinkedPackages
-       | dopt Opt_AutoLinkPackages dflags && (ghcLink dflags) /= LinkDynLib
+       | dopt Opt_AutoLinkPackages dflags
           = filter (flip elemUFM pkg_db) [basePackageId, rtsPackageId]
        | otherwise = []
       -- but in any case remove the current package from the set of
@@ -647,8 +644,12 @@ collectLinkOpts dflags ps = concat (map all_opts ps)
 packageHsLibs :: DynFlags -> PackageConfig -> [String]
 packageHsLibs dflags p = map (mkDynName . addSuffix) (hsLibraries p)
   where
-        tag = buildTag dflags
-        rts_tag = rtsBuildTag dflags
+        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))