Skip to content

Commit 30b9f70

Browse files
committed
document RUSTC_BOOTSTRAP in the unstable book
1 parent 414da5b commit 30b9f70

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# `RUSTC_BOOTSTRAP`
2+
3+
This feature is perma-unstable and has no tracking issue.
4+
5+
----
6+
7+
The `RUSTC_BOOTSTRAP` environment variable tells rustc to act as if it is a nightly compiler;
8+
in particular, it allows `#![feature(...)]` attributes and `-Z` flags even on the stable release channel.
9+
10+
Setting `RUSTC_BOOTSTRAP=crate_name` instructs rustc to only apply this to crates named `crate_name`.
11+
Setting `RUSTC_BOOTSTRAP=-1` instructs rustc to act as if it is a stable compiler, even on the nightly release channel.
12+
Cargo disallows setting `cargo::rustc-env=RUSTC_BOOTSTRAP` in build scripts.
13+
Crates can fully opt out of unstable features by using `#![forbid(unstable_features)]` at the crate root (or any other way of enabling lints, such as `-F unstable-features`).
14+
15+
## Why does this environment variable exist?
16+
17+
`RUSTC_BOOTSTRAP`, as the name suggests, is used for bootstrapping the compiler from an earlier version.
18+
In particular, nightly is built with beta, and beta is built with stable.
19+
Since the standard library and compiler both use unstable features, `RUSTC_BOOTSTRAP` is required so that we can use the previous version to build them.
20+
21+
## Why is this environment variable so easy to use for people not in the rust project?
22+
23+
Originally, `RUSTC_BOOTSTRAP` required passing in a hash of the previous compiler version, to discourage using it for any purpose other than bootstrapping.
24+
That constraint was later relaxed; see <https://github.com/rust-lang/rust/issues/36548> for the discussion that happened at that time.
25+
26+
People have at various times proposed re-adding the technical constraints.
27+
However, doing so is extremely disruptive for several major projects that we very much want to keep using the latest toolchain versions, such as Firefox, Rust for Linux, and Chromium.
28+
We continue to allow `RUSTC_BOOTSTRAP` until we can come up with an alternative that does not disrupt our largest constituents.
29+
30+
## History
31+
32+
- [Allowed without a hash](https://github.com/rust-lang/rust/pull/37265) ([discussion](https://github.com/rust-lang/rust/issues/36548))
33+
- [Extended to crate names](https://github.com/rust-lang/rust/pull/77802) ([discussion](https://github.com/rust-lang/cargo/issues/7088))
34+
- [Disallowed for build scripts](https://github.com/rust-lang/cargo/pull/9181) ([discussion](https://github.com/rust-lang/compiler-team/issues/350))
35+
- [Extended to emulate stable](https://github.com/rust-lang/rust/pull/132993) ([discussion](https://github.com/rust-lang/rust/issues/123404))

0 commit comments

Comments
 (0)