-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Migrate min-global-align
and no-alloc-shim
run-make
tests to rmake
#128407
Conversation
This PR modifies cc @jieyouxu The run-make-support library was changed cc @jieyouxu |
@bors try |
Migrate `min-global-align` and `no-alloc-shim` `run-make` tests to rmake Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: x86_64-msvc
4c26950
to
2efbc94
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #128075) made this pull request unmergeable. Please resolve the merge conflicts. |
//@ ignore-cross-compile | ||
// Reason: the compiled binary is executed | ||
|
||
//FIXME(Oneirical): ignore-msvc FIXME(bjorn3) can't figure out how to link with the MSVC toolchain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussion: I'm fine with ignoring msvc for now and leaving this FIXME in, unless you want to investigate how to make msvc linking succeeds here.
The error message suggests we might be missing a -lstdc++
or something?
I can try to take a look at the msvc stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that the C runtime library isn't being passed to the linker because the compiler isn't being given any source code to compile, only object files. Adding libcmt.lib
to the args (if msvc) would fix this but maybe there should be some more principled way of doing this. Maybe a link()
alternative to cc
that only does linking? Not sure.
One odd thing I noticed is __udivti3
. That suggests to me that compiler-builtins is also needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, actually we already have extra_c_flags
. Instead of using a hard coded list, maybe we could just use --print native-static-libs
to grab all the necessary ones. That should also include the CRT. But that's probably a big enough job to do separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to get this test to pass on msvc by adding libcmt.lib
as Chris mentioned, but also had to pass compiler-builtins:
use run_make_support::{
cc, cwd, extra_c_flags, has_extension, has_prefix, run, rustc, shallow_find_files,
};
fn main() {
rustc().input("foo.rs").crate_type("bin").emit("obj").panic("abort").run();
let libdir = rustc().print("target-libdir").run().stdout_utf8();
let libdir = libdir.trim();
let alloc_libs = shallow_find_files(&libdir, |path| {
has_prefix(path, "liballoc-") && has_extension(path, "rlib")
});
let core_libs = shallow_find_files(libdir, |path| {
has_prefix(path, "libcore-") && has_extension(path, "rlib")
});
let compiler_builtins_libs = shallow_find_files(libdir, |path| {
has_prefix(path, "libcompiler_builtins") && has_extension(path, "rlib")
});
cc().args(extra_c_flags())
.input("foo.o")
.out_exe("foo")
.arg("/link")
.args(&alloc_libs)
.args(&core_libs)
.args(&compiler_builtins_libs)
.arg("libcmt.lib")
.run();
run("foo");
// Check that linking without __rust_no_alloc_shim_is_unstable defined fails
rustc()
.input("foo.rs")
.crate_type("bin")
.emit("obj")
.panic("abort")
.cfg("check_feature_gate")
.run();
cc().args(extra_c_flags())
.input("foo.o")
.out_exe("foo")
.arg("/link")
.args(&alloc_libs)
.args(&core_libs)
.args(&compiler_builtins_libs)
.arg("libcmt.lib")
.run_fail();
}
Not super sure about what's the best thing to do w.r.t. having to pass libcmt.lib
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better to accept this PR with ignore-msvc
and then later figure the thing to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using a hard coded list, maybe we could just use
--print native-static-libs
to grab all the necessary ones. That should also include the CRT. But that's probably a big enough job to do separately.
I briefly looked at this and I don't think this is possible (currently), because its docs say:
This may be used when creating a staticlib crate type. If this is the only flag, it will perform a full compilation and include a diagnostic note that indicates the linker flags to use when linking the resulting static library.
Unfortunately, we're building a bin here, and I tried this locally, --print native-static-libs
did not emit anything (just a newline).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better to accept this PR with
ignore-msvc
and then later figure the thing to do?
Yeah, this was what I had in mind in #128407 (comment), and I don't want to block this PR on trying to unignore it on msvc -- I can try to investigate that separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Oneirical let's add a ignore-msvc
for this with a FIXME linking to #128602 and call it a day for now 😆 I'll investigate separately.
@rustbot author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, we're building a bin here, and I tried this locally, --print native-static-libs did not emit anything (just a newline).
You'd need to build a fake staticlib then parse stdout. I think this could be done once in the extra_c_flags
function and cached instead of hard coding a list of libraries to link, Or maybe it could be something compiletest does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well. I have restored the ignore:
//@ ignore-msvc
//FIXME(Oneirical): Getting this to work on MSVC requires passing libcmt.lib to CC,
// which is not trivial to do.
// Tracking issue: https://github.com/rust-lang/rust/issues/128602
// Discussion: https://github.com/rust-lang/rust/pull/128407#discussion_r1702439172
@rustbot review
59abb8e
to
2064a76
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM overall, running few more try jobs to be safe.
@bors try |
r=me if the try jobs pass |
✌️ @Oneirical, you can now approve this pull request! If @jieyouxu told you to " |
@bors rollup=iffy (symbol checks) |
This comment was marked as resolved.
This comment was marked as resolved.
Migrate `min-global-align` and `no-alloc-shim` `run-make` tests to rmake Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: aarch64-linux try-job: test-various try-job: armhf-gnu try-job: x86_64-gnu-llvm-17
This comment was marked as resolved.
This comment was marked as resolved.
…eyouxu Migrate `min-global-align` and `no-alloc-shim` `run-make` tests to rmake Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: aarch64-apple try-job: test-various try-job: armhf-gnu try-job: x86_64-gnu-llvm-17
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
Wow. I'll take a look at this tomorrow. |
|
if llvm_components_contain("x86") { | ||
rustc().target("i686-unknown-linux-gnu").emit("llvm-ir").input("min_global_align.rs").run(); | ||
assert_count_is(3, rfs::read_to_string("min_global_align.ll"), "align 1"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark (for myself): I wonder if we could try to support revisions in rmake.rs. In ui tests and codegen tests revisions
also define corresponding cfg
s, maybe we could use them here as well (this remark is for myself).
Something like
//@ revisions: i686 systemz
//@[i686] needs-llvm-components: x86
//@[systemz] needs-llvm-components: systemz
fn main() {
#[cfg(i686)]
{
// i686 specific assertions
}
#[cfg(systemz)]
{
// systemz specific assertions
}
}
Just a thought. But handling blessing / properly quarantining revisions would be a pain.
☔ The latest upstream changes (presumably #129076) made this pull request unmergeable. Please resolve the merge conflicts. |
e1c1ac1
to
204f19b
Compare
204f19b
to
b85bedc
Compare
☀️ Test successful - checks-actions |
Finished benchmarking commit (13a5289): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (secondary 2.9%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 753.65s -> 752.809s (-0.11%) |
Part of #121876 and the associated Google Summer of Code project.
Please try:
try-job: aarch64-apple
try-job: test-various
try-job: armhf-gnu
try-job: aarch64-gnu
try-job: aarch64-gnu