3 # This test makes sure that cross-language inlining can be used in conjunction
4 # with profile-guided optimization. The test only tests that the whole workflow
5 # can be executed without anything crashing. It does not test whether PGO or
6 # xLTO have any specific effect on the generated code.
10 COMMON_FLAGS=-Copt-level=3 -Ccodegen-units=1
12 # LLVM doesn't support instrumenting binaries that use SEH:
13 # https://bugs.llvm.org/show_bug.cgi?id=41279
15 # Things work fine with -Cpanic=abort though.
17 COMMON_FLAGS+= -Cpanic=abort
20 all: cpp-executable rust-executable
23 $(RUSTC) -Clinker-plugin-lto=on \
24 -Cprofile-generate="$(TMPDIR)"/cpp-profdata \
25 -o "$(TMPDIR)"/librustlib-xlto.a \
29 -fprofile-generate="$(TMPDIR)"/cpp-profdata \
33 -o "$(TMPDIR)"/cmain \
37 # Postprocess the profiling data so it can be used by the compiler
38 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
39 -o "$(TMPDIR)"/cpp-profdata/merged.profdata \
40 "$(TMPDIR)"/cpp-profdata/default_*.profraw
41 $(RUSTC) -Clinker-plugin-lto=on \
42 -Cprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \
43 -o "$(TMPDIR)"/librustlib-xlto.a \
47 -fprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \
51 -o "$(TMPDIR)"/cmain \
57 $(CLANG) ./clib.c -fprofile-generate="$(TMPDIR)"/rs-profdata -flto=thin -c -o $(TMPDIR)/clib.o -O3
58 (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
59 $(RUSTC) -Clinker-plugin-lto=on \
60 -Cprofile-generate="$(TMPDIR)"/rs-profdata \
64 -Clink-arg=-fuse-ld=lld \
68 # Postprocess the profiling data so it can be used by the compiler
69 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
70 -o "$(TMPDIR)"/rs-profdata/merged.profdata \
71 "$(TMPDIR)"/rs-profdata/default_*.profraw
73 -fprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \
78 rm "$(TMPDIR)"/libxyz.a
79 (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
80 $(RUSTC) -Clinker-plugin-lto=on \
81 -Cprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \
85 -Clink-arg=-fuse-ld=lld \