[commit: ghc] ghc-8.0: Omit unnecessary linker flags (5c91d07)

git at git.haskell.org git at git.haskell.org
Mon Nov 7 19:42:14 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/5c91d076c8017a89ceb43811506b9427ab85ad7e/ghc

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

commit 5c91d076c8017a89ceb43811506b9427ab85ad7e
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Oct 27 12:52:00 2016 +0100

    Omit unnecessary linker flags
    
    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
    
    (cherry picked from commit a977c96537bb7077c6445f02db98636b150e6e14)


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

5c91d076c8017a89ceb43811506b9427ab85ad7e
 compiler/main/SysTools.hs | 19 ++-----------------
 rules/distdir-opts.mk     |  5 -----
 utils/ghc-cabal/Main.hs   |  3 ---
 3 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
index 87fa75e..236bcfd 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -942,24 +942,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
-    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
diff --git a/rules/distdir-opts.mk b/rules/distdir-opts.mk
index e411559..51e111a 100644
--- a/rules/distdir-opts.mk
+++ b/rules/distdir-opts.mk
@@ -44,16 +44,11 @@ $1_$2_DIST_CC_OPTS = \
  $$($1_$2_DEP_CC_OPTS) \
  $$(SRC_CC_WARNING_OPTS)
 
-ifneq ($$(strip $$($1_$2_DEP_LIB_DIRS_SINGLE_QUOTED)),)
-$1_$2_DIST_LD_LIB_DIRS := $$(subst $$(space)',$$(space)-L',$$(space)$$($1_$2_DEP_LIB_DIRS_SINGLE_QUOTED))
-endif
-
 $1_$2_DIST_LD_OPTS = \
  $$(SRC_LD_OPTS) \
  $$($1_LD_OPTS) \
  $$($1_$2_LD_OPTS) \
  $$($1_$2_DIST_LD_LIB_DIRS) \
- $$(foreach opt,$$($1_$2_DEP_EXTRA_LIBS),-l$$(opt)) \
  $$($1_$2_DEP_LD_OPTS)
 
 # c.f. Cabal's Distribution.Simple.PreProcess.ppHsc2hs
diff --git a/utils/ghc-cabal/Main.hs b/utils/ghc-cabal/Main.hs
index 1937392..0ec2a2a 100644
--- a/utils/ghc-cabal/Main.hs
+++ b/utils/ghc-cabal/Main.hs
@@ -402,7 +402,6 @@ generate directory distdir dll0Modules config_args
           mkLibraryRelDir l       = "libraries/" ++ l ++ "/dist-install/build"
           libraryRelDirs = map mkLibraryRelDir transitiveDepNames
       wrappedIncludeDirs <- wrap $ forDeps Installed.includeDirs
-      wrappedLibraryDirs <- wrap libraryDirs
 
       let variablePrefix = directory ++ '_':distdir
           mods      = map display modules
@@ -442,11 +441,9 @@ generate directory distdir dll0Modules config_args
                 variablePrefix ++ "_LD_OPTS = "                        ++ unwords (ldOptions bi),
                 variablePrefix ++ "_DEP_INCLUDE_DIRS_SINGLE_QUOTED = " ++ unwords wrappedIncludeDirs,
                 variablePrefix ++ "_DEP_CC_OPTS = "                    ++ unwords (forDeps Installed.ccOptions),
-                variablePrefix ++ "_DEP_LIB_DIRS_SINGLE_QUOTED = "     ++ unwords wrappedLibraryDirs,
                 variablePrefix ++ "_DEP_LIB_DIRS_SEARCHPATH = "        ++ mkSearchPath libraryDirs,
                 variablePrefix ++ "_DEP_LIB_REL_DIRS = "               ++ unwords libraryRelDirs,
                 variablePrefix ++ "_DEP_LIB_REL_DIRS_SEARCHPATH = "    ++ mkSearchPath libraryRelDirs,
-                variablePrefix ++ "_DEP_EXTRA_LIBS = "                 ++ unwords (forDeps Installed.extraLibraries),
                 variablePrefix ++ "_DEP_LD_OPTS = "                    ++ unwords (forDeps Installed.ldOptions),
                 variablePrefix ++ "_BUILD_GHCI_LIB = "                 ++ boolToYesNo (withGHCiLib lbi),
                 "",



More information about the ghc-commits mailing list