From eb14186771e7bca992c043637aac3ed7104eaa1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 17 Feb 2023 11:25:12 +0200 Subject: [PATCH] Revert "[LLD] [COFF] Don't try to detect MSVC installations in mingw mode" This reverts commit 389bfbd66d6f78b5fc60e51e620e7f767fc867f0. This commit broke the compiler-rt/test/profile/Windows/coverage-weak-lld.cpp testcase. This testcase builds and links in an MSVC environment, but explicitly passes -lldmingw to the linker, to opt in to certain mingw-style behaviours regarding weak symbols, since effb87dfa810a28e763f914fe3e6e984782cc846. This patch broke that test, which now errored out with these errors: lld-link: error: could not open 'libuuid.a': no such file or directory lld-link: error: could not open 'libLIBCMT.a': no such file or directory lld-link: error: could not open 'libOLDNAMES.a': no such file or directory --- lld/COFF/Driver.cpp | 14 +++----------- lld/test/COFF/winsysroot.test | 9 +-------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 28fbacafe8bf..e0fc29879abe 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -1509,17 +1509,9 @@ void LinkerDriver::linkerMain(ArrayRef argsArr) { searchPaths.emplace_back(""); for (auto *arg : args.filtered(OPT_libpath)) searchPaths.push_back(arg->getValue()); - 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"); - } + detectWinSysRoot(args); + if (!args.hasArg(OPT_lldignoreenv) && !args.hasArg(OPT_winsysroot)) + addLibSearchPaths(); // Handle /ignore for (auto *arg : args.filtered(OPT_ignore)) { diff --git a/lld/test/COFF/winsysroot.test b/lld/test/COFF/winsysroot.test index bd76d4c9ccce..f09ceb5c9280 100644 --- a/lld/test/COFF/winsysroot.test +++ b/lld/test/COFF/winsysroot.test @@ -13,12 +13,5 @@ Check the same for a 64-bit input .obj. # RUN: /defaultlib:std64 /entry:main Check that when /winsysroot is specified, %LIB% is ignored. -# RUN: env LIB=%t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86 not lld-link %t.obj /winsysroot:%t.dir/doesnotexist /defaultlib:std32 2>&1 | FileCheck -check-prefix=LIBIGNORED %s +# RUN: env LIB=foo.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86 not lld-link %t.obj /winsysroot:%t.dir/doesnotexist /defaultlib:std32 2>&1 | FileCheck -check-prefix=LIBIGNORED %s LIBIGNORED: could not open 'std32.lib' - -Check that when -lldmingw is specified, %LIB% is ignored. -# RUN: env LIB=%t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86 not lld-link -lldmingw %t.obj /defaultlib:std32 2>&1 | FileCheck -check-prefix=LIBIGNORED_MINGW %s -LIBIGNORED_MINGW: could not open 'libstd32.a' - -# RUN: not lld-link -lldmingw %t.obj /defaultlib:std32 /winsysroot:%t.dir/sysroot 2>&1 | FileCheck -check-prefix=IGNORED_ARG %s -IGNORED_ARG: warning: ignoring /vctoolsdir or /winsysroot flags in MinGW mode