Skip to content

[LLD][COFF] Rebuild nodefaultlibs after updating search paths and support /noexp #128808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

A2uria
Copy link
Contributor

@A2uria A2uria commented Feb 26, 2025

Fix #107346

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Feb 26, 2025

@llvm/pr-subscribers-platform-windows
@llvm/pr-subscribers-lld

@llvm/pr-subscribers-lld-coff

Author: None (A2uria)

Changes

Fix #107346


Full diff: https://github.com/llvm/llvm-project/pull/128808.diff

2 Files Affected:

  • (modified) lld/COFF/Driver.cpp (+7)
  • (modified) lld/COFF/Options.td (+1)
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<std::string> 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.
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">;

@A2uria A2uria deleted the branch llvm:main February 26, 2025 04:05
@A2uria A2uria closed this Feb 26, 2025
@A2uria A2uria deleted the main branch February 26, 2025 04:05
@A2uria
Copy link
Contributor Author

A2uria commented Feb 26, 2025

Not sure about "this branch must not contain merge commits", split into #128813 and #128814

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lld-link not respecting /NODEFAULTLIB with a conflicting /DEFAULTLIB
2 participants