xref: /llvm-project/llvm/test/tools/llvm-lib/machine-mismatch.test (revision be17209052aa49f43df69e1b8d55bae16f341ee0)
1*be172090SJacek CabanREQUIRES: aarch64-registered-target
2*be172090SJacek Caban
3d546b505SNico WeberPrepare inputs:
4d546b505SNico Weber
5d546b505SNico WeberRUN: rm -rf %t && mkdir -p %t
6d546b505SNico WeberRUN: llvm-mc -triple=i386-pc-windows-msvc -filetype=obj -o %t/i386.obj %S/Inputs/a.s
7d546b505SNico WeberRUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t/x86_64.obj %S/Inputs/a.s
8eb56ef3eSJacek CabanRUN: llvm-mc -triple=aarch64-pc-windows-msvc -filetype=obj -o %t/arm64.obj %S/Inputs/a.s
9eb56ef3eSJacek CabanRUN: llvm-mc -triple=arm64ec-pc-windows-msvc -filetype=obj -o %t/arm64ec.obj %S/Inputs/a.s
10d546b505SNico WeberRUN: llvm-as -o %t/i386.bc %S/Inputs/i386.ll
11d546b505SNico WeberRUN: llvm-as -o %t/x86_64.bc %S/Inputs/x86_64.ll
12d546b505SNico WeberRUN: llvm-as -o %t/arm64.bc %S/Inputs/arm64.ll
13cea5d287SJacek CabanRUN: yaml2obj -o %t/arm64x.obj %S/Inputs/arm64x.yaml
14d546b505SNico Weber
15d546b505SNico Weber
16d546b505SNico WeberMixing bitcode and normal object files with the same machine type is ok:
17d546b505SNico Weber
18d546b505SNico WeberRUN: llvm-lib %t/i386.obj %t/i386.bc
19d546b505SNico WeberRUN: llvm-lib %t/x86_64.obj %t/x86_64.bc
20d546b505SNico Weber
21d546b505SNico Weber
22d546b505SNico WeberAs is including resource files:
23d546b505SNico Weber
24c5d67b52SNico WeberRUN: llvm-lib /out:%t.lib %S/Inputs/resource.res %t/i386.obj %t/i386.bc
25c5d67b52SNico WeberRUN: llvm-lib /out:%t.lib %t/x86_64.obj %S/Inputs/resource.res %t/x86_64.bc
26d546b505SNico Weber
27d546b505SNico Weber
28d546b505SNico WeberMixing object files with different machine type is not ok:
29d546b505SNico Weber
30d546b505SNico WeberRUN: not llvm-lib %t/x86_64.obj %t/i386.obj 2>&1 | \
31d546b505SNico WeberRUN:     FileCheck --check-prefix=OBJ32 %s
32b941fa88SNico WeberOBJ32: i386.obj: file machine type x86 conflicts with library machine type x64 (inferred from earlier file '{{.*}}x86_64.obj')
33d546b505SNico Weber
34d546b505SNico Weber
35d546b505SNico WeberNeither is mixing object and bitcode files with different machine type:
36d546b505SNico Weber
37d546b505SNico WeberRUN: not llvm-lib %t/x86_64.obj %t/i386.bc 2>&1 | \
38d546b505SNico WeberRUN:     FileCheck --check-prefix=BC32 %s
39b941fa88SNico WeberBC32: i386.bc: file machine type x86 conflicts with library machine type x64 (inferred from earlier file '{{.*}}x86_64.obj')
40d546b505SNico Weber
41d546b505SNico WeberRUN: not llvm-lib %t/arm64.bc %t/x86_64.bc 2>&1 | \
42d546b505SNico WeberRUN:     FileCheck --check-prefix=BC64 %s
43b941fa88SNico WeberBC64: x86_64.bc: file machine type x64 conflicts with library machine type arm64 (inferred from earlier file '{{.*}}arm64.bc')
44b941fa88SNico Weber
45b941fa88SNico Weber
46b941fa88SNico WeberIf /machine: is passed, its value is authoritative.
47b941fa88SNico Weber
48b941fa88SNico WeberRUN: not llvm-lib /machine:X86 %t/x86_64.obj %t/i386.obj 2>&1 | \
49b941fa88SNico WeberRUN:     FileCheck --check-prefix=OBJ64 %s
50b941fa88SNico WeberOBJ64: x86_64.obj: file machine type x64 conflicts with library machine type x86 (from '/machine:X86' flag)
51eb56ef3eSJacek Caban
52eb56ef3eSJacek Caban
53eb56ef3eSJacek CabanMixing arm64 and x86_64 is possible using arm64ec:
54eb56ef3eSJacek Caban
55cea5d287SJacek CabanRUN: llvm-lib -machine:arm64ec %t/arm64.bc %t/x86_64.bc %t/arm64.obj %t/x86_64.obj %t/arm64ec.obj %t/arm64x.obj
56cea5d287SJacek CabanRUN: llvm-lib -machine:arm64x %t/arm64.bc %t/x86_64.bc %t/arm64.obj %t/x86_64.obj %t/arm64ec.obj %t/arm64x.obj
57cea5d287SJacek CabanRUN: llvm-lib -machine:arm64 %t/arm64.bc %t/arm64.obj %t/arm64x.obj
58eb56ef3eSJacek Caban
59eb56ef3eSJacek CabanRUN: not llvm-lib %t/arm64ec.obj 2>&1 | FileCheck --check-prefix=NOEC %s
60eb56ef3eSJacek CabanNOEC: arm64ec.obj: file machine type arm64ec conflicts with inferred library machine type, use /machine:arm64ec or /machine:arm64x
61eb56ef3eSJacek Caban
62eb56ef3eSJacek CabanRUN: not llvm-lib -machine:arm64ec %t/arm64ec.obj %t/i386.obj 2>&1 | \
63eb56ef3eSJacek CabanRUN:     FileCheck --check-prefix=OBJEC %s
64cea5d287SJacek CabanRUN: not llvm-lib -machine:arm64x %t/arm64ec.obj %t/i386.obj 2>&1 | \
65cea5d287SJacek CabanRUN:     FileCheck --check-prefix=OBJX %s
66cea5d287SJacek CabanRUN: not llvm-lib -machine:x64 %t/x86_64.obj %t/arm64x.obj 2>&1 | \
67cea5d287SJacek CabanRUN:     FileCheck --check-prefix=OBJX2 %s
68eb56ef3eSJacek CabanOBJEC: i386.obj: file machine type x86 conflicts with library machine type arm64ec (from '/machine:arm64ec' flag)
69cea5d287SJacek CabanOBJX:  i386.obj: file machine type x86 conflicts with library machine type arm64x (from '/machine:arm64x' flag)
70cea5d287SJacek CabanOBJX2: arm64x.obj: file machine type arm64x conflicts with library machine type x64 (from '/machine:x64' flag)
71eb56ef3eSJacek Caban
72eb56ef3eSJacek CabanRUN: not llvm-lib -machine:arm64ec %t/arm64.bc %t/x86_64.bc %t/i386.bc 2>&1 | \
73eb56ef3eSJacek CabanRUN:     FileCheck --check-prefix=BCEC %s
74cea5d287SJacek CabanRUN: not llvm-lib -machine:arm64x %t/arm64.bc %t/x86_64.bc %t/i386.bc 2>&1 | \
75cea5d287SJacek CabanRUN:     FileCheck --check-prefix=BCX %s
76eb56ef3eSJacek CabanBCEC: i386.bc: file machine type x86 conflicts with library machine type arm64ec (from '/machine:arm64ec' flag)
77cea5d287SJacek CabanBCX:  i386.bc: file machine type x86 conflicts with library machine type arm64x (from '/machine:arm64x' flag)
78