| 1 |
REQUIRES: x86-registered-target,ld.lld,llvm-ar |
| 2 |
|
| 3 |
# Test that a DTLTO link succeeds when there are two archive member files with |
| 4 |
# the same filename path component. |
| 5 |
|
| 6 |
# Split this file into several sources. |
| 7 |
RUN: rm -rf %t && split-file %s %t && cd %t |
| 8 |
|
| 9 |
RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -c start.c |
| 10 |
|
| 11 |
# Create first archive. |
| 12 |
RUN: mkdir archive1 && cd archive1 |
| 13 |
RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -c ../t1.c ../t3.c |
| 14 |
RUN: llvm-ar rc archive.a t3.o t1.o |
| 15 |
RUN: cd .. |
| 16 |
|
| 17 |
# Create second archive. |
| 18 |
RUN: mkdir archive2 && cd archive2 |
| 19 |
RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -c ../t1.c ../t3.c |
| 20 |
RUN: llvm-ar rc archive.a t3.o t1.o |
| 21 |
RUN: cd .. |
| 22 |
|
| 23 |
RUN: %clang -O2 --target=x86_64-linux-gnu -Werror -flto=thin -fuse-ld=lld \ |
| 24 |
RUN: -nostdlib -Wl,--undefined=t1,--undefined=t3 \ |
| 25 |
RUN: start.o archive1/archive.a archive2/archive.a -o main.elf \ |
| 26 |
RUN: -Wl,--save-temps \ |
| 27 |
RUN: -Wl,--thinlto-distributor=%python \ |
| 28 |
RUN: -Wl,--thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \ |
| 29 |
RUN: -Wl,--thinlto-remote-compiler=%clang |
| 30 |
|
| 31 |
# Check that the required output files have been created. |
| 32 |
RUN: ls | FileCheck %s --check-prefix=OUTPUTS |
| 33 |
|
| 34 |
# JSON jobs description. |
| 35 |
OUTPUTS-DAG: {{^}}main.[[#PID:]].dist-file.json |
| 36 |
|
| 37 |
# Sources. |
| 38 |
OUTPUTS-DAG: {{^}}start.1.[[#PID]].native.o{{$}} |
| 39 |
OUTPUTS-DAG: {{^}}start.1.[[#PID]].native.o.thinlto.bc{{$}} |
| 40 |
|
| 41 |
# Archive members. |
| 42 |
# Filename composition: <archive>(<member> at <offset>).<task>.<pid>.<task>.<pid>.native.o. |
| 43 |
OUTPUTS-DAG: {{^}}archive.a(t3.o at [[#T3_OFFSET:]]).2.[[#%X,HEXPID:]].2.[[#PID]].native.o{{$}} |
| 44 |
OUTPUTS-DAG: {{^}}archive.a(t3.o at [[#T3_OFFSET]]).2.[[#%X,HEXPID]].2.[[#PID]].native.o.thinlto.bc{{$}} |
| 45 |
OUTPUTS-DAG: {{^}}archive.a(t1.o at [[#T1_OFFSET:]]).3.[[#%X,HEXPID]].3.[[#PID]].native.o{{$}} |
| 46 |
OUTPUTS-DAG: {{^}}archive.a(t1.o at [[#T1_OFFSET]]).3.[[#%X,HEXPID]].3.[[#PID]].native.o.thinlto.bc{{$}} |
| 47 |
|
| 48 |
#--- t1.c |
| 49 |
__attribute__((retain)) void t1() { } |
| 50 |
|
| 51 |
#--- start.c |
| 52 |
__attribute__((retain)) void _start() { } |
| 53 |
|
| 54 |
#--- t3.c |
| 55 |
__attribute__((retain)) void t3() { } |