Commit 80cabc9a authored by Stephen Blackheath's avatar Stephen Blackheath

Add -dylib-install-name option to GHC so the install name can be set for dynamic libs on Mac OS/X.

parent 40d05957
......@@ -1643,16 +1643,22 @@ linkDynLib dflags o_files dep_packages = do
-- later, so that it will not complain about the use of the option
-- -undefined dynamic_lookup above.
-- -install_name
-- Causes the dynamic linker to ignore the DYLD_LIBRARY_PATH when loading
-- this lib and instead look for it at its absolute path.
-- When installing the .dylibs (see target.mk), we'll change that path to
-- point to the place they are installed. Therefore, we won't have to set
-- up DYLD_LIBRARY_PATH specifically for ghc.
-- Mac OS/X stores the path where a dynamic library is (to be) installed
-- in the library itself. It's called the "install name" of the library.
-- Then any library or executable that links against it before it's
-- installed will search for it in its ultimate install location. By
-- default we set the install name to the absolute path at build time, but
-- it can be overridden by the -dylib-install-name option passed to ghc.
-- Cabal does this.
-----------------------------------------------------------------------------
let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; }
pwd <- getCurrentDirectory
instName <- case dylibInstallName dflags of
Just n -> return n
Nothing -> do
pwd <- getCurrentDirectory
return $ pwd `combine` output_fn
SysTools.runLink dflags
([ SysTools.Option verb
, SysTools.Option "-dynamiclib"
......@@ -1662,7 +1668,8 @@ linkDynLib dflags o_files dep_packages = do
++ map SysTools.Option (
md_c_flags
++ o_files
++ [ "-undefined", "dynamic_lookup", "-single_module", "-Wl,-macosx_version_min","-Wl,10.5", "-install_name " ++ (pwd </> output_fn) ]
++ [ "-undefined", "dynamic_lookup", "-single_module", "-Wl,-macosx_version_min","-Wl,10.5",
"-Wl,-read_only_relocs,suppress", "-install_name", instName ]
++ extra_ld_inputs
++ lib_path_opts
++ extra_ld_opts
......
......@@ -385,6 +385,7 @@ data DynFlags = DynFlags {
-- paths etc.
objectDir :: Maybe String,
dylibInstallName :: Maybe String,
hiDir :: Maybe String,
stubDir :: Maybe String,
......@@ -630,6 +631,7 @@ defaultDynFlags =
thisPackage = mainPackageId,
objectDir = Nothing,
dylibInstallName = Nothing,
hiDir = Nothing,
stubDir = Nothing,
......@@ -771,7 +773,7 @@ getVerbFlag dflags
| verbosity dflags >= 3 = "-v"
| otherwise = ""
setObjectDir, setHiDir, setStubDir, setOutputDir,
setObjectDir, setHiDir, setStubDir, setOutputDir, setDylibInstallName,
setObjectSuf, setHiSuf, setHcSuf, parseDynLibLoaderMode,
setPgmP, setPgmL, setPgmF, setPgmc, setPgmm, setPgms, setPgma, setPgml, setPgmdll, setPgmwindres,
addOptL, addOptP, addOptF, addOptc, addOptm, addOpta, addOptl, addOptwindres,
......@@ -786,6 +788,7 @@ setStubDir f d = d{ stubDir = Just f, includePaths = f : includePaths d }
-- -stubdir D adds an implicit -I D, so that gcc can find the _stub.h file
-- \#included from the .hc file when compiling with -fvia-C.
setOutputDir f = setObjectDir f . setHiDir f . setStubDir f
setDylibInstallName f d = d{ dylibInstallName = Just f}
setObjectSuf f d = d{ objectSuf = f}
setHiSuf f d = d{ hiSuf = f}
......@@ -1324,6 +1327,7 @@ dynamic_flags = [
Supported
, Flag "dynload" (HasArg (upd . parseDynLibLoaderMode))
Supported
, Flag "dylib-install-name" (HasArg (upd . setDylibInstallName)) Supported
------- Libraries ---------------------------------------------------
, Flag "L" (Prefix addLibraryPath ) Supported
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment