[lld] a414044 - [lld/mac] Abort link immediately on invalid -undefined argument
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 05:31:09 PST 2022
Author: Nico Weber
Date: 2022-12-08T08:30:59-05:00
New Revision: a414044012920059ac4bfd2756669f2fca3a4b99
URL: https://github.com/llvm/llvm-project/commit/a414044012920059ac4bfd2756669f2fca3a4b99
DIFF: https://github.com/llvm/llvm-project/commit/a414044012920059ac4bfd2756669f2fca3a4b99.diff
LOG: [lld/mac] Abort link immediately on invalid -undefined argument
I tried `-undefined suppress` without `-flat_namespace`.
lld printed `'-undefined suppress' only valid with '-flat_namespace'`
followed by many many screenfuls of error messages about undefined
symbols, making the original diag hard to see.
This is probably the common case when using `-undefined`, so let's
just abort the link immediately when there's an invalid `-undefined`
arg.
Differential Revision: https://reviews.llvm.org/D139559
Added:
Modified:
lld/MachO/Driver.cpp
lld/test/MachO/treat-undef-sym.s
Removed:
################################################################################
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index a42c1af6078ce..74a1311d54313 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -765,9 +765,9 @@ getUndefinedSymbolTreatment(const ArgList &args) {
(treatment == UndefinedSymbolTreatment::warning ||
treatment == UndefinedSymbolTreatment::suppress)) {
if (treatment == UndefinedSymbolTreatment::warning)
- error("'-undefined warning' only valid with '-flat_namespace'");
+ fatal("'-undefined warning' only valid with '-flat_namespace'");
else
- error("'-undefined suppress' only valid with '-flat_namespace'");
+ fatal("'-undefined suppress' only valid with '-flat_namespace'");
treatment = UndefinedSymbolTreatment::error;
}
return treatment;
diff --git a/lld/test/MachO/treat-undef-sym.s b/lld/test/MachO/treat-undef-sym.s
index 8f5e82d0e282f..b757e04b93278 100644
--- a/lld/test/MachO/treat-undef-sym.s
+++ b/lld/test/MachO/treat-undef-sym.s
@@ -43,10 +43,10 @@
# ERROR-NEXT: >>> referenced by
# INVAL-WARNING: error: '-undefined warning' only valid with '-flat_namespace'
-# INVAL-WARNING-NEXT: error: undefined symbol: _bar
+# INVAL-WARNING-NOT: error: undefined symbol: _bar
# INVAL-SUPPRESS: error: '-undefined suppress' only valid with '-flat_namespace'
-# INVAL-SUPPRESS-NEXT: error: undefined symbol: _bar
+# INVAL-SUPPRESS-NOT: error: undefined symbol: _bar
# WARNING: warning: undefined symbol: _bar
# WARNING-NEXT: >>> referenced by
More information about the llvm-commits
mailing list