Skip to content

Conversation

@CrooseGit
Copy link
Contributor

cc rust-lang/rfcs#3874

In the build-std: always RFC, it is proposed that RUSTC_BOOTSTRAP should be implied for compilation of any crate located in the sysroot. As such, Cargo would not need to set RUSTC_BOOTSTRAP for build-std, but also external projects like Rust for Linux that build core from the rust-src component could do so on a stable toolchain.

This functionality is only intended for use with unmodified standard library sources, and that should probably be document somewhere but I'm not sure where - RUSTC_BOOTSTRAP is mentioned in the unstable book, maybe with that? It might make more sense in the rustc book but there's not an obvious spot.

As rust-lang/rfcs#3874 is not yet accepted, if this warrants an MCP to be implemented in the interim, then I'd be happy to submit one.

It is unclear exactly how to test this, as it would require rustc be from a stable toolchain to test the relevant behaviours, and that's not how the test suite is set up. None of the current tests for RUSTC_BOOTSTRAP can be adapted for this.

r? @wesleywiser

When the input to rustc is within rustc's sysroot, then unstable
features should be enabled as they would be with `RUSTC_BOOTSTRAP=1`.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 26, 2026
@petrochenkov petrochenkov self-assigned this Jan 26, 2026
@Mark-Simulacrum
Copy link
Member

Setting RUSTC_BOOTSTRAP=-1 instructs rustc to act as if it is a stable compiler, even on the nightly release channel.

Quoting the docs, doesn't this let you write a test that checks this works?

@CrooseGit
Copy link
Contributor Author

Setting RUSTC_BOOTSTRAP=-1 instructs rustc to act as if it is a stable compiler, even on the nightly release channel.

Quoting the docs, doesn't this let you write a test that checks this works?

This patch is implemented such that RUSTC_BOOTSTRAP is honoured first, and then if unset the check goes ahead to see if the input is in the sysroot; as such, setting RUSTC_BOOTSTRAP=-1 to give us a 'stable' compiler to test would override the patch's logic. It could be modified to ignore RUSTC_BOOTSTRAP when the input is in the sysroot / allow RUSTC_BOOTSTRAP=-1 to be overridden if that would be the preferred behaviour?

@bjorn3
Copy link
Member

bjorn3 commented Jan 26, 2026

If we decode to take the approach from rust-lang/rfcs#3874 (comment), then rustc-build-sysroot can set RUSTC_BOOTSTRAP and rustc shouldn't implicitly enable RUSTC_BOOTSTRAP for source files inside the sysroot.

Also the sysroot needs to be compiled with -Zforce-unstable-if-unmarked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants