-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Allow running tests with GCC #144687
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
base: master
Are you sure you want to change the base?
Allow running tests with GCC #144687
Conversation
Some changes occurred in src/tools/compiletest cc @jieyouxu This PR modifies If appropriate, please update |
@@ -1769,7 +1769,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the | |||
cmd.arg("--host").arg(&*compiler.host.triple); | |||
cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.host_target)); | |||
|
|||
if let Some(codegen_backend) = builder.config.default_codegen_backend(compiler.host) { | |||
if let Some(codegen_backend) = builder.config.codegen_backends(compiler.host).first() { |
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.
Since we don't seem to run commands for each registered backend, I simply look at the first for now. Should I add a FIXME comment on it?
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 don't understand this change, why didn't you just use default_codegen_backend
? It does the same thing (looks at the first codegen backend).
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.
default_codegen_backend()
is literally implemented as codegen_backends().first()
.
Edit: for some reason github didn't show me Kobzol's comment before.
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 just submitted it now 😆 It was a pending comment, but GH uses the original time when it was written, not when it was submitted, which is a bit confusing.
@@ -1917,6 +1920,11 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the | |||
cmd.arg(exclude); | |||
} | |||
|
|||
if builder.config.codegen_backends(target).first().map(|b| b.as_str()) == Some("gcc") { |
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.
Same here.
@@ -563,6 +563,12 @@ impl Builder<'_> { | |||
println!("using sysroot {sysroot_str}"); | |||
} | |||
|
|||
if self.config.codegen_backends(target).first().map(|b| b.as_str()) == Some("gcc") { |
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.
Same here.
@@ -1226,6 +1226,13 @@ impl Config { | |||
self.out.join(self.host_target).join("ci-rustc") | |||
} | |||
|
|||
pub(crate) fn libgccjit_root(&self) -> PathBuf { |
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.
Considering we don't store GCC in the same ___location depending whether we build it or we download it, I found it better to handle it in one place instead, hence the creation of this method.
This comment has been minimized.
This comment has been minimized.
29d84ca
to
5a1a756
Compare
if self.config.codegen_backends(target).first().map(|b| b.as_str()) == Some("gcc") { | ||
let gcc_sysroot = self.config.libgccjit_root(); | ||
let gcc_sysroot = gcc_sysroot.as_os_str().to_str().expect("sysroot should be UTF-8"); | ||
cargo.env("LD_LIBRARY_PATH", gcc_sysroot); |
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.
How is it done for cg_llvm?
Couldn't we reuse what is done there?
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.
Why isn't libgccjit copied into the sysroot like for libLLVM?
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.
Excellent question, absolutely no clue.
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.
That works for build, but not for dist, we do not want to dist libgccjit.so by default with rustup (at least not yet). If build did this automatically, we would have to explicitly skip it when creating the dist archives (normally we mostly copy all .so files to them, I think).
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.
Dist has an explicit list of files to include in each component, right? It has to for each .so files to not end up in every component. So the cg_gcc component can include just cg_gcc.so and not libgccjit.so.
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 don't think it's very explicit in this case:
let libdir = builder.rustc_libdir(compiler); |
To clarify, the cg_gcc
rustup component should include both cg_gcc.so
and libgccjit.so
. But the normal rustc component shouldn't contain libgccjit.so
.
if !matches!(self.config.codegen_backend, crate::CodegenBackend::Llvm) { | ||
let lib_path = self.config.sysroot_base.join(self.config.codegen_backend.as_str()); | ||
rustc.arg(format!("-Zcodegen-backend={}", lib_path)); | ||
} |
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.
This always matches the default codegen backend, right? In that case no explicit -Zcodegen-backend
should be necessary.
I looked at how the backends are configured today and I think that before we go forward with enabling the tests, we should first both clean the handling of the backends, and understand/decide how will the GCC lookup work in practice. Some work items:
Regarding the GCC lookup, we need to figure out a universal way of how will cg_gcc find libgccjit.so. Spamming libdir paths at all the tests that could possibly use the GCC backend is not very scalable, and won't work for using the GCC backend outside bootstrap. When I |
I can link the |
I suspect that the most straightforward solution would be to do what LLVM does, so either put it in the I checked that if we put |
☔ The latest upstream changes (presumably #144773) made this pull request unmergeable. Please resolve the merge conflicts. |
Gonna do that then. |
Note that I'm currently refactoring the codegen backends quite a lot. So if you don't mind, I'd try to prepare this once that refactoring is done. |
Even the |
Yeah, that too a little bit. |
Part of rust-lang/compiler-team#891.
This PR does two things:
However, if you try it out, compilation will fail, hence why I didn't update the CI yet. We have a sync in progress to fix these bugs. If you want to try it, you can use this branch which includes commits from the current cg_gcc sync.
r? @Kobzol