[commit: ghc] master: askCc should be using the linker, not the compiler (3082879)

git at git.haskell.org git at git.haskell.org
Sat Apr 1 03:21:04 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/308287999fcc929891fbcf1221525dd7cbb77860/ghc

>---------------------------------------------------------------

commit 308287999fcc929891fbcf1221525dd7cbb77860
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Fri Mar 31 22:47:47 2017 -0400

    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


>---------------------------------------------------------------

308287999fcc929891fbcf1221525dd7cbb77860
 compiler/ghci/Linker.hs   |  2 +-
 compiler/main/SysTools.hs | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index edd947d..10e789a 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 1b567e9..fd3faf1 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 }



More information about the ghc-commits mailing list