diff options
author | Simon Marlow <marlowsd@gmail.com> | 2016-10-27 12:52:00 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2016-11-03 14:55:07 -0700 |
commit | a977c96537bb7077c6445f02db98636b150e6e14 (patch) | |
tree | c918e4f1dfdf39a4f51ca7cc68355385b186a1fc /compiler/main/SysTools.hs | |
parent | f46bfeb8344e1818f42066c3dd9717f49e8b511b (diff) | |
download | haskell-a977c96537bb7077c6445f02db98636b150e6e14.tar.gz |
Omit unnecessary linker flags
Summary:
This omits -L and -l flags from the linker command line that shouldn't
be necessary because GHC will already add them via the -package-id
flags we pass.
This also reverts part of 90538d86af579595987826cd893828d6f379f35a
that rearranges the linker command line and causes some knock-on
problems (see D2618).
Test Plan: validate (need to validate on Windows too)
Reviewers: Phyx, bgamari, niteria, austin, erikd
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2639
GHC Trac Issues: #12738
Diffstat (limited to 'compiler/main/SysTools.hs')
-rw-r--r-- | compiler/main/SysTools.hs | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index d5fd0c5c29..5fb92c8583 100644 --- a/compiler/main/SysTools.hs +++ b/compiler/main/SysTools.hs @@ -910,26 +910,9 @@ runLink dflags args = do let (p,args0) = pgm_l dflags args1 = map Option (getOpts dflags opt_l) args2 = args0 ++ linkargs ++ args1 ++ args - args3 = argFixup args2 [] - mb_env <- getGccEnv args3 - runSomethingResponseFile dflags ld_filter "Linker" p args3 mb_env + mb_env <- getGccEnv args2 + runSomethingResponseFile dflags ld_filter "Linker" p args2 mb_env where - testLib lib = "-l" `isPrefixOf` lib || ".a" `isSuffixOf` lib - {- GHC is just blindly appending linker arguments from libraries and - the commandline together. This results in very problematic link orders - which will cause incorrect linking. Since we're changing the link - arguments anyway, let's just make sure libraries are last. - This functions moves libraries on the link all the way back - but keeps the order amongst them the same. -} - argFixup [] r = [] ++ r - -- retain any lib in "-o" position. - argFixup (o@(Option "-o"):o'@(FileOption _ _):xs) r = o:o':argFixup xs r - argFixup (o@(Option opt):xs) r = if testLib opt - then argFixup xs (r ++ [o]) - else o:argFixup xs r - argFixup (o@(FileOption _ opt):xs) r = if testLib opt - then argFixup xs (r ++ [o]) - else o:argFixup xs r ld_filter = case (platformOS (targetPlatform dflags)) of OSSolaris2 -> sunos_ld_filter _ -> id |