Skip to content

Commit e36fdd7

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

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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=1` instructs rustc to enable this for all crates.
11+
Setting `RUSTC_BOOTSTRAP=crate_name` instructs rustc to only apply this to crates named `crate_name`.
12+
Setting `RUSTC_BOOTSTRAP=-1` instructs rustc to act as if it is a stable compiler, even on the nightly release channel.
13+
Cargo disallows setting `cargo::rustc-env=RUSTC_BOOTSTRAP` in build scripts.
14+
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`).
15+
16+
## Why does this environment variable exist?
17+
18+
`RUSTC_BOOTSTRAP`, as the name suggests, is used for bootstrapping the compiler from an earlier version.
19+
In particular, nightly is built with beta, and beta is built with stable.
20+
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.
21+
22+
## Why is this environment variable so easy to use for people not in the rust project?
23+
24+
Originally, `RUSTC_BOOTSTRAP` required passing in a hash of the previous compiler version, to discourage using it for any purpose other than bootstrapping.
25+
That constraint was later relaxed; see <https://github.com/rust-lang/rust/issues/36548> for the discussion that happened at that time.
26+
27+
People have at various times proposed re-adding the technical constraints.
28+
However, doing so is extremely disruptive for several major projects that we very much want to keep using the latest stable toolchain version, such as Firefox, Rust for Linux, and Chromium.
29+
We continue to allow `RUSTC_BOOTSTRAP` until we can come up with an alternative that does not disrupt our largest constituents.
30+
31+
## Stability policy
32+
33+
Like any other unstable feature, we reserve the right to change or remove this feature in the future, as well as any other unstable feature that it enables.
34+
Although we do not take technical measures to prevent it from being used, we strongly discourage using this feature.
35+
If at all possible, please contribute to stabilizing the features you care about instead of bypassing the Rust project's stability policy.
36+
37+
## History
38+
39+
- [Allowed without a hash](https://github.com/rust-lang/rust/pull/37265) ([discussion](https://github.com/rust-lang/rust/issues/36548))
40+
- [Extended to crate names](https://github.com/rust-lang/rust/pull/77802) ([discussion](https://github.com/rust-lang/cargo/issues/7088))
41+
- [Disallowed for build scripts](https://github.com/rust-lang/cargo/pull/9181) ([discussion](https://github.com/rust-lang/compiler-team/issues/350))
42+
- [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)