[PATCH] D82884: [lld][WebAssembly] Give better error message on bad archive member

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 08:40:37 PDT 2020


sbc100 created this revision.
Herald added subscribers: llvm-commits, dexonsmith, steven_wu, sunfish, aheejin, hiraditya, jgravelle-google, dschuff.
Herald added a project: LLVM.

Include the archive name as well as the member name when an error
is encountered parsing bitcode archives.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82884

Files:
  lld/test/wasm/lto/incompatible.ll
  lld/test/wasm/lto/libcall-truncsfhf2.ll
  lld/wasm/InputFiles.cpp


Index: lld/wasm/InputFiles.cpp
===================================================================
--- lld/wasm/InputFiles.cpp
+++ lld/wasm/InputFiles.cpp
@@ -569,8 +569,7 @@
 
 void BitcodeFile::parse() {
   if (doneLTO) {
-    error(toString(mb.getBufferIdentifier()) +
-          ": attempt to add bitcode file after LTO.");
+    error(toString(this) + ": attempt to add bitcode file after LTO.");
     return;
   }
 
@@ -578,7 +577,7 @@
       mb.getBuffer(), saver.save(archiveName + mb.getBufferIdentifier()))));
   Triple t(obj->getTargetTriple());
   if (t.getArch() != Triple::wasm32) {
-    error(toString(mb.getBufferIdentifier()) + ": machine type must be wasm32");
+    error(toString(this) + ": machine type must be wasm32");
     return;
   }
   std::vector<bool> keptComdats;
Index: lld/test/wasm/lto/libcall-truncsfhf2.ll
===================================================================
--- lld/test/wasm/lto/libcall-truncsfhf2.ll
+++ lld/test/wasm/lto/libcall-truncsfhf2.ll
@@ -17,4 +17,4 @@
   ret void
 }
 
-; CHECK: wasm-ld: error: {{.*}}truncsfhf2.o: attempt to add bitcode file after LTO.
+; CHECK: wasm-ld: error: {{.*}}truncsfhf2.o): attempt to add bitcode file after LTO.
Index: lld/test/wasm/lto/incompatible.ll
===================================================================
--- lld/test/wasm/lto/incompatible.ll
+++ lld/test/wasm/lto/incompatible.ll
@@ -2,7 +2,11 @@
 ; RUN: llvm-as %s -o %t.bc
 ; RUN: not wasm-ld %t.bc -o %t.wasm 2>&1 | FileCheck %s
 
+; RUN: llvm-ar rc %t.a %t.bc
+; RUN: not wasm-ld --whole-archive %t.a -o %t.wasm 2>&1 | FileCheck %s --check-prefix=CHECK-ARCHIVE
+
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
 ; CHECK: {{.*}}incompatible.ll.tmp.bc: machine type must be wasm32
+; CHECK-ARCHIVE: wasm-ld: error: {{.*}}.a(incompatible.ll.tmp.bc): machine type must be wasm32


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82884.274502.patch
Type: text/x-patch
Size: 1927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200630/30ca4aff/attachment-0001.bin>


More information about the llvm-commits mailing list