From 7c23872836f6b536ed4a59786a1d46fbb5f0dafd Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 5 Jul 2024 13:45:06 -0400 Subject: [PATCH] rewrite track-pgo-dep-info to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/proc-macro-three-crates/rmake.rs | 2 -- tests/run-make/track-path-dep-info/rmake.rs | 6 ++--- tests/run-make/track-pgo-dep-info/Makefile | 25 ------------------- tests/run-make/track-pgo-dep-info/rmake.rs | 23 +++++++++++++++++ 5 files changed, 25 insertions(+), 32 deletions(-) delete mode 100644 tests/run-make/track-pgo-dep-info/Makefile create mode 100644 tests/run-make/track-pgo-dep-info/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 118e76fdbcd..559782056e6 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -158,7 +158,6 @@ run-make/target-without-atomic-cas/Makefile run-make/test-benches/Makefile run-make/thumb-none-cortex-m/Makefile run-make/thumb-none-qemu/Makefile -run-make/track-pgo-dep-info/Makefile run-make/translation/Makefile run-make/type-mismatch-same-crate-name/Makefile run-make/unstable-flag-required/Makefile diff --git a/tests/run-make/proc-macro-three-crates/rmake.rs b/tests/run-make/proc-macro-three-crates/rmake.rs index 62dc547fcfb..d3735540fdd 100644 --- a/tests/run-make/proc-macro-three-crates/rmake.rs +++ b/tests/run-make/proc-macro-three-crates/rmake.rs @@ -5,8 +5,6 @@ // This was fixed in #37846, and this test checks // that this bug does not make a resurgence. -//FIXME(Oneirical): ignore-cross-compile - use run_make_support::{bare_rustc, cwd, rust_lib_name, rustc}; fn main() { diff --git a/tests/run-make/track-path-dep-info/rmake.rs b/tests/run-make/track-path-dep-info/rmake.rs index f4a77c7fc21..f108dc66051 100644 --- a/tests/run-make/track-path-dep-info/rmake.rs +++ b/tests/run-make/track-path-dep-info/rmake.rs @@ -4,12 +4,10 @@ // output successfully added the file as a dependency. // See https://github.com/rust-lang/rust/pull/84029 -//FIXME(Oneirical): Try it on musl - -use run_make_support::{bare_rustc, fs_wrapper, rustc}; +use run_make_support::{fs_wrapper, rustc}; fn main() { - bare_rustc().input("macro_def.rs").run(); + rustc().input("macro_def.rs").run(); rustc().env("EXISTING_PROC_MACRO_ENV", "1").emit("dep-info").input("macro_use.rs").run(); assert!(fs_wrapper::read_to_string("macro_use.d").contains("emojis.txt:")); } diff --git a/tests/run-make/track-pgo-dep-info/Makefile b/tests/run-make/track-pgo-dep-info/Makefile deleted file mode 100644 index 3afe3662fa7..00000000000 --- a/tests/run-make/track-pgo-dep-info/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# needs-profiler-support - -include ../tools.mk - -# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC` -# instead of hardcoding them everywhere they're needed. -ifeq ($(IS_MUSL_HOST),1) -ADDITIONAL_ARGS := $(RUSTFLAGS) -endif - -all: - # Generate PGO profiles - $(BARE_RUSTC) $(ADDITIONAL_ARGS) -Cprofile-generate=$(TMPDIR)/profiles --out-dir $(TMPDIR) main.rs - $(TMPDIR)/main - - # Merge profiles - "$(LLVM_BIN_DIR)/llvm-profdata" merge \ - -o "$(TMPDIR)/merged.profdata" \ - "$(TMPDIR)/profiles" || exit 1 - - # Use the profile - $(RUSTC) -Cprofile-use=$(TMPDIR)/merged.profdata --emit dep-info main.rs - - # Check that profile file is in depinfo - $(CGREP) "merged.profdata" < $(TMPDIR)/main.d diff --git a/tests/run-make/track-pgo-dep-info/rmake.rs b/tests/run-make/track-pgo-dep-info/rmake.rs new file mode 100644 index 00000000000..acfe05cf8ea --- /dev/null +++ b/tests/run-make/track-pgo-dep-info/rmake.rs @@ -0,0 +1,23 @@ +// Emitting dep-info files used to not have any mention of PGO profiles used +// in compilation, which meant these profiles could be changed without consequence. +// After changing this in #100801, this test checks that the profile data is successfully +// included in dep-info emit files. +// See https://github.com/rust-lang/rust/pull/100801 + +//@ ignore-cross-compile +// Reason: the binary is executed +//@ needs-profiler-support + +use run_make_support::{fs_wrapper, llvm_profdata, run, rustc}; + +fn main() { + // Generate the profile-guided-optimization (PGO) profiles + rustc().profile_generate("profiles").input("main.rs").run(); + // Merge the profiles + run("main"); + llvm_profdata().merge().output("merged.profdata").input("profiles").run(); + // Use the profiles in compilation + rustc().profile_use("merged.profdata").emit("dep-info").input("main.rs").run(); + // Check that the profile file is in the dep-info emit file + assert!(fs_wrapper::read_to_string("main.d").contains("merged.profdata")); +}