Commit Graph

103 Commits

Author SHA1 Message Date
Fangrui Song c60f85d073 [ELF] Use search paths for --version-script=
Summary: This behavior matches ld.bfd -Ld --version-script=t.script a.o

Reviewers: ruiu, espindola

Subscribers: emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D49820

llvm-svn: 337969
2018-07-25 21:53:18 +00:00
Rui Ueyama 0dd56dcdd4 Handle --plugin-opt= options as alias options.
Previously, we had a loop to iterate over options starting with
`--plugin-opt=` and parse them by hand. But we can make OptTable
do that job for us.

Differential Revision: https://reviews.llvm.org/D47167

llvm-svn: 332935
2018-05-22 02:53:11 +00:00
Nico Weber cac2b3349e lld-link: Add --color-diagnostics(={always,never,auto})?, --no-color-diagnostics flags.
This is most useful when using lld-link on a non-Win host (but it might become
useful on Windows too if lld also grows a fansi-escape-codes flag).

Also make the help for --color-diagnostic mention the valid values in ELF and
wasm, and print the flag name with two dashes in diags, since the one-dash form
is seen as a list of many one-letter flags in some contexts.

https://reviews.llvm.org/D46693

llvm-svn: 332012
2018-05-10 18:19:02 +00:00
Rafael Espindola 16a3716db4 Simplify libtool compatibility hack.
I tested that if I remove "elf" from the message, building a program
that uses libtool prints

checking whether to build shared libraries... no

but with this patch it still prints

checking whether to build shared libraries... yes

llvm-svn: 324428
2018-02-07 00:13:01 +00:00
Rafael Espindola 64626b344b Store just argv[0] in Config.
Having the full argv there seems in conflict with the desire to parse
all command line options in the Driver.

llvm-svn: 324418
2018-02-06 22:37:05 +00:00
Rafael Espindola eed9725451 Hide the --full-shutdown option.
llvm-svn: 324365
2018-02-06 18:12:41 +00:00
Rui Ueyama 6074e6b094 Remove redundant local variables.
llvm-svn: 320436
2017-12-11 23:19:11 +00:00
Sam Clegg 7e7566323d toString function take a const refs where possible
Differential Revision: https://reviews.llvm.org/D40824

llvm-svn: 319787
2017-12-05 16:50:46 +00:00
Rui Ueyama 2017d52b54 Move Memory.{h,cpp} to Common.
Differential Revision: https://reviews.llvm.org/D40571

llvm-svn: 319221
2017-11-28 20:39:17 +00:00
Alexander Richardson d642494828 [ELF] Fix rewriting of --sysroot in reproducer tars
Summary:
I noticed that the reproducers files I was getting from building CheriBSD
didn't work because the --sysroot option was not being rewritten. I've
updated the test to also verify that the rewritten path matches uses a
FileCheck capature instead of a {{.+}} regex

Reviewers: ruiu

Reviewed By: ruiu

Subscribers: llvm-commits, emaste

Differential Revision: https://reviews.llvm.org/D40125

llvm-svn: 318656
2017-11-20 15:49:48 +00:00
Alexander Richardson 1de78471f5 [ELF] Fall back to search dirs for linker scripts specified with -T
Summary:
This matches the behaviour of ld.bfd:
https://sourceware.org/binutils/docs/ld/Options.html#Options

If scriptfile does not exist in the current directory, ld looks for it in
the directories specified by any preceding '-L' options. Multiple '-T'
options accumulate.

Reviewers: ruiu, grimar

Reviewed By: ruiu, grimar

Subscribers: emaste, llvm-commits

Differential Revision: https://reviews.llvm.org/D40129

llvm-svn: 318655
2017-11-20 15:43:20 +00:00
Bob Haarman b8a59c8aa5 [lld] unified COFF and ELF error handling on new Common/ErrorHandler
Summary:
The COFF linker and the ELF linker have long had similar but separate
Error.h and Error.cpp files to implement error handling. This change
introduces new error handling code in Common/ErrorHandler.h, changes the
COFF and ELF linkers to use it, and removes the old, separate
implementations.

Reviewers: ruiu

Reviewed By: ruiu

Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits

Differential Revision: https://reviews.llvm.org/D39259

llvm-svn: 316624
2017-10-25 22:28:38 +00:00
Rui Ueyama 3f851704c1 Move new lld's code to Common subdirectory.
New lld's files are spread under lib subdirectory, and it isn't easy
to find which files are actually maintained. This patch moves maintained
files to Common subdirectory.

Differential Revision: https://reviews.llvm.org/D37645

llvm-svn: 314719
2017-10-02 21:00:41 +00:00
James Henderson 1304e8dd6e [ELF] Rewrite --symbol-ordering-file path in reproducer
The --symbol-ordering-file path was not being rewritten in the response file when
using --reproduce. This patch adds this to the list of switches that are rewritten,
so that the path is somewhere within the reproducer directory tree.

Reviewers: ruiu

