Commit Graph

47 Commits

Author SHA1 Message Date
Michal Gorny a028b33c7f [test] Fix zlib cond when building stand-alone, clean up
Fix the test zlib conditional to use LLVM_ENABLE_ZLIB value when
building stand-alone. The HAVE_LIBZ is not available when performing
a stand-alone build. Since the zlib support is a feature of
the underlying LLVM library, it exports the actual status as the final
value of LLVM_ENABLE_ZLIB in LLVMConfig.

While at it, canonicalize the boolean value into 0/1 and remove unused
CMake definitions (most likely copied from clang).

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

llvm-svn: 294508
2017-02-08 20:08:29 +00:00
Michal Gorny 7d0f0e3eb8 [test] Use LLD-specific binary&library dirs when building stand-alone
Use both LLD- and LLVM-specific binary&library directories when LLD is
being built stand-alone. This ensures that the freshly built tools and
libraries are found and used correctly.

Without this patch, the test suite uses LLVM_TOOLS_DIR and LLVM_LIBS_DIR
to locate lld, and set PATH and LD_LIBRARY_PATH. When doing
a stand-alone builds, these variables represent the installed LLVM.
As a result, tests either fail due to missing lld executables/libraries
or use an earlier installed LLD version rather than the one being built.

To solve this, an additional LLD_TOOLS_DIR and LLD_LIBS_DIR variables
are added that are populated using LLVM_*_OUTPUT_INTDIR. Those variables
are populated with directories used to output built executables
and libraries. In stand-alone builds, they represent the directories
used by LLD. In integrated builds, they have the same values as
LLVM_*_DIR and therefore using them does not harm.

The new variables are prepended to PATH and LD_LIBRARY_PATH to ensure
that freshly built binaries are preferred over potentially earlier
installed ones. Furthermore, the resulting PATH is used to locate tools
for substitutions since the search includes both tools built as part of
LLD and of LLVM.

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

llvm-svn: 294507
2017-02-08 20:08:25 +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
Peter Collingbourne c4e9482164 COFF: We no longer require lib.exe to test DLL exports.
llvm-svn: 289745
2016-12-15 00:11:17 +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
Rui Ueyama 3da3f06dd3 Include version string into ".comment" section.
Summary:
This patch adds a ".comment" section to an output. The comment
section contains the linker's version string. You can now
find out whether a binary is created by LLD or not using objdump
command like this.

  $ objdump -s -j .comment foo

  foo:     file format elf64-x86-64

  Contents of section .comment:
   0000 00474343 3a202855 62756e74 7520342e  .GCC: (Ubuntu 4.
   0010 382e342d 32756275 6e747531 7e31342e  8.4-2ubuntu1~14.
   ...
   00c0 766d2f74 72756e6b 20323835 38343629  vm/trunk 285846)
   00d0 004c696e 6b65723a 204c4c44 20342e30  .Linker: LLD 4.0
   00e0 2e302028 7472756e 6b203238 36343036  .0 (trunk 286406
   00f0 2900                                 ).

Compilers emits .comment section as well, so the output contains
both compiler and linker information.

Alternative considered:

I first tried to add a SHT_NOTE section because GNU gold does that.
A NOTE section starts with a header which contains content type.
It turned out that ld.gold sets type NT_GNU_GOLD_VERSION to their
NOTE section. So the NOTE type is only for GNU gold (surprise!)

Next, I tried to create ".linker-version" section. However, it seems
that reusing the existing ".comment" section is better because 1)
other tools already know about .comment section and is able to strip
it and 2) the result contans not only linker info but also compiler
info.

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

llvm-svn: 286496
2016-11-10 20:20:37 +00:00
Rafael Espindola cb09daab0a Call _exit.
As the state of lld gets more complicated, shutting down gets more
expensive.

In a normal lld run we can just call _exit immediately after renaming
the temporary output file. We still want the ability to run a full
shutdown since that is useful for detecting memory leaks.

This patch adds a --full-shutdown flag and changes lit to use it.

llvm-svn: 285224
2016-10-26 18:59:00 +00:00
Pete Cooper cb7d83c048 Add obj2yaml to the list of tool_patterns in lit. NFC
llvm-svn: 278412
2016-08-11 21:03:56 +00:00
Rui Ueyama 2dc5645b94 Check for availability of `cpio` command.
cpio may not be available on Windows, so it is better to check
for availability before running the command in a test.

llvm-svn: 278249
2016-08-10 17:42:26 +00:00
Rafael Espindola 069b1c1b37 Use just built llvm-as in tests.
llvm-svn: 276313
2016-07-21 18:08:36 +00:00
Rafael Espindola 4225342e95 This now works on unix too.
With this there are no unsupported tests on linux in test/ELF :-)

