summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2017-03-31 22:47:47 -0400
committerBen Gamari <ben@smart-cactus.org>2017-03-31 22:47:49 -0400
commit308287999fcc929891fbcf1221525dd7cbb77860 (patch)
tree3a381468905d165d747204e8f563751b63e8e888
parent546c2a17ae3b21448f7fd467cc47807ae977e51f (diff)
downloadhaskell-308287999fcc929891fbcf1221525dd7cbb77860.tar.gz
askCc should be using the linker, not the compiler
When GHCi tries to find a shared lib, it calls "gcc --print-file-name" to ask gcc where to find it. But since we're looking for libraries, we're really using the linker here, not the C compiler, so we should be respecting the values of -pgml and -optl rather than -pgmc and -optc. Test Plan: validate Reviewers: bgamari, niteria, austin, hvr, erikd Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3393
-rw-r--r--compiler/ghci/Linker.hs2
-rw-r--r--compiler/main/SysTools.hs13
2 files changed, 8 insertions, 7 deletions
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index edd947d94f..10e789acc3 100644
--- a/compiler/ghci/Linker.hs
+++ b/compiler/ghci/Linker.hs
@@ -1422,7 +1422,7 @@ searchForLibUsingGcc :: DynFlags -> String -> [FilePath] -> IO (Maybe FilePath)
searchForLibUsingGcc dflags so dirs = do
-- GCC does not seem to extend the library search path (using -L) when using
-- --print-file-name. So instead pass it a new base location.
- str <- askCc dflags (map (FileOption "-B") dirs
+ str <- askLd dflags (map (FileOption "-B") dirs
++ [Option "--print-file-name", Option so])
let file = case lines str of
[] -> ""
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
index 1b567e966a..fd3faf1851 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -31,7 +31,7 @@ module SysTools (
linkDynLib,
- askCc,
+ askLd,
touch, -- String -> String -> IO ()
copy,
@@ -480,11 +480,12 @@ runCc dflags args = do
isContainedIn :: String -> String -> Bool
xs `isContainedIn` ys = any (xs `isPrefixOf`) (tails ys)
-askCc :: DynFlags -> [Option] -> IO String
-askCc dflags args = do
- let (p,args0) = pgm_c dflags
- args1 = map Option (getOpts dflags opt_c)
- args2 = args0 ++ args1 ++ args
+-- | Run the linker with some arguments and return the output
+askLd :: DynFlags -> [Option] -> IO String
+askLd dflags args = do
+ let (p,args0) = pgm_l dflags
+ args1 = map Option (getOpts dflags opt_l)
+ args2 = args0 ++ args1 ++ args
mb_env <- getGccEnv args2
runSomethingWith dflags "gcc" p args2 $ \real_args ->
readCreateProcessWithExitCode' (proc p real_args){ env = mb_env }