| 1 |
REQUIRES: lld-link |
| 2 |
|
| 3 |
## Test that a DTLTO link succeeds and outputs the expected set of files |
| 4 |
## correctly when thin archives are present. |
| 5 |
|
| 6 |
RUN: rm -rf %t && split-file %s %t && cd %t |
| 7 |
|
| 8 |
## Compile bitcode. -O2 is required for cross-module importing. |
| 9 |
RUN: %clang -O2 --target=x86_64-pc-windows-msvc -flto=thin -c \ |
| 10 |
RUN: foo.c bar.c dog.c cat.c start.c |
| 11 |
|
| 12 |
## Generate thin archives. |
| 13 |
RUN: lld-link /lib /llvmlibthin /out:foo.lib foo.o |
| 14 |
## Create this bitcode thin archive in a subdirectory to test the expansion of |
| 15 |
## the path to a bitcode file that is referenced using "..", e.g., in this case |
| 16 |
## "../bar.o". |
| 17 |
RUN: mkdir lib |
| 18 |
RUN: lld-link /lib /llvmlibthin /out:lib/bar.lib bar.o |
| 19 |
## Create this bitcode thin archive with an absolute path entry containing "..". |
| 20 |
RUN: lld-link /lib /llvmlibthin /out:dog.lib %t/lib/../dog.o |
| 21 |
RUN: lld-link /lib /llvmlibthin /out:cat.lib cat.o |
| 22 |
RUN: lld-link /lib /llvmlibthin /out:start.lib start.o |
| 23 |
|
| 24 |
## Link from a different directory to ensure that thin archive member paths are |
| 25 |
## resolved correctly relative to the archive locations. |
| 26 |
RUN: mkdir %t/out && cd %t/out |
| 27 |
RUN: lld-link /subsystem:console /machine:x64 /entry:start /out:my.exe \ |
| 28 |
RUN: %t/foo.lib %t/lib/bar.lib ../start.lib %t/cat.lib \ |
| 29 |
RUN: /includeoptional:dog ../dog.lib \ |
| 30 |
RUN: -thinlto-distributor:%python \ |
| 31 |
RUN: -thinlto-distributor-arg:%llvm_src_root/utils/dtlto/local.py \ |
| 32 |
RUN: -thinlto-remote-compiler:%clang \ |
| 33 |
RUN: /lldsavetemps |
| 34 |
|
| 35 |
## Check that the required output files have been created. |
| 36 |
RUN: ls | FileCheck %s --check-prefix=OUTPUTS --implicit-check-not=cat |
| 37 |
|
| 38 |
## JSON jobs description. |
| 39 |
OUTPUTS-DAG: my.[[#PID:]].dist-file.json |
| 40 |
|
| 41 |
## Individual summary index files. |
| 42 |
OUTPUTS-DAG: start.1.[[#PID]].native.o.thinlto.bc{{$}} |
| 43 |
OUTPUTS-DAG: dog.2.[[#PID]].native.o.thinlto.bc{{$}} |
| 44 |
OUTPUTS-DAG: foo.3.[[#PID]].native.o.thinlto.bc{{$}} |
| 45 |
OUTPUTS-DAG: bar.4.[[#PID]].native.o.thinlto.bc{{$}} |
| 46 |
|
| 47 |
## Native output object files. |
| 48 |
OUTPUTS-DAG: start.1.[[#PID]].native.o{{$}} |
| 49 |
OUTPUTS-DAG: dog.2.[[#PID]].native.o{{$}} |
| 50 |
OUTPUTS-DAG: foo.3.[[#PID]].native.o{{$}} |
| 51 |
OUTPUTS-DAG: bar.4.[[#PID]].native.o{{$}} |
| 52 |
|
| 53 |
|
| 54 |
## It is important that cross-module inlining occurs for this test to show that Clang can |
| 55 |
## successfully load the bitcode file dependencies recorded in the summary indices. |
| 56 |
## Explicitly check that the expected importing has occurred. |
| 57 |
|
| 58 |
RUN: llvm-dis start.1.*.native.o.thinlto.bc -o - | \ |
| 59 |
RUN: FileCheck %s --check-prefixes=FOO,BAR,START |
| 60 |
|
| 61 |
RUN: llvm-dis dog.2.*.native.o.thinlto.bc -o - | \ |
| 62 |
RUN: FileCheck %s --check-prefixes=FOO,BAR,DOG,START |
| 63 |
|
| 64 |
RUN: llvm-dis foo.3.*.native.o.thinlto.bc -o - | \ |
| 65 |
RUN: FileCheck %s --check-prefixes=FOO,BAR,START |
| 66 |
|
| 67 |
RUN: llvm-dis bar.4.*.native.o.thinlto.bc -o - | \ |
| 68 |
RUN: FileCheck %s --check-prefixes=FOO,BAR,START |
| 69 |
|
| 70 |
FOO-DAG: foo.o |
| 71 |
BAR-DAG: bar.o |
| 72 |
DOG-DAG: dog.o |
| 73 |
START-DAG: start.o |
| 74 |
|
| 75 |
|
| 76 |
#--- foo.c |
| 77 |
extern int bar(int), start(int); |
| 78 |
__attribute__((retain)) int foo(int x) { return x + bar(x) + start(x); } |
| 79 |
|
| 80 |
#--- bar.c |
| 81 |
extern int foo(int), start(int); |
| 82 |
__attribute__((retain)) int bar(int x) { return x + foo(x) + start(x); } |
| 83 |
|
| 84 |
#--- dog.c |
| 85 |
extern int foo(int), bar(int), start(int); |
| 86 |
__attribute__((retain)) int dog(int x) { return x + foo(x) + bar(x) + start(x); } |
| 87 |
|
| 88 |
#--- cat.c |
| 89 |
__attribute__((retain)) void cat(int x) {} |
| 90 |
|
| 91 |
#--- start.c |
| 92 |
extern int foo(int), bar(int); |
| 93 |
__attribute__((retain)) int start(int x) { return x + foo(x) + bar(x); } |