[lld] 1cf6ebc - [lld][WebAssembly] Improve error reporting for bad ar archive members
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 15:22:08 PST 2022
Author: Sam Clegg
Date: 2022-03-01T15:21:53-08:00
New Revision: 1cf6ebc0e9031a433eb8c40652c9904a53f537f7
URL: https://github.com/llvm/llvm-project/commit/1cf6ebc0e9031a433eb8c40652c9904a53f537f7
DIFF: https://github.com/llvm/llvm-project/commit/1cf6ebc0e9031a433eb8c40652c9904a53f537f7.diff
LOG: [lld][WebAssembly] Improve error reporting for bad ar archive members
Show the name of of the archive in the error message as well as the name
of the object within it.
Differential Revision: https://reviews.llvm.org/D120689
Added:
lld/test/wasm/bad-archive-member.s
Modified:
lld/wasm/InputFiles.cpp
Removed:
################################################################################
diff --git a/lld/test/wasm/bad-archive-member.s b/lld/test/wasm/bad-archive-member.s
new file mode 100644
index 0000000000000..029027a8517a3
--- /dev/null
+++ b/lld/test/wasm/bad-archive-member.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+
+# RUN: rm -rf %t.dir
+# RUN: mkdir -p %t.dir
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux -o %t.dir/elf.o %s
+# RUN: llvm-ar rcs %t.dir/libfoo.a %t.dir/elf.o
+# RUN: not wasm-ld %t.dir/libfoo.a -o /dev/null 2>&1 | FileCheck %s
+# CHECK: error: unknown file type: {{.*}}libfoo.a(elf.o)
+
+.globl _start
+_start:
diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp
index 1e69f16cc5f97..ebff723520291 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -87,7 +87,12 @@ InputFile *createObjectFile(MemoryBufferRef mb, StringRef archiveName,
if (magic == file_magic::bitcode)
return make<BitcodeFile>(mb, archiveName, offsetInArchive);
- fatal("unknown file type: " + mb.getBufferIdentifier());
+ std::string name = mb.getBufferIdentifier().str();
+ if (!archiveName.empty()) {
+ name = archiveName.str() + "(" + name + ")";
+ }
+
+ fatal("unknown file type: " + name);
}
// Relocations contain either symbol or type indices. This function takes a
More information about the llvm-commits
mailing list