From e3f21d4781b22666652da342ef514777e472f2ed Mon Sep 17 00:00:00 2001 From: A2uria Date: Wed, 26 Feb 2025 11:16:52 +0800 Subject: [PATCH 1/2] [LLD][COFF] Add /noexp for link.exe compatibility --- lld/COFF/Options.td | 1 + 1 file changed, 1 insertion(+) diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td index b6fd3d0daaef9..4e401a5fd1d6d 100644 --- a/lld/COFF/Options.td +++ b/lld/COFF/Options.td @@ -342,6 +342,7 @@ def fastfail : F<"fastfail">; def kernel : F<"kernel">; def pdbcompress : F<"pdbcompress">; def emitpogophaseinfo : F<"emitpogophaseinfo">; +def noexp : F<"noexp">; def delay : P_priv<"delay">; def errorreport : P_priv<"errorreport">; From ff02813799d7d9e1cff0826ed1162c901ace9a2a Mon Sep 17 00:00:00 2001 From: A2uria Date: Wed, 26 Feb 2025 11:23:14 +0800 Subject: [PATCH 2/2] [LLD][COFF] Rebuild nodefaultlibs after updating search paths Fix #107346 --- lld/COFF/Driver.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 1589323073c09..086ec83cc5206 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -786,6 +786,13 @@ void LinkerDriver::addWinSysRootLibSearchPaths() { path)) searchPaths.push_back(saver().save(path)); } + + // Libraries specified by `/nodefaultlib:` may not be found in incomplete + // search paths before lld infers a machine type from input files. + std::set noDefaultLibs; + for (const std::string &path : ctx.config.noDefaultLibs) + noDefaultLibs.insert(findLib(path).lower()); + ctx.config.noDefaultLibs = noDefaultLibs; } // Parses LIB environment which contains a list of search paths.