summaryrefslogtreecommitdiffstats
path: root/lld/MinGW/Driver.cpp
Commit message (Collapse)AuthorAgeFilesLines
* LLD: Don't use the stderrOS stream in link before it's reassigned.James Y Knight2019-11-211-1/+2
| | | | | | | | | | | | | | | | 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-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use error instead of fatal to report usage errorsRui Ueyama2019-10-101-6/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D68768 llvm-svn: 374297
* [LLD] [MinGW] Look for other library patterns with -lMartin Storsjo2019-10-101-3/+25
| | | | | | | | | | | | | | | | | GNU ld looks for a number of other patterns than just lib<name>.dll.a and lib<name>.a. GNU ld does support linking directly against a DLL without using an import library. If that's the only match for a -l argument, point out that the user needs to use an import library, instead of leaving the user with a puzzling message about the -l argument not being found at all. Also convert an existing case of fatal() into error(). Differential Revision: https://reviews.llvm.org/D68689 llvm-svn: 374292
* [MinGW] Add --reproduce optionRui Ueyama2019-10-041-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D68382 llvm-svn: 373705
* [MinGW] Add an lld specific option for requesting to delay load librariesMartin Storsjo2019-08-051-0/+2
| | | | | | | | | | | | | With GNU tools, delayload is handled completely differently. (One creates a specific delayload import library using dlltool and then links against it instead of the normal import library.) Instead of requiring using -Xlink=-delayload:lib.dll, we can provide an lld specific option for this. Differential Revision: https://reviews.llvm.org/D65728 llvm-svn: 367837
* [Coding style change][lld] Rename variables for non-ELF portsRui Ueyama2019-07-111-175/+175
| | | | | | | | | | | 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
* lld, llvm-dlltool, llvm-lib: Use getAsString() instead of getSpelling() for ↵Nico Weber2019-07-051-1/+1
| | | | | | | | | | | | | | | printing unknown args Since OPT_UNKNOWN args never have any values and consist only of spelling (and are never aliased), this doesn't make any difference in practice, but it's more consistent with Arg's guidance to use getAsString() for diagnostics, and it matches what clang does. Also tweak two tests to use an unknown option that contains '=' for additional coverage while here. (The new tests pass fine with the old code too though.) llvm-svn: 365200
* Make joined instances of JoinedOrSeparate flags point to the unaliased args, ↵Nico Weber2019-07-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | like all other arg types do This fixes an 8-year-old regression. r105763 made it so that aliases always refer to the unaliased option – but it missed the "joined" branch of JoinedOrSeparate flags. (r162231 then made the Args classes non-virtual, and r169344 moved them from clang to llvm.) Back then, there was no JoinedOrSeparate flag that was an alias, so it wasn't observable. Now /U in CLCompatOptions is a JoinedOrSeparate alias in clang, and warn_slash_u_filename incorrectly used the aliased arg id (using the unaliased one isn't really a regression since that warning checks if the undefined macro contains slash or backslash and only then emits the warning – and no valid use will pass "-Ufoo/bar" or similar). Also, lld has many JoinedOrSeparate aliases, and due to this bug it had to explicitly call `getUnaliasedOption()` in a bunch of places, even though that shouldn't be necessary by design. After this fix in Option, these calls really don't have an effect any more, so remove them. No intended behavior change. (I accidentally fixed this bug while working on PR29106 but then wondered why the warn_slash_u_filename broke. When I figured it out, I thought it would make sense to land this in a separate commit.) Differential Revision: https://reviews.llvm.org/D64156 llvm-svn: 365186
* [MinGW] Support the --{major,minor}-{os,subsystem}-version optionsMartin Storsjo2019-06-141-1/+24
| | | | | | | | This fixes PR42218. Differential Revision: https://reviews.llvm.org/D63249 llvm-svn: 363432
* [Driver] Look for -m in response files as wellMartin Storsjo2019-06-101-0/+9
| | | | | | | | | | Also expand response files in the MinGW driver. This should fix PR42135. Differential Revision: https://reviews.llvm.org/D63024 llvm-svn: 362977
* [MinGW] Support the -u/--undefined option.Martin Storsjo2019-06-081-0/+2
| | | | | | | | | | | | This is implemented by the lld-link option -include:, just like --require-defined. Contrary to --require-defined, the -u/--undefined option allows the symbol to remain undefined in the end. This should fix PR42121. Differential Revision: https://reviews.llvm.org/D62876 llvm-svn: 362882
* [MinGW] Implement the -v and --version flags for the MinGW driverMartin Storsjo2019-05-171-0/+16
| | | | | | Differential Revision: https://reviews.llvm.org/D62030 llvm-svn: 361016
* [MinGW] Implement --help for the MinGW driverMartin Storsjo2019-05-171-2/+15
| | | | | | Differential Revision: https://reviews.llvm.org/D62029 llvm-svn: 361015
* [MinGW] Allow requesting PDB output without giving a file nameMartin Storsjo2019-05-171-1/+3
| | | | | | | | | | | | | | | | | | | | | When integrating PDB output in mingw targeting build systems, it might be a lot of extra work to specify unique file names for the pdb output. Therefore allow omitting the actual file name and let it implicitly be the same name as the linker output, with a pdb extension. As the current form of the pdb option takes a separate parameter value, e.g. "-pdb out.pdb", it is impractical to leave out the parameter value. Therefore, introduce a second syntax for the option, with an equals sign, like -pdb=out.pdb, where the value easily can be omitted. The form -pdb= for requesting pdb files with an implicit name should work fine, even though it looks a bit unconventional in that form. Differential Revision: https://reviews.llvm.org/D62004 llvm-svn: 361014
* [MinGW] Add an --appcontainer flag, passed through to lld-linkMartin Storsjo2019-04-191-0/+2
| | | | | | | | | GNU ld doesn't have such a flag though, so this is a lld specific option. Differential Revision: https://reviews.llvm.org/D60860 llvm-svn: 358759
* [MinGW] Hook up the --exclude-all-symbols optionMartin Storsjo2019-02-191-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D58380 llvm-svn: 354387
* [MinGW] Add --insert-timestamp as complement to the --no-insert-timestamp optionMartin Storsjo2019-02-061-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D57808 llvm-svn: 353342
* [MinGW] Hook up the --no-insert-timestamp optionMartin Storsjo2019-02-051-0/+3
| | | | | | | | | | This fixes PR40582. Patch by Georg Koppen! Differential Revision: https://reviews.llvm.org/D57679 llvm-svn: 353145
* 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
* [MinGW] Expand comment for MinGW driver. NFC.Martin Storsjo2019-01-051-3/+21
| | | | | | | | Originally authored by Rui Ueyama. Differential Revision: https://reviews.llvm.org/D53031 llvm-svn: 350464
* [MinGW] Pass libpath to the COFF linkerMartin Storsjo2018-10-101-1/+3
| | | | | | | | | This is necessary for handling defaultlib directives embedded in object files, unless they use an absolute path. Differential Revision: https://reviews.llvm.org/D53015 llvm-svn: 344123
* [MinGW] Hook up the --require-defined option to -include:Martin Storsjo2018-09-101-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D51840 llvm-svn: 341846
* [MinGW] Implement the GNU ld options -S/--strip-debugMartin Storsjo2018-06-291-0/+2
| | | | | | | | | In this mode, we retain the symbol table, but skip the actual debug information. Differential Revision: https://reviews.llvm.org/D48745 llvm-svn: 335947
* [MinGW] Handle the GNU ld option -Map for outputting a linker mapMartin Storsjo2018-05-151-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D46872 llvm-svn: 332398
* [MinGW] Add a LLD specific option -pdbMartin Storsjo2018-05-151-2/+7
| | | | | | | | | This allows producing pdb debug info. This is an LLD specific option since GCC and GNU binutils doesn't support the PDB file format. Differential Revision: https://reviews.llvm.org/D46796 llvm-svn: 332327
* [MinGW] Add support for the GNU ld flag --kill-atMartin Storsjo2018-03-141-0/+2
| | | | llvm-svn: 327562
* Use the standard error handling mechanism in MinGW driver.Rui Ueyama2017-12-121-12/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D41127 llvm-svn: 320526
* [MinGW] Don't pass -dynamicbase:no by default for arm/arm64Martin Storsjo2017-12-121-1/+3
| | | | | | | | | | | The linker refuses using -dynamicbase:no on these architectures. Stop passing -dynamicbase (which just reinforces the lld-link default) for simplicity. Differential Revision: https://reviews.llvm.org/D41052 llvm-svn: 320518
* [MinGW] Implement the --[no-]gc-sections and --icf optionsMartin Storsjo2017-11-151-0/+17
| | | | | | | | | GNU ld doesn't seem to support --icf at all, but this was suggested in D39885, and GNU gold seems to support it. Differential Revision: https://reviews.llvm.org/D40019 llvm-svn: 318283
* [MinGW] Implement support for the --image-base optionMartin Storsjo2017-11-151-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D40018 llvm-svn: 318282
* [MinGW] Add support for --dynamicbase, ignore --nxcompat, --tsaware and ↵Martin Storsjo2017-11-151-0/+2
| | | | | | | | | | | | | | | --high-entropy-va All of these are disabled by default in GNU ld, but enabled by default in lld. Disable dynamicbase by default since it potentially could cause compatibility issues, but just ignore the others since the lld default should be fine for most concievable cases. Differential Revision: https://reviews.llvm.org/D40017 llvm-svn: 318281
* [MinGW] Handle --large-address-awareMartin Storsjo2017-11-151-0/+2
| | | | | | | | | In GNU ld, this option is only available on i386, not on x86_64 (where it's enabled by default with no option to disable it either). Differential Revision: https://reviews.llvm.org/D40015 llvm-svn: 318280
* [MinGW] Output debug info by default, unless the -s parameter is passedMartin Storsjo2017-11-031-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D39541 llvm-svn: 317376
* [MinGW] Add an option -Xlink for passing options through to lld-linkMartin Storsjo2017-11-031-0/+3
| | | | | | | | | Also move the -mllvm option to the right section of the options list. Differential Revision: https://reviews.llvm.org/D39528 llvm-svn: 317302
* lld::COFF: better behavior when using as a libraryRui Ueyama2017-10-231-1/+1
| | | | | | | | | | | | | | | Previously, the COFF driver would call exit(0) when called as a library. Now it takes `ExitEarly` option, and if it is false, it doesn't exit. So it is now more library-friendly. Furthermore, link() calls freeArena() before returning, to clean up resources. Based on an Andrew Kelley's patch. Differential Revision: https://reviews.llvm.org/D39202 llvm-svn: 316370
* [MinGW] Hook up the --export-all-symbols and --output-def optionsMartin Storsjo2017-10-121-0/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D38761 llvm-svn: 315563
* Fix another build breakage.Rui Ueyama2017-10-021-1/+1
| | | | llvm-svn: 314730
* Filenames are case-insensitive on Windows, so .DEF is the same as .def.Rui Ueyama2017-09-141-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D37823 llvm-svn: 313285
* Do not use hasArgNoClaim().Rui Ueyama2017-09-131-1/+1
| | | | | | | | | Arg instances can be claimed. After claimed, its `isClaimed` function returns true. We do not use that notion in lld, so using NoClaim versions of functions is just confusing. This patch is to just use hasArg instead of hasArgNoClaim. llvm-svn: 313187
* Use getUnaliasedOption so that this switch works for option aliases.Rui Ueyama2017-09-131-1/+1
| | | | | | | There are no alises handled by this switch, but getUnaliasesdOption is preferred way of doing this. This is also consistent with ELF and COFF. llvm-svn: 313180
* Move a piece of code above some local variable definitions to make their ↵Rui Ueyama2017-09-131-3/+2
| | | | | | scope narrower. llvm-svn: 313178
* [MinGW] Only apply -Bstatic to following librariesMartin Storsjo2017-09-131-4/+9
| | | | | | | | | This is how the flag is documented in GNU binutils ld; -Bstatic only applies to -l options after it, until the next -Bdynamic. Differential Revision: https://reviews.llvm.org/D37794 llvm-svn: 313175
* [MinGW] Support dllexport on i386Martin Storsjo2017-09-131-0/+1
| | | | | | | | | | | | In MinGW configurations (GCC, or clang with a *-windows-gnu target), the -export directives in the object file contains the undecorated symbol name, while it is decorated in MSVC configurations. (On the command line, link.exe takes an undecorated symbol name for the -export argument though.) Differential Revision: https://reviews.llvm.org/D37772 llvm-svn: 313174
* [MinGW] Support creating DLLs with a def fileMartin Storsjo2017-09-131-1/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D37761 llvm-svn: 313125
* [MinGW] Add support for the options --[no-]whole-archiveMartin Storsjo2017-09-131-5/+18
| | | | | | Differential Revision: https://reviews.llvm.org/D37769 llvm-svn: 313124
* [MinGW] Pass the undecorated entry point name to the COFF linkerMartin Storsjo2017-09-121-2/+8
| | | | | | | | | On i386, the --entry parameter to GNU ld is supposed to be a decorated symbol name, while it is an undecorated name in link.exe. Differential Revision: https://reviews.llvm.org/D37710 llvm-svn: 313066
* Reorder functions so that related functions come closer.Rui Ueyama2017-09-111-19/+19
| | | | llvm-svn: 312964
* Rename COFFLdOptTable MinGWOptTable for consistency.Rui Ueyama2017-09-111-4/+4
| | | | llvm-svn: 312963
* Make the scope of an anonymous namespace as narrow as possible.Rui Ueyama2017-09-111-4/+2
| | | | llvm-svn: 312962
OpenPOWER on IntegriCloud