locateOneObj: don't look for dynamic libs in static mode
authorSimon Marlow <marlowsd@gmail.com>
Sun, 3 Jan 2010 22:36:37 +0000 (22:36 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Sun, 3 Jan 2010 22:36:37 +0000 (22:36 +0000)
also replace picIsOn with isDynamicGhcLib, as __PIC__ is not the
correct test for whether the GHC library is dynamically linked.

compiler/ghci/Linker.lhs
compiler/utils/Util.lhs

index 43bd80e..d2459f4 100644 (file)
@@ -1084,23 +1084,20 @@ loadFrameworks pkg
 -- If it isn't present, we assume it's a dynamic library.
 locateOneObj :: [FilePath] -> String -> IO LibrarySpec
 locateOneObj dirs lib
- | not picIsOn
+  | not isDynamicGhcLib
     -- When the GHC package was not compiled as dynamic library 
-    -- (=__PIC__ not set), we search for .o libraries first.
+    -- (=DYNAMIC not set), we search for .o libraries.
   = do { mb_obj_path <- findFile mk_obj_path dirs 
        ; case mb_obj_path of
            Just obj_path -> return (Object obj_path)
-           Nothing       -> 
-                do { mb_lib_path <- findFile mk_dyn_lib_path dirs
-                   ; case mb_lib_path of
-                       Just _  -> return (DLL dyn_lib_name)
-                       Nothing -> return (DLL lib) }} -- We assume
- | otherwise
-    -- When the GHC package was compiled as dynamic library (=__PIC__ set),
+           Nothing       -> return (DLL lib) }
+
+  | otherwise
+    -- When the GHC package was compiled as dynamic library (=DYNAMIC set),
     -- we search for .so libraries first.
   = do { mb_lib_path <- findFile mk_dyn_lib_path dirs
        ; case mb_lib_path of
-           Just _ -> return (DLL (lib ++ "-ghc" ++ cProjectVersion))
+           Just _ -> return (DLL dyn_lib_name)
            Nothing       ->
                 do { mb_obj_path <- findFile mk_obj_path dirs
                    ; case mb_obj_path of
index 69b8c7e..81fc0fe 100644 (file)
@@ -7,7 +7,7 @@
 -- | Highly random utility functions
 module Util (
         -- * Flags dependent on the compiler build
-        ghciSupported, debugIsOn, ghciTablesNextToCode, picIsOn,
+        ghciSupported, debugIsOn, ghciTablesNextToCode, isDynamicGhcLib,
         isWindowsHost, isWindowsTarget, isDarwinTarget,
 
         -- * General list processing
@@ -141,11 +141,11 @@ ghciTablesNextToCode = True
 ghciTablesNextToCode = False
 #endif
 
-picIsOn :: Bool
-#ifdef __PIC__
-picIsOn = True
+isDynamicGhcLib :: Bool
+#ifdef DYNAMIC
+isDynamicGhcLib = True
 #else
-picIsOn = False
+isDynamicGhcLib = False
 #endif
 
 isWindowsHost :: Bool