-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite cross-lang-lto-clang to rmake
- Loading branch information
Showing
6 changed files
with
126 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} |