Remove the lld::enableColors function, as it just obscures which
stream it's affecting, and replace with explicit calls to the stream's
enable_colors.
Also, assign the stderrOS and stdoutOS globals first in link function,
just to ensure nothing might use them.
(Either change individually fixes the issue of using the old
stream, but both together seems best.)
Follow-up to b11386f9be.
Differential Revision: https://reviews.llvm.org/D70492
This change is for those who use lld as a library. Context:
https://reviews.llvm.org/D70287
This patch adds a new parmeter to lld::*::link() so that we can pass
an raw_ostream object representing stdout. Previously, lld::*::link()
took only an stderr object.
Justification for making stdoutOS and stderrOS mandatory: I wanted to
make link() functions to take stdout and stderr in that order.
However, if we change the function signature from
bool link(ArrayRef<const char *> args, bool canExitEarly,
raw_ostream &stderrOS = llvm::errs());
to
bool link(ArrayRef<const char *> args, bool canExitEarly,
raw_ostream &stdoutOS = llvm::outs(),
raw_ostream &stderrOS = llvm::errs());
, then the meaning of existing code that passes stderrOS silently
changes (stderrOS would be interpreted as stdoutOS). So, I chose to
make existing code not to compile, so that developers can fix their
code.
Differential Revision: https://reviews.llvm.org/D70292
GNU ld looks for a number of other patterns than just lib<name>.dll.a
and lib<name>.a.
GNU ld does support linking directly against a DLL without using an
import library. If that's the only match for a -l argument, point out
that the user needs to use an import library, instead of leaving the
user with a puzzling message about the -l argument not being found
at all.
Also convert an existing case of fatal() into error().
Differential Revision: https://reviews.llvm.org/D68689
llvm-svn: 374292
Support the equals form of the long --entry=<symbol> option,
add a test for the -e<symbol> form.
Add tests for single dash forms of -exclude-all-symbols and
-export-all-symbols.
Support single-dash forms of -out-implib and -output-def, support
the equals form of --output-def=<file>. (We previously had a test
to explicitly disallow -out-implib, but it turns out that GNU ld
actually does support it just fine, despite also matching the
-o<file> option.)
Disallow the double-dashed --u form, add a test for -u<symbol>.
Differential Revision: https://reviews.llvm.org/D66066
llvm-svn: 368816
With GNU tools, delayload is handled completely differently. (One
creates a specific delayload import library using dlltool and then
links against it instead of the normal import library.)
Instead of requiring using -Xlink=-delayload:lib.dll, we can provide
an lld specific option for this.
Differential Revision: https://reviews.llvm.org/D65728
llvm-svn: 367837
This patch does the same thing as r365595 to other subdirectories,
which completes the naming style change for the entire lld directory.
With this, the naming style conversion is complete for lld.
Differential Revision: https://reviews.llvm.org/D64473
llvm-svn: 365730
Since OPT_UNKNOWN args never have any values and consist only of
spelling (and are never aliased), this doesn't make any difference in
practice, but it's more consistent with Arg's guidance to use
getAsString() for diagnostics, and it matches what clang does.
Also tweak two tests to use an unknown option that contains '=' for
additional coverage while here. (The new tests pass fine with the old
code too though.)
llvm-svn: 365200
This fixes an 8-year-old regression. r105763 made it so that aliases
always refer to the unaliased option – but it missed the "joined" branch
of JoinedOrSeparate flags. (r162231 then made the Args classes
non-virtual, and r169344 moved them from clang to llvm.)
Back then, there was no JoinedOrSeparate flag that was an alias, so it
wasn't observable. Now /U in CLCompatOptions is a JoinedOrSeparate alias
in clang, and warn_slash_u_filename incorrectly used the aliased arg id
(using the unaliased one isn't really a regression since that warning
checks if the undefined macro contains slash or backslash and only then
emits the warning – and no valid use will pass "-Ufoo/bar" or similar).
Also, lld has many JoinedOrSeparate aliases, and due to this bug it had
to explicitly call `getUnaliasedOption()` in a bunch of places, even
though that shouldn't be necessary by design. After this fix in Option,
these calls really don't have an effect any more, so remove them.
No intended behavior change.
(I accidentally fixed this bug while working on PR29106 but then
wondered why the warn_slash_u_filename broke. When I figured it out, I
thought it would make sense to land this in a separate commit.)
Differential Revision: https://reviews.llvm.org/D64156
llvm-svn: 365186
This is implemented by the lld-link option -include:, just like
--require-defined. Contrary to --require-defined, the -u/--undefined
option allows the symbol to remain undefined in the end.
This should fix PR42121.
Differential Revision: https://reviews.llvm.org/D62876
llvm-svn: 362882
Libtool concludes that the linker doesn't support shared libraries,
unless this flag is listed in the output of --help.
Differential Revision: https://reviews.llvm.org/D62053
llvm-svn: 361017
When integrating PDB output in mingw targeting build systems, it
might be a lot of extra work to specify unique file names for
the pdb output. Therefore allow omitting the actual file name
and let it implicitly be the same name as the linker output, with
a pdb extension.
As the current form of the pdb option takes a separate parameter value,
e.g. "-pdb out.pdb", it is impractical to leave out the parameter value.
Therefore, introduce a second syntax for the option, with an equals
sign, like -pdb=out.pdb, where the value easily can be omitted.
The form -pdb= for requesting pdb files with an implicit name should
work fine, even though it looks a bit unconventional in that form.
Differential Revision: https://reviews.llvm.org/D62004
llvm-svn: 361014
Move them to the same section as the newly added ignored options
without a defined name.
Also move options that actually weren't ignored to the right section.
Differential Revision: https://reviews.llvm.org/D57374
llvm-svn: 352529
GCC can use LLD with -fuse-ld=lld for MinGW these days, but by
default these options are passed to the linker (unless -fno-lto
is passed to the GCC driver).
Differential Revision: https://reviews.llvm.org/D57304
llvm-svn: 352459
to reflect the new license.
We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.
Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.
llvm-svn: 351636
This is necessary for handling defaultlib directives embedded in
object files, unless they use an absolute path.
Differential Revision: https://reviews.llvm.org/D53015
llvm-svn: 344123
In this mode, we retain the symbol table, but skip the actual debug
information.
Differential Revision: https://reviews.llvm.org/D48745
llvm-svn: 335947
This allows producing pdb debug info. This is an LLD specific option
since GCC and GNU binutils doesn't support the PDB file format.
Differential Revision: https://reviews.llvm.org/D46796
llvm-svn: 332327
These are required for handling circular dependencies between
static libraries, which is something that lld-link always does without
any extra parameters.
Differential Revision: https://reviews.llvm.org/D43786
llvm-svn: 326172
The COFF linker automatically sets the IMAGE_DLL_CHARACTERISTICS_NO_SEH
when suitable, similarly to link.exe.
Differential Revision: https://reviews.llvm.org/D41275
llvm-svn: 320861
Without this the LLVM_BUILD_LLVM_DYLIB+DLLVM_LINK_LLVM_DYLIB build
break.
Also remove unneeded lldCore from wasm/CMakeLists.txt
Differential Revision: https://reviews.llvm.org/D41194
llvm-svn: 320610
The linker refuses using -dynamicbase:no on these architectures.
Stop passing -dynamicbase (which just reinforces the lld-link
default) for simplicity.
Differential Revision: https://reviews.llvm.org/D41052
llvm-svn: 320518
LLD already writes a build id if debug info is enabled.
Some projects set --pie-executable to avoid GNU ld bugs about stripping
base relocations from an executable when they actually are used.
Since -fixed:no is the default (and we don't support setting the
-fixed option via the MinGW frontend), we don't need to handle this.
--disable-auto-image-base is ignored just like --enable-auto-image-base
(as we ignore from before).
Differential Revision: https://reviews.llvm.org/D40031
llvm-svn: 318285
GNU ld doesn't seem to support --icf at all, but this was suggested
in D39885, and GNU gold seems to support it.
Differential Revision: https://reviews.llvm.org/D40019
llvm-svn: 318283
All of these are disabled by default in GNU ld, but enabled by default
in lld.
Disable dynamicbase by default since it potentially could cause
compatibility issues, but just ignore the others since the lld
default should be fine for most concievable cases.
Differential Revision: https://reviews.llvm.org/D40017
llvm-svn: 318281
In GNU ld, this option is only available on i386, not on x86_64
(where it's enabled by default with no option to disable it either).
Differential Revision: https://reviews.llvm.org/D40015
llvm-svn: 318280
In GNU ld, this option is enabled by default, but can be set
to reduce some warnings.
For lld, ignore the flag (for now); in case linking still succeeds
everything should be fine, if not, it should be clear to the user
what part failed (possibly requiring adjusting the user project
to not rely on this feature), instead of straight out failing due to
an unknown flag.
Differential Revision: https://reviews.llvm.org/D39330
llvm-svn: 316693
Previously, the COFF driver would call exit(0) when called
as a library. Now it takes `ExitEarly` option, and if it
is false, it doesn't exit. So it is now more library-friendly.
Furthermore, link() calls freeArena() before returning, to
clean up resources.
Based on an Andrew Kelley's patch.
Differential Revision: https://reviews.llvm.org/D39202
llvm-svn: 316370