From 0149ba33bbfa890f9b77b1cb14b1ea1da50a6b66 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Tue, 6 Aug 2024 16:35:08 -0400 Subject: [PATCH] rewrite pgo-gen-lto to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/pgo-gen-lto/Makefile | 11 ---------- tests/run-make/pgo-gen-lto/rmake.rs | 22 +++++++++++++++++++ 3 files changed, 22 insertions(+), 12 deletions(-) delete mode 100644 tests/run-make/pgo-gen-lto/Makefile create mode 100644 tests/run-make/pgo-gen-lto/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index a2cfdea712e7c..13e36d30dfddd 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -20,7 +20,6 @@ run-make/min-global-align/Makefile run-make/native-link-modifier-bundle/Makefile run-make/no-alloc-shim/Makefile run-make/pdb-buildinfo-cl-cmd/Makefile -run-make/pgo-gen-lto/Makefile run-make/pgo-indirect-call-promotion/Makefile run-make/raw-dylib-alt-calling-convention/Makefile run-make/raw-dylib-c/Makefile diff --git a/tests/run-make/pgo-gen-lto/Makefile b/tests/run-make/pgo-gen-lto/Makefile deleted file mode 100644 index 54164c995222a..0000000000000 --- a/tests/run-make/pgo-gen-lto/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# needs-profiler-support -# ignore-cross-compile - -include ../tools.mk - -COMPILE_FLAGS=-Copt-level=3 -Clto=fat -Cprofile-generate="$(TMPDIR)" - -all: - $(RUSTC) $(COMPILE_FLAGS) test.rs - $(call RUN,test) || exit 1 - [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1) diff --git a/tests/run-make/pgo-gen-lto/rmake.rs b/tests/run-make/pgo-gen-lto/rmake.rs new file mode 100644 index 0000000000000..53d1623bf580e --- /dev/null +++ b/tests/run-make/pgo-gen-lto/rmake.rs @@ -0,0 +1,22 @@ +// A simple smoke test: when rustc compiles with profiling enabled, a profraw file +// should be generated. +// See https://github.com/rust-lang/rust/pull/48346 + +//@ needs-profiler-support +// Reason: this exercises LTO profiling +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{cwd, has_extension, has_prefix, run, rustc, shallow_find_files}; + +fn main() { + rustc().opt_level("3").arg("-Clto=fat").profile_generate(cwd()).input("test.rs").run(); + run("test"); + assert_eq!( + shallow_find_files(cwd(), |path| { + has_prefix(path, "default_") && has_extension(path, "profraw") + }) + .len(), + 1 + ); +}