Differential Revision: https://reviews.llvm.org/D37480

llvm-svn: 312626
2017-09-06 10:10:49 +00:00
George Rimar 6977ec6899 [ELF] - Print options aliases in --help
This is PR30422,
previously LLD did not render all option aliases in --help.
With this patch it will.

Differential revision: https://reviews.llvm.org/D35477

llvm-svn: 309089
2017-07-26 09:21:10 +00:00
George Rimar 4f37d57547 [ELF] - Introduce multiclass Eq helper for Options.td
Eq helper allows to define `XXX` and `XXX=` options forms easily.
Patch adds testcases for few aliases.

Differential revision: https://reviews.llvm.org/D35619

llvm-svn: 308752
2017-07-21 16:27:26 +00:00
Rui Ueyama 875ae82b0b Add the --chroot option for --reproduce.
Summary:
If the linker is invoked with `--chroot /foo` and `/bar/baz.o`, it
tries to read the file from `/foo/bar/baz.o`. This feature is useful
when you are dealing with files created by the --reproduce option.

Reviewers: grimar

Subscribers: llvm-commits, emaste

Differential Revision: https://reviews.llvm.org/D35517

llvm-svn: 308646
2017-07-20 18:17:55 +00:00
Rui Ueyama 7eaf3d4b31 Fix one more occurrence of getOption().getID().
llvm-svn: 308523
2017-07-19 21:06:46 +00:00
Sam Clegg 7859216b28 Fix argument numbersing in OPTION macro
The option numbers in the macro were off by one which
leads to some confusion.  There are actually 12 arguments
to this macro.

Differential Revision: https://reviews.llvm.org/D34413

llvm-svn: 305823
2017-06-20 19:17:58 +00:00
Yuka Takahashi ba5d4af490 [GSoC] Flag value completion for clang
This is patch for GSoC project, bash-completion for clang.

To use this on bash, please run `source clang/utils/bash-autocomplete.sh`.
bash-autocomplete.sh is code for bash-completion.

In this patch, Options.td was mainly changed in order to add value class
in Options.inc.

llvm-svn: 305805
2017-06-20 16:31:31 +00:00
Rui Ueyama 70c8efd03c Sort.
llvm-svn: 298829
2017-03-27 03:42:55 +00:00
Rui Ueyama 22f0d804f5 Use raw_fd_ostream::has_colors instead of StandardErrHasColors().
I just didn't know that raw_fd_ostream has has_colors() function.

llvm-svn: 298749
2017-03-24 23:21:34 +00:00
Simon Atanasyan 6ab0d5b0d1 [ELF] Print two more MIPS targets "supported" by LLD
These targets are related to MIPS N32 ABI.

llvm-svn: 298591
2017-03-23 12:17:32 +00:00
Rui Ueyama 688299bd39 Refine comment.
llvm-svn: 298571
2017-03-23 01:19:10 +00:00
Rui Ueyama b57412e95d Print out "suppoted targets".
This is to improve compatibility with GNU Libtool that expect
/supported targets:.* elf/ in a message for the -help option.

Differential Revision: https://reviews.llvm.org/D31208

llvm-svn: 298568
2017-03-23 01:00:22 +00:00
Rafael Espindola bba87168f9 Strip file path from the -o option while creating reproduce.txt.
This is a fix for Bugzilla 28579.

The problem is that in --reproduce links the file path in -o option is
copied verbatim. When "lld @response.txt" link is run against the
extracted test case, if -o contains anything other that a plain file
name, the link will likely fail because the target directory in -o may
not exists. Stripping the directory path will create the output file
in the top level test directory.

Patch by Dmitry Mikulin!

llvm-svn: 293792
2017-02-01 18:04:45 +00:00
Rui Ueyama 80166d4afe Remove unused #include.
llvm-svn: 293144
2017-01-26 03:02:30 +00:00
Rui Ueyama b4c63caf76 Rename lld::stringize -> lld::toString.
llvm-svn: 291223
2017-01-06 10:04:35 +00:00
Rui Ueyama 8781c425b3 Make -color-diagnostics an alias to -color-diagnostics=always.
Previously, that was an alias to -color-diagnostics=auto. However,
Clang's -fcolor-diagnostics is an alias to -fcolor-diagnostics=always,
so that was confusing. This patch fixes that issue.

llvm-svn: 290332
2016-12-22 08:20:28 +00:00
Rui Ueyama 398f55f6f6 Set Config->ColorDiagnostics early so that all error messages are colored.
Previously, some errors that were checked before we set to
Config->ColorDiagnostics weren't colored. This patch moves the code
to set the variable so that such error messages are colored just like
other error messages.

llvm-svn: 290157
2016-12-20 02:17:24 +00:00
Rui Ueyama 9381eb1045 Remove lld/Support/Memory.h.
I thought for a while about how to remove it, but it looks like we
can just copy the file for now. Of course I'm not happy about that,
but it's just less than 50 lines of code, and we already have
duplicate code in Error.h and some other places. I want to solve
them all at once later.

