summaryrefslogtreecommitdiffstats
path: root/lld/lib/Driver
Commit message (Collapse)AuthorAgeFilesLines
* [lld] Fix trivial typos in commentsKazuaki Ishizaki2020-01-061-4/+4
| | | | | | Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D72196
* LLD: Don't use the stderrOS stream in link before it's reassigned.James Y Knight2019-11-211-4/+4
| | | | | | | | | | | | | | | | 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 b11386f9be9b2dc7276a758d64f66833da10bdea. Differential Revision: https://reviews.llvm.org/D70492
* Fix component buildRui Ueyama2019-11-191-2/+2
| | | | | b11386f9be9b2dc7276a758d64f66833da10bdea broke lld build if `-DBUILD_SHARED_LIBS=ON` is passed to CMake.
* Make it possible to redirect not only errs() but also outs()Rui Ueyama2019-11-181-13/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [LLD] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-4/+4
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368936
* Re-submit r367649: Improve raw_ostream so that you can "write" colors using ↵Rui Ueyama2019-08-071-1/+1
| | | | | | | | | operator<< The original patch broke buildbots, perhaps because it changed the default setting whether colors are enabled or not. llvm-svn: 368131
* Revert r367649: Improve raw_ostream so that you can "write" colors using ↵Rui Ueyama2019-08-021-0/+1
| | | | | | | | operator<< This reverts commit r367649 in an attempt to unbreak Windows bots. llvm-svn: 367658
* Improve raw_ostream so that you can "write" colors using operator<<Rui Ueyama2019-08-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. raw_ostream supports ANSI colors so that you can write messages to the termina with colors. Previously, in order to change and reset color, you had to call `changeColor` and `resetColor` functions, respectively. So, if you print out "error: " in red, for example, you had to do something like this: OS.changeColor(raw_ostream::RED); OS << "error: "; OS.resetColor(); With this patch, you can write the same code as follows: OS << raw_ostream::RED << "error: " << raw_ostream::RESET; 2. Add a boolean flag to raw_ostream so that you can disable colored output. If you disable colors, changeColor, operator<<(Color), resetColor and other color-related functions have no effect. Most LLVM tools automatically prints out messages using colors, and you can disable it by passing a flag such as `--disable-colors`. This new flag makes it easy to write code that works that way. Differential Revision: https://reviews.llvm.org/D65564 llvm-svn: 367649
* [Coding style change][lld] Rename variables for non-ELF portsRui Ueyama2019-07-111-12/+12
| | | | | | | | | | | 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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* Eliminate dependency to formatv(). NFC.Rui Ueyama2018-10-101-4/+3
| | | | llvm-svn: 344177
* Adapt OptTable::PrintHelp change in D51009Fangrui Song2018-10-101-3/+7
| | | | | | | | | | | | | | Summary: Before, OptTable::PrintHelp append "[options] <inputs>" to its parameter `Help`. It is more flexible to change its semantic to `Usage` and let user customize the usage line. Reviewers: rupprecht, ruiu, espindola Reviewed By: rupprecht Subscribers: emaste, sbc100, arichardson, aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D53054 llvm-svn: 344099
* Rename a function to follow the LLVM coding style.Rui Ueyama2018-08-271-1/+1
| | | | llvm-svn: 340716
* win: Omit ".exe" from lld warning and error messages.Nico Weber2018-08-221-1/+1
| | | | | | | | | | | This is a minor follow-up to https://reviews.llvm.org/D49189. On Windows, lld used to print "lld-link.exe: error: ...". Now it just prints "lld-link: error: ...". This matches what link.exe does (it prints "LINK : ...") and makes lld's output less dependent on the host system. https://reviews.llvm.org/D51133 llvm-svn: 340487
* Omit path to lld binary from lld's error, warning, and log output.Nico Weber2018-07-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lld currently prepends the absolute path to itself to every diagnostic it emits. This path can be longer than the diagnostic, and makes the actual error message hard to read. There isn't a good reason for printing this path: if you want to know which lld you're running, pass -v to clang – chances are that if you're unsure of this, you're not only unsure when it errors out. Some people want an indication that the diagnostic is from the linker though, so instead print just the basename of the linker's path. Before: ``` $ out/bin/clang -target x86_64-unknown-linux -x c++ /dev/null -fuse-ld=lld /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crt1.o: No such file or directory /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crti.o: No such file or directory /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crtbegin.o: No such file or directory /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc_s /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lc /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc_s /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crtend.o: No such file or directory /Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crtn.o: No such file or directory clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` After: ``` $ out/bin/clang -target x86_64-unknown-linux -x c++ /dev/null -fuse-ld=lld ld.lld: error: cannot open crt1.o: No such file or directory ld.lld: error: cannot open crti.o: No such file or directory ld.lld: error: cannot open crtbegin.o: No such file or directory ld.lld: error: unable to find library -lgcc ld.lld: error: unable to find library -lgcc_s ld.lld: error: unable to find library -lc ld.lld: error: unable to find library -lgcc ld.lld: error: unable to find library -lgcc_s ld.lld: error: cannot open crtend.o: No such file or directory ld.lld: error: cannot open crtn.o: No such file or directory clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` https://reviews.llvm.org/D49189 llvm-svn: 337634
* [Darwin] Do not error on '-lto_library' optionBrian Gesiak2018-06-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Any invocation of `clang -fuse-ld=lld` that results in a link command on a macOS host currently fails, because the Darwin lld driver does not recognize the `-lto_library` option that Clang passes it. Fix the error by having the Darwin driver ignore the option. The Clang driver's macOS toolchain is written such that it will always pass the `-lto_library` option to the linker invocation on a macOS host. And although the DarwinLdDriver is written to ignore any unknown arguments, because `-lto_library` begins with `-l`, the DarwinLdDriver interprets it as a library search command, for a library named "to_library". When the DarwinLdDriver is unable to find a library specified via `-l`, it exits with a hard error. This causes any invocation of `clang -fuse-ld=lld` that results in a link command on a macOS host to fail with an error. To fix the issue, I considered two alternatives: 1. Modify the Clang Darwin toolchain to only pass `-lto_library` if lld is *not* being used. lld doesn't support LTO on Darwin anyway, so it can't use the option. However, I opted against this because, if and when lld *does* support LTO on Darwin, I'll have to make another commit to Clang in order to get it to pass the option to lld again. 2. Modify the Darwin lld driver to ignore the `-lto_library` option. Just in case users may take this to mean LTO is supported, I also added a warning. If and when lld supports LTO on Darwin, the same commit that adds support for this option can remove the warning. Option (2) seemed better to me, and is the rationale behind this commit. Test Plan: check-lld Reviewers: ruiu, smeenai, pcc Reviewed By: smeenai Subscribers: JDevlieghere, pcc, mehdi_amini, inglorion, steven_wu, llvm-commits Differential Revision: https://reviews.llvm.org/D47994 llvm-svn: 334641
* [Darwin] Use errorHandler from liblldCommonBrian Gesiak2018-06-123-161/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [lld] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-1/+1
| | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Differential Revision: https://reviews.llvm.org/D44977 llvm-svn: 332351
* lld: Prune unused libdeps.NAKAMURA Takumi2017-10-121-1/+0
| | | | llvm-svn: 315537
* lld: Reorder libdeps.NAKAMURA Takumi2017-10-111-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D38828 llvm-svn: 315529
* Build fix: don't try to link in lldConfigHans Wennborg2017-10-021-1/+0
| | | | | | Config was removed in r314719. llvm-svn: 314736
* 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
* NFC: LLD fix OptTable Variable Name StyleMartell Malone2017-08-231-2/+2
| | | | llvm-svn: 311518
* [GSoC] Flag value completion for clangYuka Takahashi2017-06-201-7/+9
| | | | | | | | | | | | 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
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-4/+4
| | | | | | | | | | | | 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
* [lld][cmake] Fix LLVM_LINK_LLVM_DYLIB buildPavel Labath2017-01-091-3/+5
| | | | | | | | | | | | | | | | | | | | | | | 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
* Prevent at compile time converting from Error::success() to Expected<T>Mehdi Amini2016-11-111-1/+1
| | | | | | | | This would trigger an assertion at runtime otherwise. Differential Revision: https://reviews.llvm.org/D26482 llvm-svn: 286562
* Fix some Clang-tidy modernize-use-default and Include What You Use warnings; ↵Eugene Zelenko2016-11-041-7/+27
| | | | | | | | other minor fixes. Differential revision: https://reviews.llvm.org/D26293 llvm-svn: 286000
* [Driver] Remove break after return. NFCI.Davide Italiano2016-08-161-1/+0
| | | | llvm-svn: 278834
* [MachO] Factor out some common code in the Driver.Davide Italiano2016-08-041-13/+15
| | | | llvm-svn: 277761
* [MachO] Add a couple of missing braces.Davide Italiano2016-07-201-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D21979 llvm-svn: 276213
* Change library search methods to return Optional instead of ErrorOr.Pete Cooper2016-03-311-5/+7
| | | | | | | | | | | | These methods weren't really throwing errors. The only error used was that a file could not be found, which isn't really an error at all as we are searching paths and libraries for a file. All of the callers also ignored errors and just used the returned path if one was available. Changing to return Optional<StringRef> as that actually reflects what we are trying to do here: optionally find a given path. llvm-svn: 264979
* Convert lld file writing to llvm::Error. NFC.Pete Cooper2016-03-301-3/+5
| | | | | | | 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
* Change loadFileList to llvm::Error. NFCPete Cooper2016-03-301-14/+16
| | | | llvm-svn: 264921
* Convert lld Pass::runOnFile to llvm::Error from std::error_code. NFC.Pete Cooper2016-03-301-3/+7
| | | | | | | Pretty mechanical change here. Just replacing all the std::error_code() with llvm::Error() and make_dynamic_error_code with make_error<GenericError> llvm-svn: 264917
* Use owning pointers instead of raw pointers for Atom's to fix leaks.Pete Cooper2016-03-221-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | This is a re-commit of r264022 with a fix for MSVC. The issue there was that the code was running DefinedAtom::~Atom() for some value and instead needed to cast to Atom before running ~Atom. Original commit message follows. Currently each File contains an BumpPtrAllocator in which Atom's are allocated. Some Atom's contain data structures like std::vector which leak as we don't run ~Atom when they are BumpPtrAllocate'd. Now each File actually owns its Atom's using an OwningAtomPtr. This is analygous to std::unique_ptr and may be replaced by it if possible. An Atom can therefore only be owned by a single File, so the Resolver now moves them from one File to another. The MachOLinkingContext owns the File's and so clears all the Atom's in ~MachOLinkingContext, then delete's all the File's. This makes sure all Atom's have been destructed before any of the BumpPtrAllocator's in which they run have gone away. Should hopefully fix the remaining leaks. Will keep an eye on the bots to make sure. llvm-svn: 264067
* Revert "Use owning pointers instead of raw pointers for Atom's to fix leaks."Pete Cooper2016-03-221-8/+1
| | | | | | | | | | | | This reverts commit r264022. This breaks the Window's bots which don't like that i'm calling ~Atom when the this pointer is a sublcass of Atom. Reverting for now until I try find a better fix. I tried using std::unique_ptr with a custom deleter as a quick fix, but it didn't work well in the YAML parser. llvm-svn: 264023
* Use owning pointers instead of raw pointers for Atom's to fix leaks.Pete Cooper2016-03-221-1/+8
| | | | | | | | | | | | | | | | | | | | Currently each File contains an BumpPtrAllocator in which Atom's are allocated. Some Atom's contain data structures like std::vector which leak as we don't run ~Atom when they are BumpPtrAllocate'd. Now each File actually owns its Atom's using an OwningAtomPtr. This is analygous to std::unique_ptr and may be replaced by it if possible. An Atom can therefore only be owned by a single File, so the Resolver now moves them from one File to another. The MachOLinkingContext owns the File's and so clears all the Atom's in ~MachOLinkingContext, then delete's all the File's. This makes sure all Atom's have been destructed before any of the BumpPtrAllocator's in which they run have gone away. Should hopefully fix the remaining leaks. Will keep an eye on the bots to make sure. llvm-svn: 264022
* Merge DarwinLdDriver and Driver.Rui Ueyama2016-03-023-118/+83
| | | | | | | | | | | 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
* Tidy up CMakefiles.Rui Ueyama2016-03-021-3/+0
| | | | llvm-svn: 262434
* Remove unused #include's.Rui Ueyama2016-03-021-8/+0
| | | | llvm-svn: 262431
* Make a few utility functions file-scoped.Rui Ueyama2016-03-012-17/+19
| | | | | | | makeErrorFile and parseMemberFiles are now used only in DarwinLdDriver.cpp. This patch moves them to that file. llvm-svn: 262423
* Remove dead code.Rui Ueyama2016-03-011-17/+0
| | | | llvm-svn: 262422
* Remove CoreDriver.Rui Ueyama2016-03-013-191/+0
| | | | | | | | | | | CoreDriver implements a driver for a hypothetical platform. It is intended to be used in unittests. However, it is actually redundant because the features are tested using the real driver for the real platforms. So we can remove this. http://reviews.llvm.org/D17698 llvm-svn: 262421
* Remove dead code for ELF.Rui Ueyama2016-02-281-5/+2
| | | | | | The preload feature was buggy that we had disabled it even for ELF. llvm-svn: 262194
* Move functionality of UniversalDriver to the entry point file.Rui Ueyama2016-02-283-242/+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 obsolte TODOs. They are for the old gnu driver.Rui Ueyama2016-02-281-99/+0
| | | | llvm-svn: 262172
* Remove a few bits of elf from the old linker.Rafael Espindola2016-02-281-1/+0
| | | | llvm-svn: 262164
* Rename elf2 to elf.Rafael Espindola2016-02-282-2/+2
| | | | llvm-svn: 262159
* Remove the old ELF linker.Rafael Espindola2016-02-284-1175/+0
| | | | | | I think it is clear by now that the new linker is viable. llvm-svn: 262158
OpenPOWER on IntegriCloud