Debian Codegraph @

cross-project-tests/dtlto/fat-lto-objects.test

raw
1 REQUIRES: ld.lld,llvm-ar
2
3 # Test that a DTLTO link succeeds and outputs the expected set of files
4 # correctly when FatLTO objects are present.
5 RUN: rm -rf %t && split-file %s %t && cd %t
6
7 # Compile bitcode. -O2 is required for cross-module importing.
8 RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -ffat-lto-objects -c \
9 RUN: foo.c boo.c start.c
10
11 # We want to test FatLTO objects when included in archives.
12 RUN: llvm-ar rcs foo.a foo.o
13 RUN: llvm-ar rcsT boo.a boo.o
14
15 # Build with DTLTO.
16 RUN: %clang --target=x86_64-linux-gnu -flto=thin -ffat-lto-objects \
17 RUN: -fuse-ld=lld -nostdlib foo.a boo.a start.o -Wl,--save-temps \
18 RUN: -fthinlto-distributor=%python \
19 RUN: -Xthinlto-distributor=%llvm_src_root/utils/dtlto/local.py
20
21 # Check that the required output files have been created.
22 RUN: ls | FileCheck %s
23
24 # thin archive member: <archive>(<member> at <offset>).<task>.<pid>.<task>.<pid>.native.o
25 CHECK-DAG: {{^}}boo.a(boo.o at [[#BOO_OFFSET:]]).3.[[#%X,HEXPID:]].3.[[#PID:]].native.o{{$}}
26 # archive member: <archive>(<member> at <offset>).<task>.<pid>.<task>.<pid>.native.o
27 CHECK-DAG: {{^}}foo.a(foo.o at [[#FOO_OFFSET:]]).2.[[#%X,HEXPID]].2.[[#PID]].native.o{{$}}
28 # FatLTO object: <file>.<task>.<pid>.<task>.<pid>.native.o.
29 CHECK-DAG: {{^}}start.o.1.[[#%X,HEXPID]].1.[[#PID]].native.o{{$}}
30
31 # Check that all objects are named in all of the index files.
32 # We expect this to happen because each object references symbols from the
33 # others.
34 RUN: llvm-dis *.1.*.thinlto.bc -o - | \
35 RUN: FileCheck %s --check-prefixes=OBJECTS
36 RUN: llvm-dis *.2.*.thinlto.bc -o - | \
37 RUN: FileCheck %s --check-prefixes=OBJECTS
38 RUN: llvm-dis *.3.*.thinlto.bc -o - | \
39 RUN: FileCheck %s --check-prefixes=OBJECTS
40
41 OBJECTS-DAG: foo.o
42 OBJECTS-DAG: boo.o
43 OBJECTS-DAG: start.o
44
45 #--- foo.c
46 extern int boo(int), _start(int);
47 __attribute__((retain)) int foo(int x) { return x + boo(x) + _start(x); }
48
49 #--- boo.c
50 extern int foo(int), _start(int);
51 __attribute__((retain)) int boo(int x) { return x + foo(x) + _start(x); }
52
53 #--- start.c
54 extern int foo(int), boo(int);
55 __attribute__((retain)) int _start(int x) { return x + foo(x) + boo(x); }