summaryrefslogtreecommitdiffstats
path: root/lld/unittests
Commit message (Collapse)AuthorAgeFilesLines
* [MachO] Add a test for detecting reserved unit length.Igor Kudrin2020-01-151-0/+38
| | | | | | This is a follow-up for D71546 to add a corresponding unit test. Differential Revision: https://reviews.llvm.org/D72695
* Make it possible to redirect not only errs() but also outs()Rui Ueyama2019-11-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-195-20/+15
| | | | | | | | | | | | | | | | | 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
* [Darwin] Use errorHandler from liblldCommonBrian Gesiak2018-06-121-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Error handling in liblldCore and the Darwin toolchain prints to an output stream. A TODO in the project explained that a diagnostics interface resembling Clang's should be added. For now, the simple diagnostics interface defined in liblldCommon seems like an improvement. It prints colors when they're available, uses locks for thread-safety, and abstracts away the `"error: "` and newline literal strings that litter the Darwin toolchain code. To use the liblldCommon error handler, a link dependency is added to the liblldDriver library. Test Plan: 1. check-lld 2. Invoke `ld64.lld -r` in a terminal that supports color output. Confirm that "ld64.lld: error: -arch not specified and could not be inferred" is output, and that the "error:" is colored red! Reviewers: ruiu, smeenai Reviewed By: ruiu Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D47998 llvm-svn: 334466
* Remove \brief commands from doxygen comments.Fangrui Song2018-05-151-1/+1
| | | | | | | | | | | | Summary: This is similar to D46290 D46320. Reviewers: ruiu, grimar Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D46861 llvm-svn: 332372
* [MachO] Don't write test files to /tmp, remove them afterwards.Martin Storsjo2018-05-111-5/+10
| | | | | | | | | This matches what is done in MachONormalizedFileBinaryWriterTests.cpp already. Differential Revision: https://reviews.llvm.org/D46743 llvm-svn: 332114
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-052-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 llvm-svn: 319840
* Move new lld's code to Common subdirectory.Rui Ueyama2017-10-021-1/+1
| | | | | | | | | | 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
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-075-10/+10
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* [Support] Move Parallel algorithms from LLD to LLVM.Zachary Turner2017-05-113-54/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D33024 llvm-svn: 302748
* [Core] Make parallel algorithms match C++ Parallelism TS.Zachary Turner2017-05-101-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D33016 llvm-svn: 302613
* Split up Parallel and LLVM'ize naming conventions.Zachary Turner2017-05-051-1/+1
| | | | | | | | | | | | This is one step in preparation of raising this up to LLVM. This hides all of the Executor stuff in a private implementation file, leaving only the core algorithms and the TaskGroup class exposed. In doing so, fix up all the variable names to conform to LLVM style. Differential Revision: https://reviews.llvm.org/D32890 llvm-svn: 302288
* Fix signed/unsigned comparison warning in a unit test. This was appearing onJames Henderson2017-04-071-1/+1
| | | | | | lld-x86_64-darwin13. llvm-svn: 299749
* [Core] Fix parallel_for for LinuxJames Henderson2017-04-071-0/+15
| | | | | | | | r299635 exposed a latent bug in the Linux implementation of parallel_for, which resulted in it calling the function outside of the range requested, resulting later in a segmentation fault. This change fixes this issue and adds a unit test. llvm-svn: 299748
* [CMake] Fix pthread handling for out-of-tree buildsEric Fiselier2017-02-101-1/+1
| | | | | | | | | | | | | | | 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
* [Cmake] Use Cmake's default RPATH for unittest.Davide Italiano2016-09-121-0/+2
| | | | | | | | | | | | | Similarly to what was done in r280791 for llvm/. This should fix a bunch of failures I saw while trying a BUILD_SHARED_LIBS build on MacOS. Still there are some failures, but this is a step forward. Thanks a lot to Chris Bieneman for the suggested fix (in PR30345) llvm-svn: 281256
* Fix potential test failures.Rui Ueyama2016-09-021-0/+4
| | | | | | | | | | | | | | | | | Windows does not allow opened files to be removed. This patch fixes two types of errors. - Output file being the same as input file. Because LLD itself holds a file descriptor of the input file, it cannot create an output file with the same name as a new file. - Removing files before releasing MemoryBuffer objects. These tests are not failing no because MemoryBuffer happens to decide not to use mmap on these files. But we shouldn't rely on that behavior. llvm-svn: 280507
* Fix Clang-tidy misc-unused-using-decls and Include What You Use warnings.Eugene Zelenko2016-04-213-4/+26
| | | | | | Differential revision: http://reviews.llvm.org/D19348 llvm-svn: 267008
* Fix test which failed Error migration on Windows bots.Pete Cooper2016-04-041-3/+2
| | | | | | | | | | | | | | Note, this is https://llvm.org/bugs/show_bug.cgi?id=27187. The problem here was that just converting an error to a bool doesn't always set the checked bit. We only set that bit if the Error didn't actually contain an error. Otherwise we'd end potentially up silently dropping it. Instead just use the consumeError method which is designed to allow us to drop an error. llvm-svn: 265311
* Use Expected<T> instead of ErrorOr<T>in yaml reader. NFCPete Cooper2016-03-311-1/+1
| | | | llvm-svn: 264981
* Convert readBinary to llvm::Error. NFCPete Cooper2016-03-302-2/+2
| | | | llvm-svn: 264973
* Convert normalized file to atoms methods to new error handling. NFC.Pete Cooper2016-03-301-2/+2
| | | | | | | This converts almost all of the error handling in atom creation to llvm::Error instead of std::error_code. llvm-svn: 264968
* Fix MachO test which is failing on a Windows bot.Pete Cooper2016-03-301-1/+5
| | | | | | | | | | This is breaking http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/31647/steps/test%20lld/logs/stdio. The issue seems to be that it can't write to a file in /tmp, probably because that path doesn't exist on Windows. This was failing after I added EXPECT_FALSE(ec) in r264961 for the error handling migration. llvm-svn: 264962
* Convert lld file writing to llvm::Error. NFC.Pete Cooper2016-03-302-9/+10
| | | | | | | This converts the writeFile method, as well as some of the ones it calls in the normalized binary file writer and yaml writer. llvm-svn: 264961
* Fix Clang-tidy modernize-deprecated-headers warnings; other minor fixes.Eugene Zelenko2016-03-213-22/+0
| | | | | | Differential revision: http://reviews.llvm.org/D18232 llvm-svn: 263968
* Merge DarwinLdDriver and Driver.Rui Ueyama2016-03-021-1/+8
| | | | | | | | | | | Now that DarwinLdDriver is the only derived class of Driver. This patch merges them and actually removed the class because they can now just be non-member functions. This change simplifies a common header, Driver.h. http://reviews.llvm.org/D17788 llvm-svn: 262502
* Fix BUILD_SHARED_LIBS build.Rafael Espindola2016-03-021-0/+1
| | | | llvm-svn: 262485
* Tidy up CMakefiles.Rui Ueyama2016-03-021-3/+0
| | | | llvm-svn: 262434
* Fix BUILD_SHARED_LIBS build.Rafael Espindola2016-03-011-0/+4
| | | | llvm-svn: 262345
* Remove DriverTest.h.Rui Ueyama2016-02-282-124/+67
| | | | | | | | Because the class is used only by one instance, we do not have to use template there in DriverTest.h. Everything can be moved to DarwinLdDriverTest.cpp. llvm-svn: 262192
* Move functionality of UniversalDriver to the entry point file.Rui Ueyama2016-02-283-42/+0
| | | | | | | | | | | | | | UniversalDriver was used as a dispatcher to each platform-specific driver. It had its own Options.td file. It was not just too much to parse only a few options (we only want to parse -core, -flavor or argv[0]), but also interpreted arguments too early. For example, if you invoke lld as "lld -flavor gnu ... -help", then you'd get the UniversalDriver's help message instead of GnuDriver's. This patch eliminates the use of Options from the dispatcher. http://reviews.llvm.org/D17686 llvm-svn: 262190
* Remove lld/Core/range.h.Rui Ueyama2016-02-282-241/+0
| | | | | | | | | | | IIUC, range was an experiment to see how N3350 would work in LLD. It turned out it didn't get traction, and it is basically duplicate of iterator_range in ADT. We have only two occurrences of range, and all of them are easily rewritten without it. http://reviews.llvm.org/D17687 llvm-svn: 262171
* Remove the old ELF linker.Rafael Espindola2016-02-283-303/+2
| | | | | | I think it is clear by now that the new linker is viable. llvm-svn: 262158
* Add support for export_dynamic cmdline option and behaviour.Pete Cooper2016-01-221-0/+25
| | | | | | | | | | | This option matches the behaviour of ld64, that is it prevents globals from being dead stripped in executables and dylibs. Reviewed by Lang Hames Differential Revision: http://reviews.llvm.org/D16026 llvm-svn: 258554
* Fix DarwinLdDriverTest.cpp to pass real llvm options.Pete Cooper2015-12-161-3/+3
| | | | | | | | | | | After r255819, parse() actually parses what you pass it. This test was failing because it passed '--debug-only' which isn't in release builds, but also 'foo' which isn't an option at all. We now pass -enable-tbaa and -enable-misched which are real options. llvm-svn: 255822
* Make ELF2 the default.Rafael Espindola2015-11-171-1/+1
| | | | | | With this the only way to get the old elf linker is "-flavor old-elf". llvm-svn: 253318
* Rename gnu2 to gnu.Rafael Espindola2015-11-161-1/+1
| | | | | | This is the second step in making ELF2 the default. llvm-svn: 253270
* [Mips] Support two more MIPS linking emulation options ↵Simon Atanasyan2015-08-281-0/+6
| | | | | | elf32btsmipn32/elf32ltsmipn32 llvm-svn: 246336
* [Mips] Make "emulation" option less dependent on the "-target" option.Simon Atanasyan2015-08-281-0/+10
| | | | | | | Now it is possible to have mips-linux-gnu-ld executable and link MIPS 64-bit little-endian binaries providing -melf64ltsmip command line argument. llvm-svn: 246335
* COFF: Remove the old COFF linker and make link an alias to link2.Rui Ueyama2015-08-063-886/+0
| | | | | | It's time to remove old COFF linker because the new one is now complete. llvm-svn: 244226
* Fix -Wextra-semi.Rui Ueyama2015-07-231-2/+1
| | | | | | Patch from Eugene.Zelenko! llvm-svn: 243060
* Revert ELF port. Posting to mailing list.Michael J. Spencer2015-07-141-1/+0
| | | | llvm-svn: 242118
* Initial ELF port.Michael J. Spencer2015-07-131-0/+1
| | | | | | | | This is a direct port of the new PE/COFF linker to ELF. It can take a single object file and generate a valid executable that executes at the first byte in the text section. llvm-svn: 242088
* ArrayRef-ify Driver::parse and related functions.David Blaikie2015-06-212-2/+2
| | | | llvm-svn: 240236
* COFF: Add a new PE/COFF port.Rui Ueyama2015-05-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is an initial patch for a section-based COFF linker. The patch has 2300 lines of code including comments and blank lines. Before diving into details, you want to start from reading README because it should give you an overview of the design. All important things are written in the README file, so I write summary here. - The linker is already able to self-link on Windows. - It's significantly faster than the existing implementation. The existing one takes 5 seconds to link LLD on my machine, while the new one only takes 1.2 seconds, even though the new one is not multi-threaded yet. (And a proof-of-concept multi- threaded version was able to link it in 0.5 seconds.) - It uses much less memory (250MB vs. 2GB virtual memory space to self-host). - IMHO the new code is much simpler and easier to read than the existing PE/COFF port. http://reviews.llvm.org/D10036 llvm-svn: 238458
* Remove redundant std::move on functions that return a unique_ptr.Benjamin Kramer2015-05-221-1/+1
| | | | llvm-svn: 238034
* Revert r234649 "PECOFF: Use C++11 braced init list to make Version objects."Nico Weber2015-04-111-10/+10
| | | | | | | | | | | | | | This doesn't compile with MSVC 2013: include\lld/ReaderWriter/PECOFFLinkingContext.h(356) : error C2797: 'lld::PECOFFLinkingContext::_imageVersion': list initialization inside member initializer list or non-static data member initializer is not implemented include\lld/ReaderWriter/PECOFFLinkingContext.h(357) : error C2797: 'lld::PECOFFLinkingContext::_imageVersion': list initialization inside member initializer list or non-static data member initializer is not implemented llvm-svn: 234676
* PECOFF: Use C++11 braced init list to make Version objects.Rui Ueyama2015-04-101-10/+10
| | | | llvm-svn: 234649
* Remove unused typedefs.Rui Ueyama2015-04-081-1/+1
| | | | llvm-svn: 234415
* Remove Makefiles.Rui Ueyama2015-03-263-65/+0
| | | | | | | | Most developers prefer to not have them, and we agreed to remove them from LLD. http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-March/083368.html llvm-svn: 233313
OpenPOWER on IntegriCloud