From 892ef6fa48bd20c037351e0cf8ea12c4c429a868 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 16 Aug 2019 20:12:10 +0300 Subject: [PATCH] rustbuild: work around the stdarch cfg(bootstrap) bug. --- src/bootstrap/bin/rustc.rs | 9 +++++++-- src/libcore/intrinsics.rs | 12 ++++++------ src/libcore/num/mod.rs | 24 ++++++++++++------------ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 9c01de8aa8251..d7887f74cc1c0 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -102,8 +102,13 @@ fn main() { // FIXME: the fact that core here is excluded is due to core_arch from our stdarch submodule // being broken on the beta compiler with bootstrap passed, so this is a temporary workaround // (we've just snapped, so there are no cfg(bootstrap) related annotations in core). - if stage == "0" && crate_name != Some("core") { - cmd.arg("--cfg").arg("bootstrap"); + if stage == "0" { + if crate_name != Some("core") { + cmd.arg("--cfg").arg("bootstrap"); + } else { + // NOTE(eddyb) see FIXME above, except now we need annotations again in core. + cmd.arg("--cfg").arg("boostrap_stdarch_ignore_this"); + } } // Print backtrace in case of ICE diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 995ee56440ea5..d145f2212f93a 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1293,38 +1293,38 @@ extern "rust-intrinsic" { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `wrapping_add` method. For example, /// [`std::u32::wrapping_add`](../../std/primitive.u32.html#method.wrapping_add) - #[cfg(bootstrap)] + #[cfg(boostrap_stdarch_ignore_this)] pub fn overflowing_add(a: T, b: T) -> T; /// Returns (a - b) mod 2N, where N is the width of T in bits. /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `wrapping_sub` method. For example, /// [`std::u32::wrapping_sub`](../../std/primitive.u32.html#method.wrapping_sub) - #[cfg(bootstrap)] + #[cfg(boostrap_stdarch_ignore_this)] pub fn overflowing_sub(a: T, b: T) -> T; /// Returns (a * b) mod 2N, where N is the width of T in bits. /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `wrapping_mul` method. For example, /// [`std::u32::wrapping_mul`](../../std/primitive.u32.html#method.wrapping_mul) - #[cfg(bootstrap)] + #[cfg(boostrap_stdarch_ignore_this)] pub fn overflowing_mul(a: T, b: T) -> T; /// Returns (a + b) mod 2N, where N is the width of T in bits. /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `wrapping_add` method. For example, /// [`std::u32::wrapping_add`](../../std/primitive.u32.html#method.wrapping_add) - #[cfg(not(bootstrap))] + #[cfg(not(boostrap_stdarch_ignore_this))] pub fn wrapping_add(a: T, b: T) -> T; /// Returns (a - b) mod 2N, where N is the width of T in bits. /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `wrapping_sub` method. For example, /// [`std::u32::wrapping_sub`](../../std/primitive.u32.html#method.wrapping_sub) - #[cfg(not(bootstrap))] + #[cfg(not(boostrap_stdarch_ignore_this))] pub fn wrapping_sub(a: T, b: T) -> T; /// Returns (a * b) mod 2N, where N is the width of T in bits. /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `wrapping_mul` method. For example, /// [`std::u32::wrapping_mul`](../../std/primitive.u32.html#method.wrapping_mul) - #[cfg(not(bootstrap))] + #[cfg(not(boostrap_stdarch_ignore_this))] pub fn wrapping_mul(a: T, b: T) -> T; /// Computes `a + b`, while saturating at numeric bounds. diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index f82d94153e846..b46e06f8d8ada 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1112,11 +1112,11 @@ $EndFeature, " without modifying the original"] #[inline] pub const fn wrapping_add(self, rhs: Self) -> Self { - #[cfg(bootstrap)] { + #[cfg(boostrap_stdarch_ignore_this)] { intrinsics::overflowing_add(self, rhs) } - #[cfg(not(bootstrap))] { + #[cfg(not(boostrap_stdarch_ignore_this))] { intrinsics::wrapping_add(self, rhs) } } @@ -1141,11 +1141,11 @@ $EndFeature, " without modifying the original"] #[inline] pub const fn wrapping_sub(self, rhs: Self) -> Self { - #[cfg(bootstrap)] { + #[cfg(boostrap_stdarch_ignore_this)] { intrinsics::overflowing_sub(self, rhs) } - #[cfg(not(bootstrap))] { + #[cfg(not(boostrap_stdarch_ignore_this))] { intrinsics::wrapping_sub(self, rhs) } } @@ -1169,11 +1169,11 @@ $EndFeature, " without modifying the original"] #[inline] pub const fn wrapping_mul(self, rhs: Self) -> Self { - #[cfg(bootstrap)] { + #[cfg(boostrap_stdarch_ignore_this)] { intrinsics::overflowing_mul(self, rhs) } - #[cfg(not(bootstrap))] { + #[cfg(not(boostrap_stdarch_ignore_this))] { intrinsics::wrapping_mul(self, rhs) } } @@ -3049,11 +3049,11 @@ $EndFeature, " without modifying the original"] #[inline] pub const fn wrapping_add(self, rhs: Self) -> Self { - #[cfg(bootstrap)] { + #[cfg(boostrap_stdarch_ignore_this)] { intrinsics::overflowing_add(self, rhs) } - #[cfg(not(bootstrap))] { + #[cfg(not(boostrap_stdarch_ignore_this))] { intrinsics::wrapping_add(self, rhs) } } @@ -3077,11 +3077,11 @@ $EndFeature, " without modifying the original"] #[inline] pub const fn wrapping_sub(self, rhs: Self) -> Self { - #[cfg(bootstrap)] { + #[cfg(boostrap_stdarch_ignore_this)] { intrinsics::overflowing_sub(self, rhs) } - #[cfg(not(bootstrap))] { + #[cfg(not(boostrap_stdarch_ignore_this))] { intrinsics::wrapping_sub(self, rhs) } } @@ -3106,11 +3106,11 @@ $EndFeature, " without modifying the original"] #[inline] pub const fn wrapping_mul(self, rhs: Self) -> Self { - #[cfg(bootstrap)] { + #[cfg(boostrap_stdarch_ignore_this)] { intrinsics::overflowing_mul(self, rhs) } - #[cfg(not(bootstrap))] { + #[cfg(not(boostrap_stdarch_ignore_this))] { intrinsics::wrapping_mul(self, rhs) } }