mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
rewrite cross-lang-lto-clang to rmake
This commit is contained in:
parent
5367673014
commit
c0d9357a4c
@ -258,6 +258,13 @@ impl CompletedProcess {
|
||||
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]
|
||||
pub fn assert_exit_code(&self, code: i32) -> &Self {
|
||||
assert!(self.output.status.code() == Some(code));
|
||||
|
@ -1,7 +1,6 @@
|
||||
run-make/branch-protection-check-IBT/Makefile
|
||||
run-make/cat-and-grep-sanity-check/Makefile
|
||||
run-make/cdylib-dylib-linkage/Makefile
|
||||
run-make/cross-lang-lto-clang/Makefile
|
||||
run-make/cross-lang-lto-pgo-smoketest/Makefile
|
||||
run-make/cross-lang-lto-upstream-rlibs/Makefile
|
||||
run-make/dep-info-doesnt-run-much/Makefile
|
||||
|
@ -1,25 +0,0 @@
|
||||
# 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"
|
61
tests/run-make/cross-lang-lto-clang/rmake.rs
Normal file
61
tests/run-make/cross-lang-lto-clang/rmake.rs
Normal file
@ -0,0 +1,61 @@
|
||||
// This test checks that cross-language inlining actually works by checking
|
||||
// the generated machine code.
|
||||
// See https://github.com/rust-lang/rust/pull/57514
|
||||
|
||||
//@ 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.
|
||||
|
||||
use run_make_support::{clang, env_var, llvm_ar, llvm_objdump, rustc, static_lib_name};
|
||||
|
||||
fn main() {
|
||||
rustc()
|
||||
.linker_plugin_lto("on")
|
||||
.output(static_lib_name("rustlib-xlto"))
|
||||
.opt_level("2")
|
||||
.codegen_units(1)
|
||||
.input("rustlib.rs")
|
||||
.run();
|
||||
clang()
|
||||
.lto("thin")
|
||||
.use_ld("lld")
|
||||
.arg("-lrustlib-xlto")
|
||||
.out_exe("cmain")
|
||||
.input("cmain.c")
|
||||
.arg("-O3")
|
||||
.run();
|
||||
// Make sure we don't find a call instruction to the function we expect to
|
||||
// always be inlined.
|
||||
llvm_objdump()
|
||||
.arg("-d")
|
||||
.input("cmain")
|
||||
.run()
|
||||
.assert_stdout_not_contains_regex("call.*rust_always_inlined");
|
||||
// As a sanity check, make sure we do find a call instruction to a
|
||||
// non-inlined function
|
||||
llvm_objdump()
|
||||
.arg("-d")
|
||||
.input("cmain")
|
||||
.run()
|
||||
.assert_stdout_contains_regex("call.*rust_never_inlined");
|
||||
clang().input("clib.c").lto("thin").arg("-c").out_exe("clib.o").arg("-O2").run();
|
||||
llvm_ar().obj_to_ar().output_input(static_lib_name("xyz"), "clib.o").run();
|
||||
rustc()
|
||||
.linker_plugin_lto("on")
|
||||
.opt_level("2")
|
||||
.linker(&env_var("CLANG"))
|
||||
.link_arg("-fuse-ld=lld")
|
||||
.input("main.rs")
|
||||
.output("rsmain")
|
||||
.run();
|
||||
llvm_objdump()
|
||||
.arg("-d")
|
||||
.input("rsmain")
|
||||
.run()
|
||||
.assert_stdout_not_contains_regex("call.*c_always_inlined");
|
||||
llvm_objdump()
|
||||
.arg("-d")
|
||||
.input("rsmain")
|
||||
.run()
|
||||
.assert_stdout_contains_regex("call.*c_never_inlined");
|
||||
}
|
Loading…
Reference in New Issue
Block a user