[ELF] - Report proper error message about mixing bitcode files.
authorGeorge Rimar <grimar@accesssoftek.com>
Wed, 11 Jul 2018 12:32:00 +0000 (12:32 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Wed, 11 Jul 2018 12:32:00 +0000 (12:32 +0000)
If we have 2 bitcode inputs for different targets, LLD would
print "<internal>" instead of the name of one of the files.

The patch adds a test and fixes this issue.

llvm-svn: 336794

lld/ELF/SymbolTable.cpp
lld/test/ELF/lto/Inputs/i386-empty.ll [new file with mode: 0644]
lld/test/ELF/lto/mix-platforms2.ll [new file with mode: 0644]

index 13af40a..c52ec8f 100644 (file)
@@ -38,7 +38,7 @@ static InputFile *getFirstElf() {
     return ObjectFiles[0];
   if (!SharedFiles.empty())
     return SharedFiles[0];
-  return nullptr;
+  return BitcodeFiles[0];
 }
 
 // All input object files must be for the same architecture
diff --git a/lld/test/ELF/lto/Inputs/i386-empty.ll b/lld/test/ELF/lto/Inputs/i386-empty.ll
new file mode 100644 (file)
index 0000000..6029cb6
--- /dev/null
@@ -0,0 +1,2 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "i686-linux-gnu"
diff --git a/lld/test/ELF/lto/mix-platforms2.ll b/lld/test/ELF/lto/mix-platforms2.ll
new file mode 100644 (file)
index 0000000..1bd989e
--- /dev/null
@@ -0,0 +1,9 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %tx64.o
+; RUN: llvm-as %S/Inputs/i386-empty.ll -o %ti386.o
+; RUN: not ld.lld %ti386.o %tx64.o -o %t.out 2>&1 | FileCheck %s
+
+; CHECK: {{.*}}x64.o is incompatible with {{.*}}i386.o
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"