[lld] c790d6f - [ELF] isCompatile: avoid a toStr and 2 ErrAlways
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 24 11:30:27 PST 2024
Author: Fangrui Song
Date: 2024-11-24T11:30:21-08:00
New Revision: c790d6f53f617b73c40d42a217c120023b9ab66f
URL: https://github.com/llvm/llvm-project/commit/c790d6f53f617b73c40d42a217c120023b9ab66f
DIFF: https://github.com/llvm/llvm-project/commit/c790d6f53f617b73c40d42a217c120023b9ab66f.diff
LOG: [ELF] isCompatile: avoid a toStr and 2 ErrAlways
Added:
Modified:
lld/ELF/InputFiles.cpp
lld/test/ELF/incompatible.s
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 14131dd9f765ce..07c8f1d1a679d8 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -284,7 +284,7 @@ static bool isCompatible(Ctx &ctx, InputFile *file) {
StringRef target =
!ctx.arg.bfdname.empty() ? ctx.arg.bfdname : ctx.arg.emulation;
if (!target.empty()) {
- ErrAlways(ctx) << file << " is incompatible with " << target;
+ Err(ctx) << file << " is incompatible with " << target;
return false;
}
@@ -295,10 +295,10 @@ static bool isCompatible(Ctx &ctx, InputFile *file) {
existing = ctx.sharedFiles[0];
else if (!ctx.bitcodeFiles.empty())
existing = ctx.bitcodeFiles[0];
- std::string with;
+ auto diag = Err(ctx);
+ diag << file << " is incompatible";
if (existing)
- with = " with " + toStr(ctx, existing);
- ErrAlways(ctx) << file << " is incompatible" << with;
+ diag << " with " << existing;
return false;
}
diff --git a/lld/test/ELF/incompatible.s b/lld/test/ELF/incompatible.s
index 39c25106f4d721..0d25acd857610b 100644
--- a/lld/test/ELF/incompatible.s
+++ b/lld/test/ELF/incompatible.s
@@ -6,11 +6,11 @@
// RUN: not ld.lld %ta.o %tb.o -o /dev/null 2>&1 | \
// RUN: FileCheck --check-prefix=A-AND-B %s
-// A-AND-B: b.o is incompatible with {{.*}}a.o
+// A-AND-B: error: {{.*}}b.o is incompatible with {{.*}}a.o
-// RUN: not ld.lld %tb.o %tc.o -o /dev/null 2>&1 | \
+// RUN: ld.lld --noinhibit-exec %tb.o %tc.o -o /dev/null 2>&1 | \
// RUN: FileCheck --check-prefix=B-AND-C %s
-// B-AND-C: c.o is incompatible with {{.*}}b.o
+// B-AND-C: warning: {{.*}}c.o is incompatible with {{.*}}b.o
// RUN: not ld.lld %ta.o %ti686.so -o /dev/null 2>&1 | \
// RUN: FileCheck --check-prefix=A-AND-SO %s
@@ -69,8 +69,8 @@
// RUN: rm -f %t.a
// RUN: llvm-ar rc %t.a %tc.o
// RUN: llvm-mc -filetype=obj -triple=i686-linux %s -o %td.o
-// RUN: not ld.lld %t.a %td.o 2>&1 -o /dev/null | FileCheck --check-prefix=ARCHIVE %s
-// ARCHIVE: {{.*}}d.o is incompatible
+// RUN: ld.lld --noinhibit-exec %t.a %td.o 2>&1 -o /dev/null | FileCheck --check-prefix=ARCHIVE %s
+// ARCHIVE: warning: {{.*}}d.o is incompatible{{$}}
.global _start
_start:
.data
More information about the llvm-commits
mailing list