[commit: ghc] ghc-7.10: clarify --no-as-needed is only needed on ELF (7b8da47)

git at git.haskell.org git at git.haskell.org
Fri Apr 3 05:41:59 UTC 2015


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

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/7b8da47ae8f99f7a452d83f1e09c876792c001af/ghc

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

commit 7b8da47ae8f99f7a452d83f1e09c876792c001af
Author: Peter Trommler <ptrommler at acm.org>
Date:   Fri Apr 3 00:22:59 2015 -0500

    clarify --no-as-needed is only needed on ELF
    
    From the code it was not clear that `--no-as-needed` was not necessary
    on Windows. Add this fact and describe the fix for #10110 in a separate
    note.
    
    See audit for rGHC1b7f59769052fd8193c6acc561216e070d0ca335 raised
    by @thomie.
    
    Reviewed By: thomie
    
    Differential Revision: https://phabricator.haskell.org/D791
    
    GHC Trac Issues: #10110
    
    (cherry picked from commit 13a0d5ac95a80e8b3604e084ae189da405a47270)


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

7b8da47ae8f99f7a452d83f1e09c876792c001af
 compiler/main/SysTools.hs | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
index 26e8cf6..8fa947c 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -715,6 +715,10 @@ We cache the LinkerInfo inside DynFlags, since clients may link
 multiple times. The definition of LinkerInfo is there to avoid a
 circular dependency.
 
+-}
+
+{- Note [ELF needed shared libs]
+
 Some distributions change the link editor's default handling of
 ELF DT_NEEDED tags to include only those shared objects that are
 needed to resolve undefined symbols. For Template Haskell we need
@@ -722,8 +726,10 @@ the last temporary shared library also if it is not needed for the
 currently linked temporary shared library. We specify --no-as-needed
 to override the default. This flag exists in GNU ld and GNU gold.
 
--}
+The flag is only needed on ELF systems. On Windows (PE) and Mac OS X
+(Mach-O) the flag is not needed.
 
+-}
 
 neededLinkArgs :: LinkerInfo -> [Option]
 neededLinkArgs (GnuLD o)     = o
@@ -761,10 +767,13 @@ getLinkerInfo' dflags = do
           -- Set DT_NEEDED for all shared libraries. Trac #10110.
           return (GnuLD $ map Option ["-Wl,--hash-size=31",
                                       "-Wl,--reduce-memory-overheads",
+                                      -- ELF specific flag
+                                      -- see Note [ELF needed shared libs]
                                       "-Wl,--no-as-needed"])
 
         | any ("GNU gold" `isPrefixOf`) stdo =
           -- GNU gold only needs --no-as-needed. Trac #10110.
+          -- ELF specific flag, see Note [ELF needed shared libs]
           return (GnuGold [Option "-Wl,--no-as-needed"])
 
          -- Unknown linker.



More information about the ghc-commits mailing list