-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Allow overwriting the sysroot compile flag via --rustc-args #112435
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
My impression based on the Zulip thread is that the best way for this to be done out-of-tree is for you to build a proper sysroot for the stage0 rustc, such that you don't need --sysroot to redirect it elsewhere. That would look something like copying the full directory (bin, lib, etc.) into a different location and then replacing its regular target-specific load path with the one you want. (Most of that could be hardlinked if you wanted to avoid extra disk space, at least on Linux). If that doesn't work, then I'd prefer to see a patch like this instead in rustbuild/bootstrap where we're computing the initial-sysroot in the first place. One option there is to pass the rustflags (e.g. RUSTFLAGS_BOOTSTRAP) to the rustc we're running to get the sysroot, where you could then pass --sysroot X at that stage. That would mean that e.g. compiletest will get built with that sysroot, I think, but that seems OK? Presumably if you're running tests you're comfortable with that too. |
I'm not sure I understand. Do you suggest I copy the gcc-built sysroot from
Again, I'm not sure I understand, so I might be wrong here. Wouldn't that require to build rustc? |
I don't think that's quite right. The default stage0 sysroot we're passing is $(rustc --print sysroot), so you would copy into $tmp/sysroot from ~/.rustup/toolchains/... (based on Zulip) and build_sysroot into the right directories.
No, I don't think you would need to build rustc for this. It's essentially a different approach to the copying, I think. |
I still don't understand.
The codegen builds the sysroot into Why would you copy from
You said this would build |
$tmp is a random directory. Based on Zulip, I am under the impression that you configure (via config.toml) bootstrap/rustbuild to use ~/.rustup/toolchains/nightly-... as your stage0 compiler, but for tests you are telling that compiler to use a different sysroot (via `--sysroot). I am suggesting that instead of trying to alter the behavior of the compiler via --sysroot, you create a directory containing the necessary artifacts so that the compiler's own detection logic suffices, which will avoid needing any patches to the Rust tree (as far as I can tell). Yes, |
Where would this directory needs to be to be detected by rustc? Where is this detection logic? |
You don't need to pass rust/compiler/rustc_session/src/filesearch.rs Lines 203 to 205 in d0ee190
|
I'm still confused.
and the |
cp -r /home/user/.rustup/toolchains/nightly-2023-06-03-x86_64-unknown-linux-gnu/ foo (where foo didn't exist previously), then adjust the contents as needed (e.g., replacing lib/rustlib/$target/lib or so). |
This doesn't seem to work. The sysroot used by the UI tests is the following:
So it's not the one in |
Let's see if you can instead update this PR to allow overwriting the sysroot. |
Locally when I run x.py test --stage 0 I see compiletest get passed My point is that we should not need any changes in this repository to enable you to do what you want, so updating this PR does not make sense. |
Maybe this is the misunderstanding. I don't want to pass the sysroot to compiletest. I want compiletest to send a different sysroot to the UI tests. I test with the following command:
|
--sysroot-base is the argument that compiletest is using to determine which sysroot should get passed during compilation of tests: rust/src/tools/compiletest/src/runtest.rs Line 1956 in 34d64ab
|
This is exactly the code that this PR changed, so I'm not sure I understand your point. Edit:
so something must be wrong. Does this config look good to you: changelog-seen = 2
[rust]
codegen-backends = []
deny-warnings = false
[build]
cargo = "/home/user/.rustup/toolchains/my_toolchain/bin/cargo"
local-rebuild = true
rustc = "/home/user/.rustup/toolchains/my_toolchain/bin/rustc"
[target.x86_64-unknown-linux-gnu]
llvm-filecheck = ""
[llvm]
download-ci-llvm = false |
Line 1430 in 34d64ab
"/home/user/.rustup/toolchains/my_toolchain/bin/rustc" --print sysroot ...
I'm not sure what is wrong. I guess the best bet is for you to debug on your end and try to figure out what is causing us to pass stage0-sysroot. |
Ok, I understood what you mean and I can now pass the correct sysroot. However, I cannot build bootstrap anymore: Since this issue was probably there for a long time and I might not be able to fix it quickly, I'd like to continue with this PR. Anything you'd like me to change in this PR? |
@bors r+ Seems ok for now, but let's try to get that fixed soon. |
Thanks. What would you suggest as a proper fix? |
…Mark-Simulacrum Allow overwriting the sysroot compile flag via --rustc-args Hi. As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/How.20to.20overwrite.20sysroot.20in.20x.2Epy.20test/near/364272269), this is a solution to allow the codegens to overwrite the sysroot as part of their test suite. Thanks for the review.
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#110805 (Github action to periodically `cargo update` to keep dependencies current) - rust-lang#112435 (Allow overwriting the sysroot compile flag via --rustc-args) - rust-lang#112610 (Bump stdarch) - rust-lang#112619 (Suggest bumping download-ci-llvm-stamp if the build config for llvm changes) - rust-lang#112738 (make ice msg "Unknown runtime phase" a bit nicer) r? `@ghost` `@rustbot` modify labels: rollup
Hi.
As discussed on Zulip, this is a solution to allow the codegens to overwrite the sysroot as part of their test suite.
Thanks for the review.