diff options
author | Bartosz Nitka <niteria@gmail.com> | 2017-01-21 09:59:55 -0800 |
---|---|---|
committer | Bartosz Nitka <niteria@gmail.com> | 2017-01-21 10:00:12 -0800 |
commit | f9ccad236fa6042a3abbb655129f47fe9dadceaf (patch) | |
tree | ded82c41ef05fe429cbabee10ae730795e5774bc /compiler | |
parent | 15b9a85ef03e2729d487a6f8460be8880c797609 (diff) | |
download | haskell-f9ccad236fa6042a3abbb655129f47fe9dadceaf.tar.gz |
Always use -Xlinker for -rpath
Currently we use `-Wl` which takes a list of
comma-separated options. Unfortunately that
breaks when you use it with `-rpath` and
a path that has commas in them.
Buck, the build system, produces paths with
commas in them.
`-Xlinker` doesn't have this disadvantage
and as far as I can tell is supported by
both `gcc` and `clang`. Anecdotally `nvcc`
supports `-Xlinker`, but not `-Wl`.
Test Plan: ./validate, harbourmaster
Reviewers: nomeata, simonmar, austin, bgamari, hvr
Reviewed By: simonmar, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2971
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ghci/Linker.hs | 13 | ||||
-rw-r--r-- | compiler/main/DriverPipeline.hs | 21 | ||||
-rw-r--r-- | compiler/main/SysTools.hs | 3 |
3 files changed, 29 insertions, 8 deletions
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs index 9252489617..76c1cdafa2 100644 --- a/compiler/ghci/Linker.hs +++ b/compiler/ghci/Linker.hs @@ -880,18 +880,23 @@ dynLoadObjs hsc_env pls objs = do concatMap (\(lp, l) -> [ Option ("-L" ++ lp) - , Option ("-Wl,-rpath") - , Option ("-Wl," ++ lp) + , Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp , Option ("-l" ++ l) ]) (temp_sos pls) ++ concatMap (\lp -> [ Option ("-L" ++ lp) - , Option ("-Wl,-rpath") - , Option ("-Wl," ++ lp) + , Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp ]) minus_big_ls + -- See Note [-Xlinker -rpath vs -Wl,-rpath] ++ map (\l -> Option ("-l" ++ l)) minus_ls, -- Add -l options and -L options from dflags. -- diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index a54e05c1fb..08af37cdda 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1742,6 +1742,20 @@ getHCFilePackages filename = -- read any interface files), so the user must explicitly specify all -- the packages. +{- +Note [-Xlinker -rpath vs -Wl,-rpath] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +-Wl takes a comma-separated list of options which in the case of +-Wl,-rpath -Wl,some,path,with,commas parses the the path with commas +as separate options. +Buck, the build system, produces paths with commas in them. + +-Xlinker doesn't have this disadvantage and as far as I can tell +it is supported by both gcc and clang. Anecdotally nvcc supports +-Xlinker, but not -Wl. +-} + linkBinary :: DynFlags -> [FilePath] -> [InstalledUnitId] -> IO () linkBinary = linkBinary' False @@ -1770,8 +1784,9 @@ linkBinary' staticLink dflags o_files dep_packages = do then "$ORIGIN" </> (l `makeRelativeTo` full_output_fn) else l + -- See Note [-Xlinker -rpath vs -Wl,-rpath] rpath = if gopt Opt_RPath dflags - then ["-Wl,-rpath", "-Wl," ++ libpath] + then ["-Xlinker", "-rpath", "-Xlinker", libpath] else [] -- Solaris 11's linker does not support -rpath-link option. It silently -- ignores it and then complains about next option which is -l<some @@ -1781,7 +1796,7 @@ linkBinary' staticLink dflags o_files dep_packages = do -- elf_begin: I/O error: region read: Is a directory rpathlink = if (platformOS platform) == OSSolaris2 then [] - else ["-Wl,-rpath-link", "-Wl," ++ l] + else ["-Xlinker", "-rpath-link", "-Xlinker", l] in ["-L" ++ l] ++ rpathlink ++ rpath | osMachOTarget (platformOS platform) && dynLibLoader dflags == SystemDependent && @@ -1791,7 +1806,7 @@ linkBinary' staticLink dflags o_files dep_packages = do then "@loader_path" </> (l `makeRelativeTo` full_output_fn) else l - in ["-L" ++ l] ++ ["-Wl,-rpath", "-Wl," ++ libpath] + in ["-L" ++ l] ++ ["-Xlinker", "-rpath", "-Xlinker", libpath] | otherwise = ["-L" ++ l] let dead_strip = if osSubsectionsViaSymbols (platformOS platform) diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index ea3c461327..5bd9fd1f47 100644 --- a/compiler/main/SysTools.hs +++ b/compiler/main/SysTools.hs @@ -1588,7 +1588,8 @@ linkDynLib dflags0 o_files dep_packages osMachOTarget (platformOS (targetPlatform dflags)) ) && dynLibLoader dflags == SystemDependent && WayDyn `elem` ways dflags - = ["-L" ++ l, "-Wl,-rpath", "-Wl," ++ l] + = ["-L" ++ l, "-Xlinker", "-rpath", "-Xlinker", l] + -- See Note [-Xlinker -rpath vs -Wl,-rpath] | otherwise = ["-L" ++ l] let lib_paths = libraryPaths dflags |