Commit Graph

2998 Commits

Author SHA1 Message Date
Martell Malone 6b43b7ad49 [ELF] - Allow the Code Model flag when using LTO
Differential Revision: https://reviews.llvm.org/D29445

llvm-svn: 296542
2017-02-28 23:43:26 +00:00
Eric Fiselier 87c87f4c30 [CMake] Fix pthread handling for out-of-tree builds
LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects
to correctly link the threading library when needed. Unfortunately
`PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed
and therefore can't be used when configuring out-of-tree builds. This causes
such builds to fail since `pthread` isn't being correctly linked.

This patch attempts to fix that problem by renaming and exporting
`LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB`
because It seemed likely to cause collisions with downstream users of
`LLVMConfig.cmake`.

llvm-svn: 294690
2017-02-10 01:59:20 +00:00
Ismail Donmez 82c489f2a6 Fix shared build after r293965 (Core) and r293967 (COFF)
llvm-svn: 293996
2017-02-03 10:13:39 +00:00
Bob Haarman 37c22a3ecb added missing dependency on intrinsics_gen to lib/Core
llvm-svn: 293986
2017-02-03 00:53:57 +00:00
Bob Haarman fbc229dc8f added missing files for r293965
llvm-svn: 293966
2017-02-02 23:53:10 +00:00
Bob Haarman 35989d6be5 add the ability to call InitTargetOptionsFromCodeGenFlags from multiple objects
Summary: llvm/CodeGen/CommandFlags.h a utility function InitTargetOptionsFromCodeGenFlags which is used to set target options from flags based on the command line. The command line flags are stored in globals defined in the same file, and including the file in multiple places causes the globals to be defined multiple times, leading to linker errors. This change adds a single place in lld where these globals are defined and exports only the utility function. This makes it possible to call InitTargetOptionsFromCodeGenFlags from multiple places in lld, which a follow-up change will do.

Reviewers: davide, ruiu

Reviewed By: davide, ruiu

Subscribers: mgorny

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

llvm-svn: 293965
2017-02-02 23:49:16 +00:00
Pavel Labath c9fa114b28 [lld][cmake] Fix LLVM_LINK_LLVM_DYLIB build
Summary:
Lld's build had a couple of issues which prevented a successfull
LLVM_LINK_LLVM_DYLIB compilation.

- add_llvm_library vs llvm_add_library: One adds a library to libLLVM.so, other
  one doesn't. Lld was using the wrong one, causing symbols to be mupltiply
  defined in things linking to libLLVM.
- confusion when to use LINK_LIBS vs LINK_COMPONENTS in llvm_add_library
- not using LLVM_LINK_COMPONENTS for add_lld_tool

With these fixes lld compiles and it's test suite passes both in
LLVM_LINK_LLVM_DYLIB mode and without it.

Reviewers: ruiu, beanz

Subscribers: llvm-commits, mgorny

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

llvm-svn: 291432
2017-01-09 09:57:08 +00:00
Rui Ueyama 3e6490399e Define sys::path::convert_to_slash
This patch moves convertToUnixPathSeparator from LLD to LLVM.

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

llvm-svn: 291414
2017-01-09 01:47:15 +00:00
Rafael Espindola 1d1f692158 Revert r291221.
Should bring back the windows bots.

llvm-svn: 291263
2017-01-06 19:01:49 +00:00
Rui Ueyama b4c63caf76 Rename lld::stringize -> lld::toString.
llvm-svn: 291223
2017-01-06 10:04:35 +00:00
Rui Ueyama dac6169214 Remove lld::convertToUnixPathSeparator.
Now TarWriter takes care of path separator conversion, so we don't
need to handle that in LLD.

llvm-svn: 291221
2017-01-06 09:38:43 +00:00
Rui Ueyama 7f1f912794 Use TarWriter to create tar archives instead of cpio.
This is how we use TarWriter in LLD. Now LLD does not append
a file extension, so you need to pass `--reproduce foo.tar`
instead of `--reproduce foo`.

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

llvm-svn: 291210
2017-01-06 02:33:53 +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
Michal Gorny 906534fe4e Remove unnecessary llvm/Config/config.h includes
Remove the includes of <llvm/Config/config.h> private LLVM header.
The relevant files seem not to use any definitions from that file,
and it is not available when building against installed LLVM.

The use in lib/ReaderWriter/MachO/MachOLinkingContext.cpp originates
from rL218718, and the use in ELF/Strings.cpp from rL274804 (where it
was moved from Symbols.cpp). In both cases, they were added as a part of
demangling support, and they provided HAVE_CXXABI_H.

Since we are now using the LLVM demangler library instead, the code was
removed and the includes and no longer necessary.

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

llvm-svn: 289707
2016-12-14 20:53:57 +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
Rui Ueyama 007f9f3e3d Fix Windows buildbots.
llvm-svn: 288975
2016-12-07 20:31:46 +00:00
Rui Ueyama 63d064e9d1 Make convertToUnixPathSeparator return a new string instead of mutating argument.
llvm-svn: 288972
2016-12-07 20:22:27 +00:00
George Rimar 92c88a4f76 [ELF] - Print absolute file name in errors when possible.
Currently LLD prints basename of source file name in error messages,
for example:
$ mkdir foo
$ echo 'void _start(void) { foobar(); }' > foo/bar.c
$ gcc -g -c foo/bar.c
$ bin/ld.lld -o out bar.o 
bin/ld.lld: error: bar.c:1: undefined symbol 'foobar'
$
This should say:
bin/ld.lld: error: foo/bar.c:1: undefined symbol 'foobar'

This is PR31299

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

llvm-svn: 288966
2016-12-07 19:42:25 +00:00
Davide Italiano c223d1bc6b [ELF] Don't replace path separators on *NIX.
Apparently this is wrong because it's legal to have a filename
on UNIX which contains a backslash.

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

llvm-svn: 287143
2016-11-16 19:35:36 +00:00
George Rimar 117c933304 [ELF] - Fixed comment. NFC.
llvm-svn: 286712
2016-11-12 06:27:42 +00:00
Mehdi Amini 16e25c8d4c Fix wrong formatting in lld introduced in r286561 (NFC)
Pointed out by Davide.

llvm-svn: 286649
2016-11-11 22:28:19 +00:00
Greg Clayton a6ccd19035 Fix code to deal with recent LLVM changes.
https://reviews.llvm.org/D26526

llvm-svn: 286598
2016-11-11 16:23:47 +00:00
George Rimar e893689331 [ELF] - Use backward slashes inside response files
Patch replaces forward slashes with backward inside response.txt

This is https://llvm.org/bugs/show_bug.cgi?id=30951.

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

llvm-svn: 286589
2016-11-11 13:23:13 +00:00
Mehdi Amini c1edf566b9 Prevent at compile time converting from Error::success() to Expected<T>
This would trigger an assertion at runtime otherwise.

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

llvm-svn: 286562
2016-11-11 04:29:25 +00:00
Rui Ueyama 8c6a5aaf15 Create a vector containing all input sections.
Previously, we do this piece of code to iterate over all input sections.

  for (elf::ObjectFile<ELFT> *F : Symtab.getObjectFiles())
    for (InputSectionBase<ELFT> *S : F->getSections())

It turned out that this mechanisms doesn't work well with synthetic
input sections because synthetic input sections don't belong to any
input file.

This patch defines a vector that contains all input sections including
synthetic ones.

llvm-svn: 286051
2016-11-05 22:37:59 +00:00
Eugene Zelenko 22886a2853 Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D26320

llvm-svn: 286030
2016-11-05 01:00:56 +00:00
Eugene Zelenko e568b91510 Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D26293

llvm-svn: 286000
2016-11-04 17:39:46 +00:00
Greg Clayton 9a134fc917 Fix build breakage on buildbots that was due to 285309.
llvm-svn: 285321
2016-10-27 17:43:39 +00:00
Rui Ueyama 80695c1aef Truncate a SVN path part from --version output.
This is in sync with what clang does.

llvm-svn: 285163
2016-10-26 03:52:06 +00:00
Eugene Zelenko 8329bfc63a Fix Clang-tidy readability-redundant-member-init warnings; other minor fixes
Differential revision: https://reviews.llvm.org/D25931

llvm-svn: 285086
2016-10-25 16:57:35 +00:00
Pavel Labath 407fd070b7 Adjust for TimePoint interface change in llvm: D25730. NFC
llvm-svn: 284965
2016-10-24 10:59:14 +00:00
Benjamin Kramer 3ad3f5033d Retire llvm::alignOf in favor of C++11 alignof.
No functionality change intended.

llvm-svn: 284734
2016-10-20 15:30:02 +00:00
Reid Kleckner 89f3090d35 Use noexcept directly now that all compilers support it
llvm-svn: 284671
2016-10-19 23:50:50 +00:00
Rui Ueyama 4ff3b5adc3 Move getVersionString to Core and simplify Version.cpp.
llvm-svn: 284641
2016-10-19 20:53:07 +00:00
Davide Italiano f6c1d2c158 [MachO] Factor out a fair amount of duplicated code. NFCI.
llvm-svn: 281260
2016-09-12 21:07:26 +00:00
Davide Italiano 35065193f1 [MachO] Remove code accidentally cut'n'pasted 3 times.
It wasn't harmful, just goofy. It's weird to see how this has
fallen through the crack without anybody noticing for so long.

llvm-svn: 281148
2016-09-10 20:41:26 +00:00
Rafael Espindola 5b0fb8f4d5 Fix shared library build.
llvm-svn: 280753
2016-09-06 21:06:55 +00:00
Rafael Espindola d1942133e8 Use the demangler in llvm.
llvm-svn: 280733
2016-09-06 19:17:14 +00:00
Duncan P. N. Exon Smith 9f71057d69 ReaderWriter: Use ilist_noalloc_traits for TrieEdge, NFC
Adopt r280128 in lld, specializing ilist_alloc_traits rather than
reinventing the wheel.

llvm-svn: 280566
2016-09-03 01:29:36 +00:00
Duncan P. N. Exon Smith c9e8bc191c ADT: Remove uses of ilist_*sentinel_traits, NFC
llvm-svn: 279458
2016-08-22 18:59:33 +00:00
Davide Italiano 8dd4e70222 [Driver] Remove break after return. NFCI.
llvm-svn: 278834
2016-08-16 18:23:44 +00:00
Duncan P. N. Exon Smith 623c4c1572 MachO: Use ilist_half_embedded_sentinel_traits, NFC
Use ilist_half_embedded_sentinel_traits for the list of
lld::mach_o::normalized::TrieEdge, rather than duplicating the code.

llvm-svn: 278523
2016-08-12 16:25:04 +00:00
Davide Italiano 54eb8ffd55 [Core] Retire yet another unused member function.
The code in lib/ could use a lot of love :(

llvm-svn: 278506
2016-08-12 12:37:23 +00:00
Davide Italiano 0f672ed87a [Core] Simplify a bit. NFCI.
llvm-svn: 278505
2016-08-12 12:34:39 +00:00
Pete Cooper ef5bea9dca Dead strip DESC bits should only be set on object files.
It only makes sense to set on N_NO_DEAD_STRIP on a relocatable object file.  Otherwise the bits aren't useful for anything.  Matches the ld64 behaviour.

llvm-svn: 278419
2016-08-11 21:27:18 +00:00
Pete Cooper 1ed8f1f6e5 Better compress lazy binding info to match ld64.
We should be using one of BIND_OPCODE_SET_DYLIB_SPECIAL_IMM, BIND_OPCODE_SET_DYLIB_ORDINAL_IMM,
and BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB depending on whether ordinals are <= 0, <= 15, > 15.

This matches the behaviour of ld64.

llvm-svn: 278407
2016-08-11 20:59:27 +00:00
Pete Cooper 21f475e1c4 Generate slightly more compressed binding opcodes when entries are the same as last time.
We already had logic for binding opcodes had the same addend as last time.  This adds
the cases where the ordinal, symbol name, type, and segment offsets are the same as
the last emitted ordinal.

This gets us one step closer to emitting rebase opcodes as compressed as ld64 can manage.

llvm-svn: 278405
2016-08-11 20:37:02 +00:00
Pete Cooper 732f1ef9de Arm64 stubs alignment is 2, not 4.
This matches the behaviour of ld64 when looking at the alignment of the stubs section in the final image.

llvm-svn: 278398
2016-08-11 20:18:05 +00:00
Pete Cooper 46cd113c87 Change when we choose to add an LC_LOAD_DYLIB to the final image.
Currently we do this when an atom is used, but we need to do it when a
dylib is referenced on the cmdline as this matches ld64.

This fixes much confusion over which maps are indexed with installName
vs path.  There is likely other confusion so i'll be seeing if i can remove
path() completely in a future commit as path() shouldn't really be needed by anyone.

llvm-svn: 278396
2016-08-11 20:10:14 +00:00
Pete Cooper 932bce6ade Fix off-by-one error in default currentVersion.
A version of 0x1000 is 0.16.0, not 1.0.0 as the comment said.  Fix the
value to match the comment, and also the one test case which had this
wrong.

llvm-svn: 278381
2016-08-11 18:41:14 +00:00