Skip to content

Commit 73e575a

Browse files
committed
[lld][WebAssembly] Give better error message on bad archive member
Include the archive name as well as the member name when an error is encountered parsing bitcode archives. Differential Revision: https://reviews.llvm.org/D82884
1 parent c758644 commit 73e575a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lld/test/wasm/lto/incompatible.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
; RUN: llvm-as %s -o %t.bc
33
; RUN: not wasm-ld %t.bc -o %t.wasm 2>&1 | FileCheck %s
44

5+
; RUN: llvm-ar rc %t.a %t.bc
6+
; RUN: not wasm-ld --whole-archive %t.a -o %t.wasm 2>&1 | FileCheck %s --check-prefix=CHECK-ARCHIVE
7+
58
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
69
target triple = "x86_64-unknown-linux-gnu"
710

811
; CHECK: {{.*}}incompatible.ll.tmp.bc: machine type must be wasm32
12+
; CHECK-ARCHIVE: wasm-ld: error: {{.*}}.a(incompatible.ll.tmp.bc): machine type must be wasm32

lld/test/wasm/lto/libcall-truncsfhf2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ define void @_start() {
1717
ret void
1818
}
1919

20-
; CHECK: wasm-ld: error: {{.*}}truncsfhf2.o: attempt to add bitcode file after LTO.
20+
; CHECK: wasm-ld: error: {{.*}}truncsfhf2.o): attempt to add bitcode file after LTO.

lld/wasm/InputFiles.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,15 @@ bool BitcodeFile::doneLTO = false;
569569

570570
void BitcodeFile::parse() {
571571
if (doneLTO) {
572-
error(toString(mb.getBufferIdentifier()) +
573-
": attempt to add bitcode file after LTO.");
572+
error(toString(this) + ": attempt to add bitcode file after LTO.");
574573
return;
575574
}
576575

577576
obj = check(lto::InputFile::create(MemoryBufferRef(
578577
mb.getBuffer(), saver.save(archiveName + mb.getBufferIdentifier()))));
579578
Triple t(obj->getTargetTriple());
580579
if (t.getArch() != Triple::wasm32) {
581-
error(toString(mb.getBufferIdentifier()) + ": machine type must be wasm32");
580+
error(toString(this) + ": machine type must be wasm32");
582581
return;
583582
}
584583
std::vector<bool> keptComdats;

0 commit comments

Comments
 (0)