Debian Codegraph @

cross-project-tests/dtlto/multimodule.test

raw
1 REQUIRES: x86-registered-target,ld.lld,llvm-ar
2
3 # Test that a DTLTO link succeeds with a multi-module (via -fsplit-lto-unit)
4 # bitcode file. We use an archive, as archive member inputs exercise more of
5 # the DTLTO specific code than other input file types.
6
7 RUN: rm -rf %t && split-file %s %t && cd %t
8
9 RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -c usebar.cc \
10 RUN: -fno-rtti -fno-exceptions -fsplit-lto-unit
11
12 # Sanity check that multi-module bitcode was produced.
13 RUN: not llvm-modextract -n 2 usebar.o -o - 2>&1 \
14 RUN: | FileCheck %s --check-prefix=TWO
15 TWO: bitcode file contains 2 module(s)
16
17 # Create an archive.
18 RUN: llvm-ar rcs usebar.a usebar.o
19
20 # Build with DTLTO.
21 RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -fuse-ld=lld \
22 RUN: -nostdlib -shared -Wl,--whole-archive,--allow-shlib-undefined usebar.a \
23 RUN: -fthinlto-distributor=%python \
24 RUN: -Xthinlto-distributor=%llvm_src_root/utils/dtlto/local.py \
25 RUN: -Wl,--save-temps
26
27 RUN: ls | sort | FileCheck %s
28
29 # DTLTO JSON file - confirms DTLTO occurred.
30 CHECK: .dist-file.json
31
32 # .native.o exists - confirms archive member usebar.o participated in DTLTO.
33 CHECK: {{^}}usebar.a(usebar.o
34 CHECK-SAME: .native.o
35
36 #--- usebar.cc
37 // Minimal C++ input to exercise multi-module emission with -fsplit-lto-unit.
38 struct A { virtual int foo(); };
39 int bar(A *a);
40
41 struct B : A { int foo() { return 2; } };
42 int use() { static B b; return bar(&b); }