[PATCH] D120689: [lld][WebAssembly] Improve error reporting for bad ar archive members
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 28 16:33:48 PST 2022
sbc100 created this revision.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, dschuff.
sbc100 requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
Show the name of of the archive in the error message as well as the name
of the object within it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D120689
Files:
lld/test/wasm/bad-archive-member.s
lld/wasm/InputFiles.cpp
Index: lld/wasm/InputFiles.cpp
===================================================================
--- lld/wasm/InputFiles.cpp
+++ lld/wasm/InputFiles.cpp
@@ -87,7 +87,12 @@
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
Index: lld/test/wasm/bad-archive-member.s
===================================================================
--- /dev/null
+++ lld/test/wasm/bad-archive-member.s
@@ -0,0 +1,10 @@
+# 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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120689.411927.patch
Type: text/x-patch
Size: 1106 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220301/4e893911/attachment-0001.bin>
More information about the llvm-commits
mailing list