Differential Revision: https://reviews.llvm.org/D27819

llvm-svn: 290062
2016-12-18 14:06:06 +00:00
Rui Ueyama 520d9169e6 Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.
llvm-svn: 289084
2016-12-08 18:31:13 +00:00
Rafael Espindola d0ebd84c42 Change the implementation of --dynamic-list to use linker script parsing.
The feature is documented as
-----------------------------
The format of the dynamic list is the same as the version node
without scope and node name.  See *note VERSION:: for more
information.
--------------------------------

And indeed qt uses a dynamic list with an 'extern "C++"' in it. With
this patch we support that

The change to gc-sections-shared makes us match bfd. Just because we
kept bar doesn't mean it has to be in the dynamic symbol table.

The changes to invalid-dynamic-list.test and reproduce.s are because
of the new parser.

The changes to version-script.s are the only case where we change
behavior with regards to bfd, but I would like to see a mix of
--version-script and --dynamic-list used in the wild before
complicating the code.

llvm-svn: 289082
2016-12-08 17:54:26 +00:00
Eugene Leviant 03ff016666 [ELF] Better error reporting for linker scripts
Differential revision: https://reviews.llvm.org/D26795

llvm-svn: 287547
2016-11-21 15:49:56 +00:00
Rui Ueyama 60c4e36c7e Simplify. NFC.
llvm-svn: 287510
2016-11-20 23:15:56 +00:00
Rui Ueyama f7dfb2e250 Remove a file that is too short to be an independent file.
We have a .cpp and a .h for parseDynamicList(). This patch
moves the function to DriverUtil.cpp.

llvm-svn: 287468
2016-11-19 23:26:41 +00:00
Rui Ueyama 1cb63183af Restore a comment that was accidentally changed.
llvm-svn: 287457
2016-11-19 19:26:52 +00:00
Rui Ueyama 061f9286df Use Optional<std::string> instead of "" to represent a failure.
llvm-svn: 287456
2016-11-19 19:23:58 +00:00
Rui Ueyama ec75220fe9 Make buildSysrootedPath file-scoped.
This patch also changes its return type to simplify callers.

llvm-svn: 287455
2016-11-19 19:23:56 +00:00
Rui Ueyama 844c1c908c Simplify "missing argument" error message.
We do not have an option taking more than one arguments,
so we can just say "missing argument" instead of "missing argument(s)".

llvm-svn: 287454
2016-11-19 18:49:38 +00:00
George Rimar d8b27769c8 [ELF] - format. NFC.
llvm-svn: 286805
2016-11-14 10:14:18 +00:00
Rui Ueyama 55518e7dd8 Consolidate BumpPtrAllocators.
Previously, we have a lot of BumpPtrAllocators, but all these
allocators virtually have the same lifetime because they are
not freed until the linker finishes its job. This patch aggregates
them into a single allocator.

Differential revision: https://reviews.llvm.org/D26042

llvm-svn: 285452
2016-10-28 20:57:25 +00:00
Rui Ueyama 4ff3b5adc3 Move getVersionString to Core and simplify Version.cpp.
llvm-svn: 284641
2016-10-19 20:53:07 +00:00
Peter Collingbourne feee2103c6 COFF: Implement /linkrepro flag.
This flag is implemented similarly to --reproduce in the ELF linker.

This patch implements /linkrepro by moving the cpio writer and associated
utility functions to lldCore, and using that implementation in both linkers.

One COFF-specific detail is that we store the object file from which the
resource files were created in our reproducer, rather than the resource
files themselves. This allows the reproducer to be used on non-Windows
systems for example.

Differential Revision: https://reviews.llvm.org/D22418

llvm-svn: 276719
2016-07-26 02:00:42 +00:00
Rui Ueyama 3ec5c84606 Attempt to unbreak Windows bot.
llvm-svn: 275695
2016-07-16 19:16:15 +00:00
Rui Ueyama 818bb2f8dc Remove redundant namespace specifiers.
llvm-svn: 275694
2016-07-16 18:55:47 +00:00
Rui Ueyama 0f282a593f Do not call warning() from ELFOptTable::parse().
warning() depends on Config->FatalWarnings, so we don't want to call
that function before we initialize that member.

llvm-svn: 274723
2016-07-07 01:58:04 +00:00
Rui Ueyama a027d33949 Fix indentation.
llvm-svn: 274719
2016-07-07 01:21:14 +00:00
Davide Italiano f296a7eeae [ELF] Introduce a flag to parse response files according to windows rules.
Differential Revision:  http://reviews.llvm/org/D22015

llvm-svn: 274684
2016-07-06 21:24:34 +00:00
Rafael Espindola 1f6929bff6 Use / instead of \ on windows created cpio files
Otherwise when extracting these files on a unix system one
ends up with files named like "repro\bar\foo.o".

llvm-svn: 274622
2016-07-06 12:09:51 +00:00