Skip to content

Commit c0d9357

Browse files
committed
rewrite cross-lang-lto-clang to rmake
1 parent 5367673 commit c0d9357

File tree

4 files changed

+68
-26
lines changed

4 files changed

+68
-26
lines changed

src/tools/run-make-support/src/command.rs

+7
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ impl CompletedProcess {
258258
self
259259
}
260260

261+
/// Checks that `stderr` does not contain the regex pattern `unexpected`.
262+
#[track_caller]
263+
pub fn assert_stderr_not_contains_regex<S: AsRef<str>>(&self, unexpected: S) -> &Self {
264+
assert_not_contains_regex(&self.stdout_utf8(), unexpected);
265+
self
266+
}
267+
261268
#[track_caller]
262269
pub fn assert_exit_code(&self, code: i32) -> &Self {
263270
assert!(self.output.status.code() == Some(code));

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
run-make/branch-protection-check-IBT/Makefile
22
run-make/cat-and-grep-sanity-check/Makefile
33
run-make/cdylib-dylib-linkage/Makefile
4-
run-make/cross-lang-lto-clang/Makefile
54
run-make/cross-lang-lto-pgo-smoketest/Makefile
65
run-make/cross-lang-lto-upstream-rlibs/Makefile
76
run-make/dep-info-doesnt-run-much/Makefile

tests/run-make/cross-lang-lto-clang/Makefile

-25
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// This test checks that cross-language inlining actually works by checking
2+
// the generated machine code.
3+
// See https://github.com/rust-lang/rust/pull/57514
4+
5+
//@ needs-force-clang-based-tests
6+
// FIXME(#126180): This test doesn't actually run anywhere, because the only
7+
// CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests.
8+
9+
use run_make_support::{clang, env_var, llvm_ar, llvm_objdump, rustc, static_lib_name};
10+
11+
fn main() {
12+
rustc()
13+
.linker_plugin_lto("on")
14+
.output(static_lib_name("rustlib-xlto"))
15+
.opt_level("2")
16+
.codegen_units(1)
17+
.input("rustlib.rs")
18+
.run();
19+
clang()
20+
.lto("thin")
21+
.use_ld("lld")
22+
.arg("-lrustlib-xlto")
23+
.out_exe("cmain")
24+
.input("cmain.c")
25+
.arg("-O3")
26+
.run();
27+
// Make sure we don't find a call instruction to the function we expect to
28+
// always be inlined.
29+
llvm_objdump()
30+
.arg("-d")
31+
.input("cmain")
32+
.run()
33+
.assert_stdout_not_contains_regex("call.*rust_always_inlined");
34+
// As a sanity check, make sure we do find a call instruction to a
35+
// non-inlined function
36+
llvm_objdump()
37+
.arg("-d")
38+
.input("cmain")
39+
.run()
40+
.assert_stdout_contains_regex("call.*rust_never_inlined");
41+
clang().input("clib.c").lto("thin").arg("-c").out_exe("clib.o").arg("-O2").run();
42+
llvm_ar().obj_to_ar().output_input(static_lib_name("xyz"), "clib.o").run();
43+
rustc()
44+
.linker_plugin_lto("on")
45+
.opt_level("2")
46+
.linker(&env_var("CLANG"))
47+
.link_arg("-fuse-ld=lld")
48+
.input("main.rs")
49+
.output("rsmain")
50+
.run();
51+
llvm_objdump()
52+
.arg("-d")
53+
.input("rsmain")
54+
.run()
55+
.assert_stdout_not_contains_regex("call.*c_always_inlined");
56+
llvm_objdump()
57+
.arg("-d")
58+
.input("rsmain")
59+
.run()
60+
.assert_stdout_contains_regex("call.*c_never_inlined");
61+
}

0 commit comments

Comments
 (0)