Rollup merge of #120167 - dtolnay:bootstrap, r=clubby789

Capture the rationale for `-Zallow-features=` in bootstrap.py

Based on the discussion in https://github.com/rust-lang/rust/pull/120096.
This commit is contained in:
Matthias Krüger 2024-01-21 12:28:54 +01:00 committed by GitHub
commit ac713695f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -924,17 +924,29 @@ class RustBuild(object):
# default toolchain is not nightly. # default toolchain is not nightly.
# #
# But that setting has the collateral effect of rust-analyzer also # But that setting has the collateral effect of rust-analyzer also
# passing RUSTC_BOOTSTRAP=1 to all x.py invocations too (the various overrideCommand). # passing RUSTC_BOOTSTRAP=1 to all x.py invocations too (the various
# For compiling bootstrap that can cause spurious rebuilding of bootstrap when # overrideCommand).
# rust-analyzer x.py invocations are interleaved with handwritten ones on the
# command line.
# #
# Set RUSTC_BOOTSTRAP=1 consistently. # Set a consistent RUSTC_BOOTSTRAP=1 here to prevent spurious rebuilds
# of bootstrap when rust-analyzer x.py invocations are interleaved with
# handwritten ones on the command line.
env["RUSTC_BOOTSTRAP"] = "1" env["RUSTC_BOOTSTRAP"] = "1"
default_rustflags = "" if env.get("RUSTFLAGS_BOOTSTRAP", "") else "-Zallow-features=" # If any of RUSTFLAGS or RUSTFLAGS_BOOTSTRAP are present and nonempty,
# we allow arbitrary compiler flags in there, including unstable ones
env.setdefault("RUSTFLAGS", default_rustflags) # such as `-Zthreads=8`.
#
# But if there aren't custom flags being passed to bootstrap, then we
# cancel the RUSTC_BOOTSTRAP=1 from above by passing `-Zallow-features=`
# to ensure unstable language or library features do not accidentally
# get introduced into bootstrap over time. Distros rely on being able to
# compile bootstrap with a variety of their toolchains, not necessarily
# the same as Rust's CI uses.
if env.get("RUSTFLAGS", "") or env.get("RUSTFLAGS_BOOTSTRAP", ""):
# Preserve existing RUSTFLAGS.
env.setdefault("RUSTFLAGS", "")
else:
env["RUSTFLAGS"] = "-Zallow-features="
target_features = [] target_features = []
if self.get_toml("crt-static", build_section) == "true": if self.get_toml("crt-static", build_section) == "true":