Add hardwire-lib-paths option and make it default for inplace invocations
authorClemens Fruhwirth <clemens@endorphin.org>
Tue, 17 Jul 2007 19:26:22 +0000 (19:26 +0000)
committerClemens Fruhwirth <clemens@endorphin.org>
Tue, 17 Jul 2007 19:26:22 +0000 (19:26 +0000)
compiler/Makefile
compiler/main/DriverPipeline.hs
compiler/main/StaticFlags.hs

index 252da0d..25cedab 100644 (file)
@@ -725,7 +725,7 @@ endif
 
 $(INPLACE_HS): Makefile $(FPTOOLS_TOP)/mk/config.mk
        echo "import System.Cmd; import $(EnvImport); import System.Exit" > $@
-       echo "main = do args <- $(GetArgs); rawSystem \"$(TOP_ABS)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)\" (\"-B$(TOP_ABS)\":args) >>= exitWith" >> $@
+       echo "main = do args <- $(GetArgs); rawSystem \"$(TOP_ABS)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)\" (\"-B$(TOP_ABS)\":\"-fhardwire-lib-paths\":args) >>= exitWith" >> $@
 
 $(INPLACE_PROG): $(INPLACE_HS)
        $(HC) --make $< -o $@
index 4dc287a..a9e9ab4 100644 (file)
@@ -35,7 +35,7 @@ import Module
 import UniqFM          ( eltsUFM )
 import ErrUtils
 import DynFlags
-import StaticFlags     ( v_Ld_inputs, opt_Static, WayName(..) )
+import StaticFlags     ( v_Ld_inputs, opt_Static, opt_HardwireLibPaths, WayName(..) )
 import Config
 import Panic
 import Util
@@ -1173,7 +1173,9 @@ linkBinary dflags o_files dep_packages = do
     -- dependencies, and eliminating duplicates.
 
     pkg_lib_paths <- getPackageLibraryPath dflags dep_packages
-    let pkg_lib_path_opts = map ("-L"++) pkg_lib_paths
+    let pkg_lib_path_opts = concat (map get_pkg_lib_path_opts pkg_lib_paths)
+       get_pkg_lib_path_opts l | opt_HardwireLibPaths = ["-L" ++ l, "-Wl,-rpath", "-Wl," ++ l]
+                               | otherwise = ["-L" ++ l]
 
     let lib_paths = libraryPaths dflags
     let lib_path_opts = map ("-L"++) lib_paths
index e71c5c7..9c4427c 100644 (file)
@@ -57,6 +57,7 @@ module StaticFlags (
        -- Related to linking
        opt_PIC,
        opt_Static,
+       opt_HardwireLibPaths,
 
        -- misc opts
        opt_IgnoreDotGhci,
@@ -328,6 +329,7 @@ opt_PIC                         = True
 opt_PIC                         = lookUp FSLIT("-fPIC")
 #endif
 opt_Static                     = lookUp  FSLIT("-static")
+opt_HardwireLibPaths           = lookUp  FSLIT("-fhardwire-lib-paths")
 opt_Unregisterised             = lookUp  FSLIT("-funregisterised")
 
 -- Derived, not a real option.  Determines whether we will be compiling
@@ -368,6 +370,7 @@ isStaticFlag f =
        "fexcess-precision",
        "funfolding-update-in-place",
        "static",
+       "fhardwire-lib-paths",
        "funregisterised",
        "fext-core",
        "fcpr-off",