summaryrefslogtreecommitdiff
path: root/lld/COFF
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2023-02-15 12:06:45 +0200
committerMartin Storsjö <martin@martin.st>2023-02-17 10:56:43 +0200
commit389bfbd66d6f78b5fc60e51e620e7f767fc867f0 (patch)
tree1b8c5d58deeca000c9baa03f90b2a24d5de25c5b /lld/COFF
parent3d84f4268dd9e1257e71938485fa23d17210ba44 (diff)
downloadllvm-389bfbd66d6f78b5fc60e51e620e7f767fc867f0.tar.gz
[LLD] [COFF] Don't try to detect MSVC installations in mingw mode
In mingw mode, all linker paths are passed explicitly to the linker by the compiler driver. Don't try to implicitly add linker paths from the LIB environment variable or by detecting an MSVC installation directory. If the /winsysroot command line parameter is explicitly passed to lld-link while /lldmingw is specified, it could be considered reasonable to actually include those paths. However, modifying the code to handle only the /winsysroot case but not the other ones, when the mingw mode has been enabled, seems like much more code complexity for a mostly hypothetical case. Add a test for this when case when using LIB. (The code paths for trying to detect an MSVC installation aren't really regression tested.) Also fix an issue in the existing test for "Check that when /winsysroot is specified, %LIB% is ignored.", where the LIB variable pointed to a nonexistent directory, so the test would pass even if /winsysroot wouldn't be specified. Differential Revision: https://reviews.llvm.org/D144084
Diffstat (limited to 'lld/COFF')
-rw-r--r--lld/COFF/Driver.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index e0fc29879abe..28fbacafe8bf 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1509,9 +1509,17 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
searchPaths.emplace_back("");
for (auto *arg : args.filtered(OPT_libpath))
searchPaths.push_back(arg->getValue());
- detectWinSysRoot(args);
- if (!args.hasArg(OPT_lldignoreenv) && !args.hasArg(OPT_winsysroot))
- addLibSearchPaths();
+ if (!config->mingw) {
+ // Don't automatically deduce the lib path from the environment or MSVC
+ // installations when operating in mingw mode. (This also makes LLD ignore
+ // winsysroot and vctoolsdir arguments.)
+ detectWinSysRoot(args);
+ if (!args.hasArg(OPT_lldignoreenv) && !args.hasArg(OPT_winsysroot))
+ addLibSearchPaths();
+ } else {
+ if (args.hasArg(OPT_vctoolsdir, OPT_winsysroot))
+ warn("ignoring /vctoolsdir or /winsysroot flags in MinGW mode");
+ }
// Handle /ignore
for (auto *arg : args.filtered(OPT_ignore)) {