[project @ 2004-11-12 13:35:55 by simonpj]
[ghc-hetmet.git] / ghc / compiler / ghci / Linker.lhs
index ebccb9f..cbb6b6b 100644 (file)
@@ -20,7 +20,7 @@ module Linker ( HValue, showLinkerState,
                linkPackages,
        ) where
 
-#include "../includes/config.h"
+#include "../includes/ghcconfig.h"
 #include "HsVersions.h"
 
 import ObjLink         ( loadDLL, loadObj, unloadObj, resolveObjs, initObjLinker )
@@ -757,19 +757,19 @@ linkPackages dflags new_pkgs
 linkPackage :: DynFlags -> PackageConfig -> IO ()
 linkPackage dflags pkg
    = do 
-        let dirs      =  Packages.library_dirs pkg
-        let libs      =  Packages.hs_libraries pkg ++ extra_libraries pkg
-                               ++ [ lib | '-':'l':lib <- extra_ld_opts pkg ]
+        let dirs      =  Packages.libraryDirs pkg
+        let libs      =  Packages.hsLibraries pkg ++ Packages.extraLibraries pkg
+                               ++ [ lib | '-':'l':lib <- Packages.extraLdOpts pkg ]
         classifieds   <- mapM (locateOneObj dirs) libs
 
         -- Complication: all the .so's must be loaded before any of the .o's.  
        let dlls = [ dll | DLL dll    <- classifieds ]
            objs = [ obj | Object obj <- classifieds ]
 
-       maybePutStr dflags ("Loading package " ++ Packages.name pkg ++ " ... ")
+       maybePutStr dflags ("Loading package " ++ showPackageId (package pkg) ++ " ... ")
 
        -- See comments with partOfGHCi
-       when (Packages.name pkg `notElem` partOfGHCi) $ do
+       when (pkgName (package pkg) `notElem` partOfGHCi) $ do
            loadFrameworks pkg
             -- When a library A needs symbols from a library B, the order in
             -- extra_libraries/extra_ld_opts is "-lA -lB", because that's the
@@ -778,15 +778,19 @@ linkPackage dflags pkg
             -- dlopen-ing A with RTLD_NOW (see addDLL in Linker.c) will fail
             -- when B has not been loaded before. In a nutshell: Reverse the
             -- order of DLLs for dynamic linking.
+           -- This fixes a problem with the HOpenGL package (see "Compiling
+           -- HOpenGL under recent versions of GHC" on the HOpenGL list).
            mapM_ (load_dyn dirs) (reverse dlls)
        
        -- After loading all the DLLs, we can load the static objects.
+       -- Ordering isn't important here, because we do one final link
+       -- step to resolve everything.
        mapM_ loadObj objs
 
         maybePutStr dflags "linking ... "
         ok <- resolveObjs
        if succeeded ok then maybePutStrLn dflags "done."
-             else panic ("can't load package `" ++ name pkg ++ "'")
+             else throwDyn (InstallationError ("unable to load package `" ++ showPackageId (package pkg) ++ "'"))
 
 load_dyn dirs dll = do r <- loadDynamic dirs dll
                       case r of