llvm-svn: 274752
2016-07-07 13:52:04 +00:00
Rui Ueyama 287956f72b Correctly define "zlib" feature.
We have "REQUIRES: zlib" in our test, but zlib was not defined,
so the test did not run on any platform.

llvm-svn: 274730
2016-07-07 03:55:57 +00:00
Rui Ueyama ac75a27809 Add a test for --reproduce on Windows.
It is insanely hard to write a test that works both on Windows and Unix.
I tried to workaround it with cpio's minor options, but the behaviors of
the options were myterious. It just doesn't worth to spend time on it.
And probably minor options could break buildbots that doesn't have the
GNU version of cpio command.

In this patch, I simply added a separate test file that runs only on
Windows.

llvm-svn: 268596
2016-05-05 02:18:04 +00:00
Reid Kleckner 750e76d245 Fix the detection of the shell feature and disable some tests when its not present
llvm-svn: 264912
2016-03-30 20:15:50 +00:00
NAKAMURA Takumi 127295492d check-lld: Introduce %python.
llvm-svn: 260207
2016-02-09 07:30:18 +00:00
NAKAMURA Takumi c96ae0c8a8 Introduce the feature 'demangler' in check-lld. Mark lld/test/old-elf/X86_64/demangle.test as REQUIRES:demangler.
llvm-svn: 260206
2016-02-09 07:30:11 +00:00
Tom Stellard 68a55e6c34 [ELF] Fix REQUIRES line in amdgpu tests
'REQUIRES' needs to be in all caps.

Also update lit.cfg so these tests get run when the AMDGPU target is
enabled.

llvm-svn: 257029
2016-01-07 05:02:38 +00:00
Lang Hames fc3438cd3f [lld] Watch out for tool names inside paths when substituting tool-paths in lit.
If we don't filter these out we can end up, generating bogus paths, for example:
/home/user/lld/build/bin -> /home/user/home/user/lld/build/bin/lld/build/bin.

llvm-svn: 255378
2015-12-11 22:09:03 +00:00
Pete Cooper 80c9b9468f Make commands printed by llvm-lit include the build path in lit.cfg.
When llvm-lit prints a failure, you'll see something like 'lld *command*' However, you can't then take this, paste it in to a terminal and run it, because it's not got the absolute path of lld.

llvm and clang's lit.cfg files contain lists of commands to look for which are substituted by their full paths. So now you'd see something like '*build dir*/bin/lld *command*'.

This patch adds the same capability to lld's lit.cfg

Reviewed by Rafael Espíndola

llvm-svn: 255283
2015-12-10 19:17:35 +00:00
Rafael Espindola 83af95d927 Enable the aarch64 tests.
llvm-svn: 248707
2015-09-28 12:22:25 +00:00
Rafael Espindola 1c2f64d1a6 Add a big endian testcase.
llvm-svn: 244173
2015-08-05 23:40:20 +00:00
Rafael Espindola ccd3adc60b lit fixes for lld.
It was not using LLVM_LIT_TOOLS_DIR and at least on my VM never finding lib.exe.

With this all the COFF tests show up as supported and pass.

llvm-svn: 244107
2015-08-05 19:55:17 +00:00
Peter Collingbourne 60c1616613 COFF: Initial implementation of link-time optimization.
This implementation is known to work in very simple cases (see new test case).

Differential Revision: http://reviews.llvm.org/D10115

llvm-svn: 238777
2015-06-01 20:10:10 +00:00
Reid Kleckner 5959176069 [lld] Use lit's shell to run tests on Windows by default
It's a lot faster than bash.

Also use FileCheck instead of grep to search through a binary file.
Cygwin's grep isn't working here for unknown reasons that probably
aren't worth investigating.

llvm-svn: 237834
2015-05-20 20:41:45 +00:00
Rafael Espindola c08ab8e6e4 Delete unnecessary generality in loadFile.
loadFile could load mulitple files just because yaml has a feature for
putting multiple documents in one file.

Designing a linker around what yaml can do seems like a bad idea to
me. This patch changes it to read a single file.

There are further improvements to be done to the api and they
will follow shortly.

llvm-svn: 235724
2015-04-24 15:51:45 +00:00
Rui Ueyama 2c64aef35f Remove YAML/Native round-trip passes.
The round-trip passes were introduced in r193300. The intention of
the change was to make sure that LLD is capable of reading end
writing such file formats.

But that turned out to be yet another over-designed stuff that had
been slowing down everyday development.

The passes ran after the core linker and before the writer. If you
had an additional piece of information that needs to be passed from
front-end to the writer, you had to invent a way to save the data to
YAML/Native. These passes forced us to do that even if that data
was not needed to be represented neither in an object file nor in
an executable/DSO. It doesn't make sense. We don't need these passes.

http://reviews.llvm.org/D7480

