rewrite track-pgo-dep-info to rmake

This commit is contained in:
Oneirical 2024-07-05 13:45:06 -04:00
parent 48a9d4b68a
commit 7c23872836
5 changed files with 25 additions and 32 deletions

View File

@ -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

View File

@ -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() {

View File

@ -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:"));
}

View File

@ -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

View File

@ -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"));
}