98 lines · plain
1REQUIRES: ld.lld,llvm-ar2 3## Test that a DTLTO link succeeds and outputs the expected set of files4## correctly when thin archives are present.5 6RUN: rm -rf %t && split-file %s %t && cd %t7 8## Compile bitcode. -O2 is required for cross-module importing.9RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -c \10RUN: foo.c bar.c dog.c cat.c start.c11 12## Generate thin archives.13RUN: llvm-ar rcs foo.a foo.o --thin14## Create this bitcode thin archive in a subdirectory to test the expansion of15## the path to a bitcode file that is referenced using "..", e.g., in this case16## "../bar.o".17RUN: mkdir lib18RUN: llvm-ar rcs lib/bar.a bar.o --thin19## Create this bitcode thin archive with an absolute path entry containing "..".20RUN: llvm-ar rcs dog.a %t/lib/../dog.o --thin21## The bitcode member of cat.a will not be used in the link.22RUN: llvm-ar rcs cat.a cat.o --thin23RUN: llvm-ar rcs start.a start.o --thin24 25## Link from a different directory to ensure that thin archive member paths are26## resolved correctly relative to the archive locations.27RUN: mkdir %t/out && cd %t/out28 29RUN: %clang --target=x86_64-linux-gnu -flto=thin -fuse-ld=lld %t/foo.a %t/lib/bar.a ../start.a %t/cat.a \30RUN: -Wl,--whole-archive ../dog.a \31RUN: -fthinlto-distributor=%python \32RUN: -Xthinlto-distributor=%llvm_src_root/utils/dtlto/local.py \33RUN: -Wl,--save-temps -nostdlib -Werror34 35## Check that the required output files have been created.36RUN: ls | sort | FileCheck %s37 38## No files are expected before.39CHECK-NOT: {{.}}40 41## JSON jobs description.42CHECK: {{^}}a.[[PID:[a-zA-Z0-9_]+]].dist-file.json{{$}}43 44## Native output object files and individual summary index files.45CHECK: {{^}}bar.3.[[PID]].native.o{{$}}46CHECK: {{^}}bar.3.[[PID]].native.o.thinlto.bc{{$}}47CHECK: {{^}}dog.1.[[PID]].native.o{{$}}48CHECK: {{^}}dog.1.[[PID]].native.o.thinlto.bc{{$}}49CHECK: {{^}}foo.2.[[PID]].native.o{{$}}50CHECK: {{^}}foo.2.[[PID]].native.o.thinlto.bc{{$}}51CHECK: {{^}}start.4.[[PID]].native.o{{$}}52CHECK: {{^}}start.4.[[PID]].native.o.thinlto.bc{{$}}53 54## No files are expected after.55CHECK-NOT: {{.}}56 57 58## It is important that cross-module inlining occurs for this test to show that Clang can59## successfully load the bitcode file dependencies recorded in the summary indices.60## Explicitly check that the expected importing has occurred.61 62RUN: llvm-dis start.4.*.native.o.thinlto.bc -o - | \63RUN: FileCheck %s --check-prefixes=FOO,BAR,START64 65RUN: llvm-dis dog.1.*.native.o.thinlto.bc -o - | \66RUN: FileCheck %s --check-prefixes=FOO,BAR,DOG,START67 68RUN: llvm-dis foo.2.*.native.o.thinlto.bc -o - | \69RUN: FileCheck %s --check-prefixes=FOO,BAR,START70 71RUN: llvm-dis bar.3.*.native.o.thinlto.bc -o - | \72RUN: FileCheck %s --check-prefixes=FOO,BAR,START73 74FOO-DAG: foo.o75BAR-DAG: bar.o76DOG-DAG: dog.o77START-DAG: start.o78 79 80#--- foo.c81extern int bar(int), _start(int);82__attribute__((retain)) int foo(int x) { return x + bar(x) + _start(x); }83 84#--- bar.c85extern int foo(int), _start(int);86__attribute__((retain)) int bar(int x) { return x + foo(x) + _start(x); }87 88#--- dog.c89extern int foo(int), bar(int), _start(int);90__attribute__((retain)) int dog(int x) { return x + foo(x) + bar(x) + _start(x); }91 92#--- cat.c93__attribute__((retain)) void cat(int x) {}94 95#--- start.c96extern int foo(int), bar(int);97__attribute__((retain)) int _start(int x) { return x + foo(x) + bar(x); }98