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
--- /dev/null
+# 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:
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