[lld] Improve readability of "undefined reference" message (PR #82671)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 10:22:53 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld-elf

Author: None (DeanSturtevant1)

<details>
<summary>Changes</summary>

The current message implies a command line flag caused an undefined reference. This of course is wrong and causes confusion. The message now more accurately reflects the true state of affairs.

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


1 Files Affected:

- (modified) lld/ELF/Writer.cpp (+3-2) 


``````````diff
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 0bbf43ddf694aa..cf8825296213b2 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -2057,8 +2057,9 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
           if (sym->dsoDefined)
             continue;
           if (sym->isUndefined() && !sym->isWeak()) {
-            diagnose("undefined reference due to --no-allow-shlib-undefined: " +
-                     toString(*sym) + "\n>>> referenced by " + toString(file));
+            diagnose("undefined reference: " +
+                     toString(*sym) + "\n>>> referenced by " + toString(file) +
+                     " (disallowed by --no-allow-shlib-undefined)");
           } else if (sym->isDefined() && sym->computeBinding() == STB_LOCAL) {
             diagnose("non-exported symbol '" + toString(*sym) + "' in '" +
                      toString(sym->file) + "' is referenced by DSO '" +

``````````

</details>


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


More information about the llvm-commits mailing list