summaryrefslogtreecommitdiffstats
path: root/tests/run-make/cross-lang-lto-pgo-smoketest/Makefile
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /tests/run-make/cross-lang-lto-pgo-smoketest/Makefile
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/cross-lang-lto-pgo-smoketest/Makefile')
-rw-r--r--tests/run-make/cross-lang-lto-pgo-smoketest/Makefile87
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/run-make/cross-lang-lto-pgo-smoketest/Makefile b/tests/run-make/cross-lang-lto-pgo-smoketest/Makefile
new file mode 100644
index 000000000..70085d9bd
--- /dev/null
+++ b/tests/run-make/cross-lang-lto-pgo-smoketest/Makefile
@@ -0,0 +1,87 @@
+# needs-matching-clang
+
+# This test makes sure that cross-language inlining can be used in conjunction
+# with profile-guided optimization. The test only tests that the whole workflow
+# can be executed without anything crashing. It does not test whether PGO or
+# xLTO have any specific effect on the generated code.
+
+include ../tools.mk
+
+COMMON_FLAGS=-Copt-level=3 -Ccodegen-units=1
+
+# LLVM doesn't support instrumenting binaries that use SEH:
+# https://bugs.llvm.org/show_bug.cgi?id=41279
+#
+# Things work fine with -Cpanic=abort though.
+ifdef IS_MSVC
+COMMON_FLAGS+= -Cpanic=abort
+endif
+
+all: cpp-executable rust-executable
+
+cpp-executable:
+ $(RUSTC) -Clinker-plugin-lto=on \
+ -Cprofile-generate="$(TMPDIR)"/cpp-profdata \
+ -o "$(TMPDIR)"/librustlib-xlto.a \
+ $(COMMON_FLAGS) \
+ ./rustlib.rs
+ $(CLANG) -flto=thin \
+ -fprofile-generate="$(TMPDIR)"/cpp-profdata \
+ -fuse-ld=lld \
+ -L "$(TMPDIR)" \
+ -lrustlib-xlto \
+ -o "$(TMPDIR)"/cmain \
+ -O3 \
+ ./cmain.c
+ $(TMPDIR)/cmain
+ # Postprocess the profiling data so it can be used by the compiler
+ "$(LLVM_BIN_DIR)"/llvm-profdata merge \
+ -o "$(TMPDIR)"/cpp-profdata/merged.profdata \
+ "$(TMPDIR)"/cpp-profdata/default_*.profraw
+ $(RUSTC) -Clinker-plugin-lto=on \
+ -Cprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \
+ -o "$(TMPDIR)"/librustlib-xlto.a \
+ $(COMMON_FLAGS) \
+ ./rustlib.rs
+ $(CLANG) -flto=thin \
+ -fprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \
+ -fuse-ld=lld \
+ -L "$(TMPDIR)" \
+ -lrustlib-xlto \
+ -o "$(TMPDIR)"/cmain \
+ -O3 \
+ ./cmain.c
+
+rust-executable:
+ exit
+ $(CLANG) ./clib.c -fprofile-generate="$(TMPDIR)"/rs-profdata -flto=thin -c -o $(TMPDIR)/clib.o -O3
+ (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
+ $(RUSTC) -Clinker-plugin-lto=on \
+ -Cprofile-generate="$(TMPDIR)"/rs-profdata \
+ -L$(TMPDIR) \
+ $(COMMON_FLAGS) \
+ -Clinker=$(CLANG) \
+ -Clink-arg=-fuse-ld=lld \
+ -o $(TMPDIR)/rsmain \
+ ./main.rs
+ $(TMPDIR)/rsmain
+ # Postprocess the profiling data so it can be used by the compiler
+ "$(LLVM_BIN_DIR)"/llvm-profdata merge \
+ -o "$(TMPDIR)"/rs-profdata/merged.profdata \
+ "$(TMPDIR)"/rs-profdata/default_*.profraw
+ $(CLANG) ./clib.c \
+ -fprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \
+ -flto=thin \
+ -c \
+ -o $(TMPDIR)/clib.o \
+ -O3
+ rm "$(TMPDIR)"/libxyz.a
+ (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
+ $(RUSTC) -Clinker-plugin-lto=on \
+ -Cprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \
+ -L$(TMPDIR) \
+ $(COMMON_FLAGS) \
+ -Clinker=$(CLANG) \
+ -Clink-arg=-fuse-ld=lld \
+ -o $(TMPDIR)/rsmain \
+ ./main.rs