summaryrefslogtreecommitdiffstats
path: root/lld/Common
Commit message (Collapse)AuthorAgeFilesLines
* Make LLVM_APPEND_VC_REV=OFF affect clang, lld, and lldb as well.Nico Weber2020-06-231-2/+2
| | | | | | | | | | | | | | | | | | When LLVM_APPEND_VC_REV=OFF is set, the current git hash is no longer embedded into binaries (mostly for --version output). Without it, most binaries need to relink after every single commit, even if they didn't change otherwise (due to, say, a documentation-only commit). LLVM_APPEND_VC_REV is ON by default, so this doesn't change the default behavior of anything. With this, all clients of GenerateVersionFromVCS.cmake honor LLVM_APPEND_VC_REV. Differential Revision: https://reviews.llvm.org/D72855 (cherry picked from commit fb5fafb23cc2d8613f8be2487afe94d8594a88ce)
* [Support] ThreadPoolExecutor fixes for Windows/MinGWAndrew Ng2020-01-101-3/+4
| | | | | | | | | | | | | | | | | | | | | Changed ThreadPoolExecutor to no longer use detached threads and instead to join threads on destruction. This is to prevent intermittent crashing on Windows when doing a normal full exit, e.g. via exit(). Changed ThreadPoolExecutor to be a ManagedStatic so that it can be stopped on llvm_shutdown(). Without this, it would only be stopped in the destructor when doing a full exit. This is required to avoid intermittent crashing on Windows due to a race condition between the ThreadPoolExecutor starting up threads and the process doing a fast exit, e.g. via _exit(). The Windows crashes appear to only occur with the MSVC static runtimes and are more frequent with the debug static runtime. These changes also prevent intermittent deadlocks on exit with the MinGW runtime. Differential Revision: https://reviews.llvm.org/D70447
* [lld] Fix trivial typos in commentsKazuaki Ishizaki2020-01-061-1/+1
| | | | | | 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-2/+0
| | | | | | | | | | | | | | | | 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
* Make it possible to redirect not only errs() but also outs()Rui Ueyama2019-11-181-15/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Move duplicated dwarf parsing code to the Common library. NFC.Martin Storsjo2019-10-212-0/+105
| | | | | | Differential Revision: https://reviews.llvm.org/D69197 llvm-svn: 375390
* [LLD] Simplify the demangleItanium function. NFC.Martin Storsjo2019-09-271-7/+4
| | | | | | | | | Instead of returning an optional, just return the input string if demangling fails, as that's what all callers use anyway. Differential Revision: https://reviews.llvm.org/D68015 llvm-svn: 373077
* [LLD] Convert demangleItanium to use the higher level llvm::demangle ↵Martin Storsjo2019-09-271-6/+4
| | | | | | | | | | | | | function. NFC. This avoids a few lines of boilerplate of dealing with C string allocations. Add a testcase for a case where demangling shouldn't happen. Differential Revision: https://reviews.llvm.org/D68014 llvm-svn: 373076
* [LLD] [COFF] Use the unified llvm demangle frontend function. NFC.Martin Storsjo2019-09-271-17/+0
| | | | | | | | Add test cases for some cases where we don't want demangling to happen. Differential Revision: https://reviews.llvm.org/D67301 llvm-svn: 373075
* [ELF] For VS-style diagnostics, prefer printing full paths in the header.Igor Kudrin2019-08-091-2/+9
| | | | | | | | | | | | The filename part in the message header is used by Visual Studio to fill Error List so that a user can click on an item and jump to the mentioned location. If we use only the name of a source file and not the full path, Visual Studio might be unable to find the right file or, even worse, show a wrong one. Differential Revision: https://reviews.llvm.org/D65875 llvm-svn: 368409
* [ELF] Fix splitting messages for duplicate symbols.Igor Kudrin2019-08-071-2/+2
| | | | | | | | | D65213 (rL367536) does not work for the case when a source file path includes subdirectories. Differential Revision: https://reviews.llvm.org/D65810 llvm-svn: 368153
* Simplify error message output. NFC.Rui Ueyama2019-08-071-16/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D65855 llvm-svn: 368144
* Re-submit r367649: Improve raw_ostream so that you can "write" colors using ↵Rui Ueyama2019-08-071-60/+46
| | | | | | | | | operator<< The original patch broke buildbots, perhaps because it changed the default setting whether colors are enabled or not. llvm-svn: 368131
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-1/+1
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* Revert r367649: Improve raw_ostream so that you can "write" colors using ↵Rui Ueyama2019-08-021-42/+59
| | | | | | | | operator<< This reverts commit r367649 in an attempt to unbreak Windows bots. llvm-svn: 367658
* Add an assert() to catch possible regexp errors.Rui Ueyama2019-08-021-5/+6
| | | | llvm-svn: 367651
* Add a comment for --vs-diagnostics.Rui Ueyama2019-08-021-0/+21
| | | | llvm-svn: 367650
* Improve raw_ostream so that you can "write" colors using operator<<Rui Ueyama2019-08-021-59/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ELF] With --vs-diagnostics, print a separate message for each location of a ↵Igor Kudrin2019-08-011-3/+24
| | | | | | | | | | | | | duplicate symbol. We extract and print the source location in the message header so that Visual Studio is able to parse it and jump there. As duplicate symbols are defined in several locations, it is more convenient to have separate error messages, which allows a user to easily access all the locations. Differential Revision: https://reviews.llvm.org/D65213 llvm-svn: 367536
* [ELF] Fix finding locations in messages for undefined hidden symbols.Igor Kudrin2019-08-011-3/+1
| | | | | | | | | | | | Previously, when `--vs-diagnostics` was used, the linker printed something like hidden(undef.s): error: undefined hidden symbol: foo >>> referenced by undef.s:15 Differential Revision: https://reviews.llvm.org/D65499 llvm-svn: 367515
* [LLD] Do not print additional newlines after reaching error limitAlexander Richardson2019-07-241-1/+2
| | | | | | | | | | | | | | | | | | | | Summary: This could previously happen if errors that are emitted after reaching the error limit. In that case, the flag inside the newline() function will be set to true which causes the next call to print a newline even though the actual message will be discarded. Reviewers: ruiu, grimar, MaskRay, espindola Reviewed By: ruiu Subscribers: emaste, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65198 llvm-svn: 366944
* [ELF] Support explicitly overriding relocation model in LTOPetr Hosek2019-07-201-0/+4
| | | | | | | | lld currently selects the relocation model automatically depending on the link flags specified, but in some cases it'd be useful to allow explicitly overriding the relocation model using a flag. llvm-svn: 366644
* [lld] Add Visual Studio compatible diagnosticsChris Jackson2019-07-171-5/+40
| | | | | | | | | | | | Summary: Add a --vs-diagnostics flag that alters the format of diagnostic output to enable source hyperlinks in Visual Studio. Differential Revision: https://reviews.llvm.org/D58484 Reviewed by: ruiu llvm-svn: 366333
* Fix build breakage on Win32.Rui Ueyama2019-07-111-1/+1
| | | | llvm-svn: 365732
* [Coding style change][lld] Rename variables for non-ELF portsRui Ueyama2019-07-118-219/+219
| | | | | | | | | | | 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
* Let unaliased Args track which Alias they were created from, and use that in ↵Nico Weber2019-07-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Arg::getAsString() for diagnostics With this, `clang-cl /source-charset:utf-16 test.cc` now prints `invalid value 'utf-16' in '/source-charset:utf-16'` instead of `invalid value 'utf-16' in '-finput-charset=utf-16'` before, and several other clang-cl flags produce much less confusing output as well. Fixes PR29106. Since an arg and its alias can have different arg types (joined vs not) and different values (because of AliasArgs<>), I chose to give the Alias its own Arg object. For convenience, I just store the alias directly in the unaliased arg – there aren't many arg objects at runtime, so that seems ok. Finally, I changed Arg::getAsString() to use the alias's representation if it's present – that function was already documented as being the suitable function for diagnostics, and most callers already used it for diagnostics. Implementation-wise, Arg::accept() previously used to parse things as the unaliased option. The core of that switch is now extracted into a new function acceptInternal() which parses as the _aliased_ option, and the previously-intermingled unaliasing is now done as an explicit step afterwards. (This also changes one place in lld that didn't use getAsString() for diagnostics, so that that one place now also prints the flag as the user wrote it, not as it looks after it went through unaliasing.) Differential Revision: https://reviews.llvm.org/D64253 llvm-svn: 365413
* [lld] Allow args::getInterger to parse args larger than 2^31-1Sam Clegg2019-06-071-2/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D62933 llvm-svn: 362770
* Fail early if an output file is not writableRui Ueyama2019-03-112-0/+100
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=36478 Differential Revision: https://reviews.llvm.org/D43664 llvm-svn: 355834
* Remove a function from header and move the implementation to a .cpp file. NFC.Rui Ueyama2019-02-221-6/+0
| | | | llvm-svn: 354703
* Update `ld.lld --version` string for monorepo.Rui Ueyama2019-02-212-25/+36
| | | | | | | | | | | | | | | | | This patch basically does the same thing as https://reviews.llvm.org/rL352729 did to clang. With this patch, lld now prints out a correct version string including a git commit id like this: $ bin/ld.lld --version LLD 9.0.0 (https://github.com/llvm/llvm-project.git c027658504fa9e68173f53dedaf223695a65e910) (compatible with GNU linkers) Fixes https://bugs.llvm.org/show_bug.cgi?id=40780 Differential Revision: https://reviews.llvm.org/D58411 llvm-svn: 354605
* Fix names of functions in TargetOptionsCommandFlags.h. NFC.Sam Clegg2019-02-011-5/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D57555 llvm-svn: 352825
* [LTO] Set CGOptLevel in LTO config.Sam Clegg2019-01-301-0/+9
| | | | | | | | | Previously we were never setting this which means it was always being set to Default (-O2/-Os). Differential Revision: https://reviews.llvm.org/D57422 llvm-svn: 352667
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-199-36/+27
| | | | | | | | | | | | | | | | | 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
* Set MAttrs in LTO modeFangrui Song2018-11-011-0/+1
| | | | | | | | | | | | | | | | Summary: Without this patch, MAttrs are not set. Patch by Yin Ma Reviewers: espindola, MaskRay, ruiu, pcc Reviewed By: MaskRay, pcc Subscribers: pcc, emaste, sbc100, inglorion, arichardson, aheejin, steven_wu, llvm-commits Differential Revision: https://reviews.llvm.org/D53446 llvm-svn: 345884
* Allow later -z name=<int> args to override earlier argsRyan Prichard2018-09-261-1/+1
| | | | | | | | | | | | | | | | | | Summary: lld already gives later -z options precedence in getZFlag(). This matches the behavior of ld.bfd and ld.gold, where later options override earlier ones. (I tested with -z max-page-size and -z stack-size.) Reviewers: ruiu, espindola, grimar Reviewed By: ruiu, grimar Subscribers: grimar, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D52526 llvm-svn: 343145
* lld-link: Also demangle undefined dllimported symbols.Nico Weber2018-09-171-1/+7
| | | | | | | | | dllimported symbols go through an import stub that's called __imp_ followed by the name the stub points to. Make that work. Differential Revision: https://reviews.llvm.org/D52145 llvm-svn: 342401
* lld-link: print demangled symbol names for "undefined symbol" diagnosticsNico Weber2018-09-151-20/+9
| | | | | | | | | | | | | | | | | For this, add a few toString() calls when printing the "undefined symbol" diagnostics; toString() already does demangling on Windows hosts. Also make lld::demangleMSVC() (called by toString(Symbol*)) call LLVM's microsoftDemangle() instead of UnDecorateSymbolName() so that it works on non-Windows hosts – this makes both updating tests easier and provides a better user experience for people doing cross-links. This doesn't yet do the right thing for symbols starting with __imp_, but that can be improved in a follow-up. Differential Revision: https://reviews.llvm.org/D52104 llvm-svn: 342332
* Rename a function to follow the LLVM coding style.Rui Ueyama2018-08-271-1/+1
| | | | llvm-svn: 340716
* [Common] Discard the temp file while keeping the memory mapping open, on errorsMartin Storsjo2018-08-241-2/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D51095 llvm-svn: 340635
* win: Omit ".exe" from lld warning and error messages.Nico Weber2018-08-221-0/+7
| | | | | | | | | | | 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
* [LTO] Errors in LLVM backend should manifest as lld errorsSam Clegg2018-07-021-1/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D48812 llvm-svn: 336143
* Code cleanup in preparation for adding LTO for wasm. NFC.Sam Clegg2018-05-222-1/+24
| | | | | | | | | | | | | | - Move some common code into Common/rrorHandler.cpp and Common/Strings.h. - Don't use `fatal` when incompatible bitcode files are encountered. - Rename NameRef variable to just Name See D47162 Differential Revision: https://reviews.llvm.org/D47206 llvm-svn: 333021
* CommandFlags.def -> CommandFlags.inc, leftover after r329840Fangrui Song2018-05-221-2/+2
| | | | llvm-svn: 332951
* Handle --plugin-opt= options as alias options.Rui Ueyama2018-05-221-7/+11
| | | | | | | | | | 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
* Rename to match an LLVM changeDavid Blaikie2018-04-111-1/+1
| | | | llvm-svn: 329841
* Make sure that clang-format doesn't reorder include files.Rui Ueyama2018-02-281-0/+2
| | | | | | | clang-format won't reorder include files if there is a blank line. Thanks to Nico for the tips. llvm-svn: 326371
* Attempt to build breakage caused by r326339.Rui Ueyama2018-02-281-1/+1
| | | | | | | clang-format automatically sorted the #include lines, but I believe Windows.h needs to be included before Dbghelp.h. llvm-svn: 326360
* Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp.Rui Ueyama2018-02-281-0/+66
| | | | | | | | | This should resolve the issue that lld build fails in some hosts that uses case-insensitive file system. Differential Revision: https://reviews.llvm.org/D43788 llvm-svn: 326339
* Pass CPU string to LTO pipeline.Rafael Espindola2018-01-301-0/+2
| | | | | | | | | | Previously an empty CPU string was passed to the LTO engine which resulted in a generic CPU for which certain features like NOPL were disabled. This fixes that. Patch by Pratik Bhatu! llvm-svn: 323801
* Add a missing file header.Rui Ueyama2018-01-181-0/+9
| | | | llvm-svn: 322909
OpenPOWER on IntegriCloud