-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Migrate cross-lang-lto-clang
and cross-lang-lto-pgo-smoketest
run-make
tests to rmake
#128356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,62 @@ | ||
// 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 | ||
// NOTE(#126180): This test only runs 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. | ||
|
||
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() | ||
.disassemble() | ||
.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() | ||
.disassemble() | ||
.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() | ||
.disassemble() | ||
.input("rsmain") | ||
.run() | ||
.assert_stdout_not_contains_regex("call.*c_always_inlined"); | ||
llvm_objdump() | ||
.disassemble() | ||
.input("rsmain") | ||
.run() | ||
.assert_stdout_contains_regex("call.*c_never_inlined"); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
120 changes: 120 additions & 0 deletions
120
tests/run-make/cross-lang-lto-pgo-smoketest-clang/rmake.rs
This file contains hidden or 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,120 @@ | ||
// 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. | ||
// See https://github.com/rust-lang/rust/pull/61036 | ||
|
||
//@ needs-force-clang-based-tests | ||
// NOTE(#126180): This test would 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. | ||
|
||
//@ 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 | ||
// which added -C panic=abort to every RUSTC call. It was justified as follows: | ||
|
||
// "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." | ||
|
||
// This isn't very pertinent, however, as the test does not get run on any | ||
// MSVC platforms. | ||
|
||
use run_make_support::{ | ||
clang, env_var, has_extension, has_prefix, llvm_ar, llvm_profdata, rfs, run, rustc, | ||
shallow_find_files, static_lib_name, | ||
}; | ||
|
||
fn main() { | ||
rustc() | ||
.linker_plugin_lto("on") | ||
.output(static_lib_name("rustlib-xlto")) | ||
.opt_level("3") | ||
.codegen_units(1) | ||
.input("rustlib.rs") | ||
.arg("-Cprofile-generate=cpp-profdata") | ||
.run(); | ||
clang() | ||
.lto("thin") | ||
.arg("-fprofile-generate=cpp-profdata") | ||
.use_ld("lld") | ||
.arg("-lrustlib-xlto") | ||
.out_exe("cmain") | ||
.input("cmain.c") | ||
.arg("-O3") | ||
.run(); | ||
run("cmain"); | ||
// Postprocess the profiling data so it can be used by the compiler | ||
let profraw_files = shallow_find_files("cpp-profdata", |path| { | ||
has_prefix(path, "default") && has_extension(path, "profraw") | ||
}); | ||
let profraw_file = profraw_files.get(0).unwrap(); | ||
llvm_profdata().merge().output("cpp-profdata/merged.profdata").input(profraw_file).run(); | ||
rustc() | ||
.linker_plugin_lto("on") | ||
.profile_use("cpp-profdata/merged.profdata") | ||
.output(static_lib_name("rustlib-xlto")) | ||
.opt_level("3") | ||
.codegen_units(1) | ||
.input("rustlib.rs") | ||
.run(); | ||
clang() | ||
.lto("thin") | ||
.arg("-fprofile-use=cpp-profdata/merged.profdata") | ||
.use_ld("lld") | ||
.arg("-lrustlib-xlto") | ||
.out_exe("cmain") | ||
.input("cmain.c") | ||
.arg("-O3") | ||
.run(); | ||
|
||
clang() | ||
.input("clib.c") | ||
.arg("-fprofile-generate=rs-profdata") | ||
.lto("thin") | ||
.arg("-c") | ||
.out_exe("clib.o") | ||
.arg("-O3") | ||
.run(); | ||
llvm_ar().obj_to_ar().output_input(static_lib_name("xyz"), "clib.o").run(); | ||
rustc() | ||
.linker_plugin_lto("on") | ||
.opt_level("3") | ||
.codegen_units(1) | ||
.arg("-Cprofile-generate=rs-profdata") | ||
.linker(&env_var("CLANG")) | ||
.link_arg("-fuse-ld=lld") | ||
.input("main.rs") | ||
.output("rsmain") | ||
.run(); | ||
run("rsmain"); | ||
// Postprocess the profiling data so it can be used by the compiler | ||
let profraw_files = shallow_find_files("rs-profdata", |path| { | ||
has_prefix(path, "default") && has_extension(path, "profraw") | ||
}); | ||
let profraw_file = profraw_files.get(0).unwrap(); | ||
llvm_profdata().merge().output("rs-profdata/merged.profdata").input(profraw_file).run(); | ||
clang() | ||
.input("clib.c") | ||
.arg("-fprofile-use=rs-profdata/merged.profdata") | ||
.arg("-c") | ||
.lto("thin") | ||
.out_exe("clib.o") | ||
.arg("-O3") | ||
.run(); | ||
rfs::remove_file(static_lib_name("xyz")); | ||
llvm_ar().obj_to_ar().output_input(static_lib_name("xyz"), "clib.o").run(); | ||
rustc() | ||
.linker_plugin_lto("on") | ||
.opt_level("3") | ||
.codegen_units(1) | ||
.arg("-Cprofile-use=rs-profdata/merged.profdata") | ||
.linker(&env_var("CLANG")) | ||
.link_arg("-fuse-ld=lld") | ||
.input("main.rs") | ||
.output("rsmain") | ||
.run(); | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.