Commit 13a0d5ac authored by Peter Trommler's avatar Peter Trommler 🥁 Committed by Austin Seipp

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
parent 48977c8f
......@@ -717,6 +717,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
......@@ -724,8 +728,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
......@@ -763,10 +769,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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment