[lld] [LLD] [COFF] Explicitly prefer def files and export directives over /export-all-symbols (PR #190749)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 02:56:29 PDT 2026


================
@@ -1264,11 +1286,22 @@ void SymbolTable::fixupExports() {
     // If the existing export comes from .OBJ directives, we are allowed to
     // overwrite it with /DEF: or /EXPORT without any warning, as MSVC link.exe
     // does.
-    if (existing->source == ExportSource::Directives) {
+    // Also silently override exports from /export-all-symbols with ones from
+    // def files and /EXPORT.
+    int existingPriority = exportSourcePriority(existing->source);
+    int newPriority = exportSourcePriority(e.source);
+    if (existingPriority < newPriority) {
+      // New definition with higher priority; don't warn, and replace the
+      // existing definition with this one.
       *existing = e;
       v[pair.first->second.second] = e;
       continue;
+    } else if (existingPriority > newPriority) {
----------------
cjacek wrote:

The `else` here is redundant (I think this is essentially https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return). The patch looks good to me otherwise.

https://github.com/llvm/llvm-project/pull/190749


More information about the llvm-commits mailing list