llvm-svn: 230069
2015-02-20 22:10:28 +00:00
Filipe Cabecinhas d1787adcec Fix REQUIRES lines added in r226951 and add the x86 feature if the X86 target was compiled in
llvm-svn: 226985
2015-01-24 03:55:22 +00:00
Ed Maste 933daef54f Add FreeBSD to system-linker-elf case
llvm-svn: 217672
2014-09-12 13:16:30 +00:00
Nick Kledzik 50bda292c8 If lld is renamed (or symlinked) to "ld" automatically pick the right flavor.
The existing system linkers on Darwin and Linux are called "ld".  We'd like to
eventually drop in lld as "ld" and have it just work.  But lld is a universal
linker that requires the first option to be -flavor to know which command line
mode to emulate (gnu or darwin).

This change tests if argv[0] is "ld" and if so, if the tool was built on MacOSX
then assume the darwin flavor otherwise the gnu flavor.  There are two test
cases which copy lld to "ld" and then run it. One for darwin and one for linux.

llvm-svn: 217566
2014-09-11 00:52:05 +00:00
Simon Atanasyan d7bc5d0119 XFAIL the ARM test when we don't have this target.
llvm-svn: 214420
2014-07-31 19:02:10 +00:00
Filipe Cabecinhas cd8c610cb0 XFAIL the Mips tests when we don't have the target.
These tests shouldn't even try to use the Mips target, but let's make
them not fail when we don't have it while they don't get fixed.

llvm-svn: 206947
2014-04-23 05:35:26 +00:00
Filipe Cabecinhas 47f07f8c9a winlib should be lib.exe, not just lib.
This avoids setting the winlib feature on machines with a lib dir in a
$PATH dir.

llvm-svn: 206940
2014-04-23 04:38:13 +00:00
Michael J. Spencer 876bee8155 [lit] Environment variables get stripped in lit. Manually specify locale.
llvm-svn: 204774
2014-03-26 01:19:07 +00:00
Michael J. Spencer a4f983e258 [lit] Python 3.
llvm-svn: 204773
2014-03-26 00:53:48 +00:00
Rui Ueyama bc6b52e68e Move RoundTrip tests behind LLVM_RUN_ROUNDTRIP_TEST env flag.
If the environment variable is defined and not empty, RoundTrip tests
are run. The reason to move the tests behind the flag is because they
are too slow to enable by default.

LLD linking time on llvm-tblgen improved from 2m7s to 2.3s. About 60x
faster now in this case.

Differential Revision: http://llvm-reviews.chandlerc.com/D3126

llvm-svn: 204296
2014-03-20 02:49:33 +00:00
Shankar Easwaran 7a0818dd4a [test] use llvm-config to drive testing in assert mode/debug mode
llvm-svn: 202101
2014-02-25 02:29:17 +00:00
Nico Rieck 78f2b48e7d Fix feature detection in lld's lit.cfg
llvm-svn: 202078
2014-02-24 21:13:53 +00:00
Rui Ueyama 76d2fa70be [PECOFF] Add a test for r197803.
llvm-svn: 198828
2014-01-09 01:11:48 +00:00
Rui Ueyama f23b27a837 [PECOFF] Add a test for the resource file.
llvm-svn: 193982
2013-11-04 05:17:54 +00:00
Daniel Dunbar bc7bfb1bee [tests] Update to use lit_config and lit package, as appropriate.
llvm-svn: 188093
2013-08-09 18:51:17 +00:00
Rui Ueyama 130a6eb7fa Try to guard a test that requires DEBUG().
This is a follow-up patch for r185524. Being assert enabled does not mean
that DEBUG() is enabled, so we need to check the existence of DEBUG() itself.

llvm-svn: 185619
2013-07-04 09:29:47 +00:00
Rui Ueyama 924922235e Guard a test that fails on a Release build.
llvm-svn: 185524
2013-07-03 09:09:13 +00:00
Michael J. Spencer ca20ffbab2 [test] Fix tests on Windows.
llvm-svn: 172339
2013-01-13 01:09:51 +00:00
Michael J. Spencer 74f29afd58 [Driver] Add test.
llvm-svn: 169721
2012-12-10 02:53:10 +00:00
Sid Manning 37e3120af8 Fix environment path problem
llvm-svn: 163929
2012-09-14 20:04:36 +00:00
Hemant Kulkarni 927bbc2871 ELF support for LLD writer. The writer at present emits ELF header and section
table header. Skeleton code for ReferenceKinds.
Credits:
Doxygen by  Michael Spencer.
Origianl implementation from Macho by Sidney Manning.
Templatization, implementation of section header chunks, string table, ELF header by Hemant Kulkarni.

llvm-svn: 163906
2012-09-14 16:11:34 +00:00
Michael J. Spencer 773a8fb6ab Initial commit. Code by Nick Kledzik. Cleanups and build system by me.
llvm-svn: 146844
2011-12-18 08:27:59 +00:00