Skip to content

Commit 51dc52b

Browse files
committed
Auto merge of #61494 - Mark-Simulacrum:move-to-cfg-bootstrap, r=alexcrichton
Utilize cfg(bootstrap) over cfg(stage0) Also removes stage1, stage2 cfgs being passed to rustc to ensure that stage1 and stage2 are only differentiated as a group (i.e., only through not bootstrap). Fixes #53582 r? @alexcrichton
2 parents daf1ed0 + bea2e55 commit 51dc52b

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

src/bootstrap/bin/rustc.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ fn main() {
8989

9090
let mut cmd = Command::new(rustc);
9191
cmd.args(&args)
92-
.arg("--cfg")
93-
.arg(format!("stage{}", stage))
9492
.env(bootstrap::util::dylib_path_var(),
9593
env::join_paths(&dylib_path).unwrap());
9694
let mut maybe_crate = None;
9795

96+
// Non-zero stages must all be treated uniformly to avoid problems when attempting to uplift
97+
// compiler libraries and such from stage 1 to 2.
98+
if stage == "0" {
99+
cmd.arg("--cfg").arg("bootstrap");
100+
}
101+
98102
// Print backtrace in case of ICE
99103
if env::var("RUSTC_BACKTRACE_ON_ICE").is_ok() && env::var("RUST_BACKTRACE").is_err() {
100104
cmd.env("RUST_BACKTRACE", "1");

src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl Step for StartupObjects {
341341
if !up_to_date(src_file, dst_file) {
342342
let mut cmd = Command::new(&builder.initial_rustc);
343343
builder.run(cmd.env("RUSTC_BOOTSTRAP", "1")
344-
.arg("--cfg").arg("stage0")
344+
.arg("--cfg").arg("bootstrap")
345345
.arg("--target").arg(target)
346346
.arg("--emit=obj")
347347
.arg("-o").arg(dst_file)

src/libcore/intrinsics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1242,17 +1242,17 @@ extern "rust-intrinsic" {
12421242

12431243
/// Returns the result of an unchecked addition, resulting in
12441244
/// undefined behavior when `x + y > T::max_value()` or `x + y < T::min_value()`.
1245-
#[cfg(not(stage0))]
1245+
#[cfg(not(bootstrap))]
12461246
pub fn unchecked_add<T>(x: T, y: T) -> T;
12471247

12481248
/// Returns the result of an unchecked substraction, resulting in
12491249
/// undefined behavior when `x - y > T::max_value()` or `x - y < T::min_value()`.
1250-
#[cfg(not(stage0))]
1250+
#[cfg(not(bootstrap))]
12511251
pub fn unchecked_sub<T>(x: T, y: T) -> T;
12521252

12531253
/// Returns the result of an unchecked multiplication, resulting in
12541254
/// undefined behavior when `x * y > T::max_value()` or `x * y < T::min_value()`.
1255-
#[cfg(not(stage0))]
1255+
#[cfg(not(bootstrap))]
12561256
pub fn unchecked_mul<T>(x: T, y: T) -> T;
12571257

12581258
/// Performs rotate left.

src/libcore/num/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", s
5050
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5151
#[repr(transparent)]
5252
#[rustc_layout_scalar_valid_range_start(1)]
53-
#[cfg_attr(not(stage0), rustc_nonnull_optimization_guaranteed)]
53+
#[cfg_attr(not(bootstrap), rustc_nonnull_optimization_guaranteed)]
5454
pub struct $Ty($Int);
5555
}
5656

src/libcore/ptr/non_null.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::cmp::Ordering;
3838
#[stable(feature = "nonnull", since = "1.25.0")]
3939
#[repr(transparent)]
4040
#[rustc_layout_scalar_valid_range_start(1)]
41-
#[cfg_attr(not(stage0), rustc_nonnull_optimization_guaranteed)]
41+
#[cfg_attr(not(bootstrap), rustc_nonnull_optimization_guaranteed)]
4242
pub struct NonNull<T: ?Sized> {
4343
pointer: *const T,
4444
}

0 commit comments

Comments
 (0)