diff options
Diffstat (limited to 'compiler/main')
-rw-r--r-- | compiler/main/DriverPipeline.hs | 16 | ||||
-rw-r--r-- | compiler/main/SysTools.lhs | 7 |
2 files changed, 12 insertions, 11 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 3d34bdbcac..b5052f2d64 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1785,6 +1785,15 @@ linkBinary' staticLink dflags o_files dep_packages = do then [] else ["-Wl,-rpath-link", "-Wl," ++ l] in ["-L" ++ l] ++ rpathlink ++ rpath + | osMachOTarget (platformOS platform) && + dynLibLoader dflags == SystemDependent && + not (gopt Opt_Static dflags) && + gopt Opt_RPath dflags + = let libpath = if gopt Opt_RelativeDynlibPaths dflags + then "@loader_path" </> + (l `makeRelativeTo` full_output_fn) + else l + in ["-L" ++ l] ++ ["-Wl,-rpath", "-Wl," ++ libpath] | otherwise = ["-L" ++ l] let lib_paths = libraryPaths dflags @@ -1920,13 +1929,6 @@ linkBinary' staticLink dflags o_files dep_packages = do then ["-Wl,-read_only_relocs,suppress"] else []) - ++ (if platformOS platform == OSDarwin && - not staticLink && - not (gopt Opt_Static dflags) && - gopt Opt_RPath dflags - then ["-Wl,-rpath","-Wl," ++ topDir dflags] - else []) - ++ o_files ++ lib_path_opts) ++ extra_ld_inputs diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index 2150c6d594..ad059d7fe6 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -1293,7 +1293,8 @@ linkDynLib dflags0 o_files dep_packages let pkg_lib_paths = collectLibraryPaths pkgs let pkg_lib_path_opts = concatMap get_pkg_lib_path_opts pkg_lib_paths get_pkg_lib_path_opts l - | osElfTarget (platformOS (targetPlatform dflags)) && + | ( osElfTarget (platformOS (targetPlatform dflags)) || + osMachOTarget (platformOS (targetPlatform dflags)) ) && dynLibLoader dflags == SystemDependent && not (gopt Opt_Static dflags) = ["-L" ++ l, "-Wl,-rpath", "-Wl," ++ l] @@ -1390,9 +1391,7 @@ linkDynLib dflags0 o_files dep_packages instName <- case dylibInstallName dflags of Just n -> return n - Nothing -> do - pwd <- getCurrentDirectory - return $ pwd `combine` output_fn + Nothing -> return $ "@rpath" `combine` (takeFileName output_fn) runLink dflags ( map Option verbFlags ++ [ Option "-dynamiclib" |