| 1 |
REQUIRES: ld.lld |
| 2 |
|
| 3 |
# Test that if a link is terminated by a signal (or the equivalent on |
| 4 |
# Windows), e.g. CTRL-C, DTLTO temporary files are cleaned up. We use |
| 5 |
# archives in this test as the handling for archives requires a superset |
| 6 |
# of the temporary files used for object inputs. |
| 7 |
|
| 8 |
RUN: rm -rf %t && split-file %s %t && cd %t |
| 9 |
|
| 10 |
RUN: %clang --target=x86_64-linux-gnu -O2 t1.c t2.c -flto=thin -c |
| 11 |
|
| 12 |
RUN: llvm-ar rcs t.a t1.o t2.o |
| 13 |
|
| 14 |
DEFINE: %{tdir} = dummy-to-make-lit-work |
| 15 |
DEFINE: %{kill-dtlto} = mkdir %{tdir} && %python %S/test_temps.py %{tdir} kill \ |
| 16 |
DEFINE: %clang --target=x86_64-linux-gnu -nostdlib -O2 -flto=thin \ |
| 17 |
DEFINE: -fuse-ld=lld -Wl,--whole-archive t.a -o %{tdir}/t.elf -shared \ |
| 18 |
DEFINE: -fthinlto-distributor=%python \ |
| 19 |
DEFINE: -Xthinlto-distributor=%S/local_codegen_and_wait.py |
| 20 |
|
| 21 |
# Check that all temporary files are removed if the process is aborted. |
| 22 |
REDEFINE: %{tdir} = empty |
| 23 |
RUN: %{kill-dtlto} |
| 24 |
RUN: ls %{tdir} | FileCheck %s --allow-empty --check-prefix=EMPTY |
| 25 |
|
| 26 |
EMPTY-NOT: {{.}} |
| 27 |
|
| 28 |
# Check that --save-temps preserves temporary files if the process is aborted. |
| 29 |
REDEFINE: %{tdir} = savetemps |
| 30 |
RUN: %{kill-dtlto} -Wl,--save-temps |
| 31 |
RUN: ls %{tdir} | sort | FileCheck %s --check-prefixes=BOOKEND,TEMPS,INDEX,OTHER |
| 32 |
|
| 33 |
# Check that --thinlto-emit-index-files preserves the index files if the process |
| 34 |
# is aborted. |
| 35 |
REDEFINE: %{tdir} = index |
| 36 |
RUN: %{kill-dtlto} -Wl,--thinlto-emit-index-files |
| 37 |
RUN: ls %{tdir} | sort | FileCheck %s --check-prefixes=BOOKEND,INDEX |
| 38 |
|
| 39 |
# No files are expected before. |
| 40 |
BOOKEND-NOT: {{.}} |
| 41 |
TEMPS: {{^}}t.[[#PID:]].dist-file.json{{$}} |
| 42 |
# Filename composition: <archive>(<member> at <offset>).<task>.<pid>.<task>.<pid>.native.o. |
| 43 |
TEMPS: {{^}}t.a(t1.o at [[#T1_OFFSET:]]).1.[[#%X,HEXPID:]].1.[[#PID]].native.o{{$}} |
| 44 |
INDEX: {{^}}t.a(t1.o at [[#T1_OFFSET:]]).1.[[#%X,HEXPID:]].1.[[#PID:]].native.o.thinlto.bc{{$}} |
| 45 |
TEMPS: {{^}}t.a(t1.o at [[#T1_OFFSET]]).1.[[#%X,HEXPID]].o{{$}} |
| 46 |
TEMPS: {{^}}t.a(t2.o at [[#T2_OFFSET:]]).2.[[#%X,HEXPID]].2.[[#PID]].native.o{{$}} |
| 47 |
INDEX: {{^}}t.a(t2.o at [[#T2_OFFSET:]]).2.[[#%X,HEXPID]].2.[[#PID]].native.o.thinlto.bc{{$}} |
| 48 |
TEMPS: {{^}}t.a(t2.o at [[#T2_OFFSET]]).2.[[#%X,HEXPID]].o{{$}} |
| 49 |
OTHER: {{^}}t.elf.resolution.txt{{$}} |
| 50 |
# No files are expected after. |
| 51 |
BOOKEND-NOT: {{.}} |
| 52 |
|
| 53 |
#--- t1.c |
| 54 |
__attribute__((retain)) int t1(int x) { return x; } |
| 55 |
|
| 56 |
#--- t2.c |
| 57 |
__attribute__((retain)) int t2(int x) { return x; } |