run cross-lang-lto-pgo-smoketest in CI by renaming it

This commit is contained in:
Oneirical 2024-08-01 11:51:31 -04:00
parent 560e86d753
commit 290a260721
12 changed files with 35 additions and 142 deletions

View File

@ -258,13 +258,6 @@ pub fn assert_stderr_not_contains_regex<S: AsRef<str>>(&self, unexpected: S) ->
self self
} }
/// Checks that `stderr` does not contain the regex pattern `unexpected`.
#[track_caller]
pub fn assert_stderr_not_contains_regex<S: AsRef<str>>(&self, unexpected: S) -> &Self {
assert_not_contains_regex(&self.stdout_utf8(), unexpected);
self
}
#[track_caller] #[track_caller]
pub fn assert_exit_code(&self, code: i32) -> &Self { pub fn assert_exit_code(&self, code: i32) -> &Self {
assert!(self.output.status.code() == Some(code)); assert!(self.output.status.code() == Some(code));

View File

@ -246,6 +246,12 @@ pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref()); self.cmd.arg(path.as_ref());
self self
} }
/// Disassemble all executable sections found in the input files.
pub fn disassemble(&mut self) -> &mut Self {
self.cmd.arg("-d");
self
}
} }
impl LlvmAr { impl LlvmAr {

View File

@ -1,29 +0,0 @@
# FIXME(Oneirical): This is already implemented as an rmake.rs file, but due to #126180,
# the rmake.rs is not ran on CI. Once the rmake test has been proven to work, remove this
# Makefile.
# needs-force-clang-based-tests
# This test makes sure that cross-language inlining actually works by checking
# the generated machine code.
include ../tools.mk
all: cpp-executable rust-executable
cpp-executable:
$(RUSTC) -Clinker-plugin-lto=on -o $(TMPDIR)/librustlib-xlto.a -Copt-level=2 -Ccodegen-units=1 ./rustlib.rs
$(CLANG) -flto=thin -fuse-ld=lld -L $(TMPDIR) -lrustlib-xlto -o $(TMPDIR)/cmain ./cmain.c -O3
# Make sure we don't find a call instruction to the function we expect to
# always be inlined.
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -v -e "call.*rust_always_inlined"
# As a sanity check, make sure we do find a call instruction to a
# non-inlined function
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -e "call.*rust_never_inlined"
rust-executable:
$(CLANG) ./clib.c -flto=thin -c -o $(TMPDIR)/clib.o -O2
(cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
$(RUSTC) -Clinker-plugin-lto=on -L$(TMPDIR) -Copt-level=2 -Clinker=$(CLANG) -Clink-arg=-fuse-ld=lld ./main.rs -o $(TMPDIR)/rsmain
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -e "call.*c_never_inlined"
"$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -v -e "call.*c_always_inlined"

View File

@ -3,8 +3,9 @@
// See https://github.com/rust-lang/rust/pull/57514 // See https://github.com/rust-lang/rust/pull/57514
//@ needs-force-clang-based-tests //@ needs-force-clang-based-tests
// FIXME(#126180): This test doesn't actually run anywhere, because the only // NOTE(#126180): This test only runs on `x86_64-gnu-debug`, because that CI job sets
// CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests. // RUSTBUILD_FORCE_CLANG_BASED_TESTS and only runs tests which contain "clang" in their
// name.
use run_make_support::{clang, env_var, llvm_ar, llvm_objdump, rustc, static_lib_name}; use run_make_support::{clang, env_var, llvm_ar, llvm_objdump, rustc, static_lib_name};
@ -27,14 +28,14 @@ fn main() {
// Make sure we don't find a call instruction to the function we expect to // Make sure we don't find a call instruction to the function we expect to
// always be inlined. // always be inlined.
llvm_objdump() llvm_objdump()
.arg("-d") .disassemble()
.input("cmain") .input("cmain")
.run() .run()
.assert_stdout_not_contains_regex("call.*rust_always_inlined"); .assert_stdout_not_contains_regex("call.*rust_always_inlined");
// As a sanity check, make sure we do find a call instruction to a // As a sanity check, make sure we do find a call instruction to a
// non-inlined function // non-inlined function
llvm_objdump() llvm_objdump()
.arg("-d") .disassemble()
.input("cmain") .input("cmain")
.run() .run()
.assert_stdout_contains_regex("call.*rust_never_inlined"); .assert_stdout_contains_regex("call.*rust_never_inlined");
@ -49,12 +50,12 @@ fn main() {
.output("rsmain") .output("rsmain")
.run(); .run();
llvm_objdump() llvm_objdump()
.arg("-d") .disassemble()
.input("rsmain") .input("rsmain")
.run() .run()
.assert_stdout_not_contains_regex("call.*c_always_inlined"); .assert_stdout_not_contains_regex("call.*c_always_inlined");
llvm_objdump() llvm_objdump()
.arg("-d") .disassemble()
.input("rsmain") .input("rsmain")
.run() .run()
.assert_stdout_contains_regex("call.*c_never_inlined"); .assert_stdout_contains_regex("call.*c_never_inlined");

View File

@ -5,14 +5,23 @@
// See https://github.com/rust-lang/rust/pull/61036 // See https://github.com/rust-lang/rust/pull/61036
//@ needs-force-clang-based-tests //@ needs-force-clang-based-tests
// FIXME(#126180): This test doesn't actually run anywhere, because the only // NOTE(#126180): This test would only run on `x86_64-gnu-debug`, because that CI job sets
// CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests. // RUSTBUILD_FORCE_CLANG_BASED_TESTS and only runs tests which contain "clang" in their
// name.
//@ needs-profiler-support
// FIXME(Oneirical): Except that due to the reliance on llvm-profdata, this test
// never runs, because `x86_64-gnu-debug` does not have the `profiler_builtins` crate.
//FIXME(Oneirical): There was a strange workaround for MSVC on this test //FIXME(Oneirical): There was a strange workaround for MSVC on this test
// which added -C panic=abort to every RUSTC call. It was justified as follows: // which added -C panic=abort to every RUSTC call. It was justified as follows:
// LLVM doesn't support instrumenting binaries that use SEH:
// "LLVM doesn't support instrumenting binaries that use SEH:
// https://bugs.llvm.org/show_bug.cgi?id=41279 // https://bugs.llvm.org/show_bug.cgi?id=41279
// Things work fine with -Cpanic=abort though. // Things work fine with -Cpanic=abort though."
// This isn't very pertinent, however, as the test does not get run on any
// MSVC platforms.
use run_make_support::{ use run_make_support::{
clang, env_var, has_extension, has_prefix, llvm_ar, llvm_profdata, rfs, run, rustc, clang, env_var, has_extension, has_prefix, llvm_ar, llvm_profdata, rfs, run, rustc,

View File

@ -1,94 +0,0 @@
# FIXME(Oneirical): This is already implemented as an rmake.rs file, but due to #126180,
# the rmake.rs is not ran on CI. Once the rmake test has been proven to work, remove this
# Makefile.
# needs-force-clang-based-tests
# FIXME(#126180): This test doesn't actually run anywhere, because the only
# CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests.
# 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

View File

@ -3,8 +3,11 @@
//@ needs-force-clang-based-tests //@ needs-force-clang-based-tests
//@ needs-llvm-components riscv //@ needs-llvm-components riscv
// FIXME(#126180): This test doesn't actually run anywhere, because the only //@ needs-force-clang-based-tests
// CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests. // FIXME(#126180): This test can only run on `x86_64-gnu-debug`, because that CI job sets
// RUSTBUILD_FORCE_CLANG_BASED_TESTS and only runs tests which contain "clang" in their
// name.
// However, this test does not run at all as its name does not contain "clang".
use std::path::PathBuf; use std::path::PathBuf;
use std::process::{Command, Output}; use std::process::{Command, Output};

View File

@ -2,6 +2,10 @@
// $ RUSTBUILD_FORCE_CLANG_BASED_TESTS=1 ./x.py test tests/run-make/wasm-override-linker/ // $ RUSTBUILD_FORCE_CLANG_BASED_TESTS=1 ./x.py test tests/run-make/wasm-override-linker/
//@ needs-force-clang-based-tests //@ needs-force-clang-based-tests
// FIXME(#126180): This test can only run on `x86_64-gnu-debug`, because that CI job sets
// RUSTBUILD_FORCE_CLANG_BASED_TESTS and only runs tests which contain "clang" in their
// name.
// However, this test does not run at all as its name does not contain "clang".
use run_make_support::{env_var, rustc, target}; use run_make_support::{env_var, rustc, target};