From f7226acce9761a3b82cd80099b0d09f201715274 Mon Sep 17 00:00:00 2001 From: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com> Date: Sun, 11 Feb 2024 18:03:42 +0800 Subject: [PATCH 1/3] Remove unneeded `extern core` in `tgamma` --- src/math/tgamma.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/math/tgamma.rs b/src/math/tgamma.rs index e64eff61f..3f38c0b1d 100644 --- a/src/math/tgamma.rs +++ b/src/math/tgamma.rs @@ -22,7 +22,6 @@ Gamma(x)*Gamma(-x) = -pi/(x sin(pi x)) most ideas and constants are from boost and python */ -extern crate core; use super::{exp, floor, k_cos, k_sin, pow}; const PI: f64 = 3.141592653589793238462643383279502884; From 28d0f1213914f340dda2617e526a8befb7bdd1e1 Mon Sep 17 00:00:00 2001 From: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com> Date: Sun, 18 Feb 2024 21:23:20 +0800 Subject: [PATCH 2/3] Fix compilation errors from 5e0eca75f The commit 5e0eca75fb14a93ec84cb3c36a90fa7d366b245e removed the `checked` feature and replaced it by using `debug_assertions`. There were some places that were not modified, this commit fixes them --- build.rs | 2 +- src/math/rem_pio2_large.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 80145a9cc..af4793e90 100644 --- a/build.rs +++ b/build.rs @@ -6,7 +6,7 @@ fn main() { #[cfg(feature = "musl-reference-tests")] musl_reference_tests::generate(); - if !cfg!(feature = "checked") { + if !cfg!(debug_assertions) { let lvl = env::var("OPT_LEVEL").unwrap(); if lvl != "0" { println!("cargo:rustc-cfg=assert_no_panic"); diff --git a/src/math/rem_pio2_large.rs b/src/math/rem_pio2_large.rs index db97a39d4..9de3a0002 100644 --- a/src/math/rem_pio2_large.rs +++ b/src/math/rem_pio2_large.rs @@ -227,7 +227,7 @@ pub(crate) fn rem_pio2_large(x: &[f64], y: &mut [f64], e0: i32, prec: usize) -> let x1p24 = f64::from_bits(0x4170000000000000); // 0x1p24 === 2 ^ 24 let x1p_24 = f64::from_bits(0x3e70000000000000); // 0x1p_24 === 2 ^ (-24) - #[cfg(all(target_pointer_width = "64", feature = "checked"))] + #[cfg(all(target_pointer_width = "64", debug_assertions))] assert!(e0 <= 16360); let nx = x.len(); From 9ded10304060e82d5cb71fcf8ae99a9538802c65 Mon Sep 17 00:00:00 2001 From: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com> Date: Sun, 18 Feb 2024 21:24:30 +0800 Subject: [PATCH 3/3] Add `rustc-dep-of-std` feature to allow compiling for `std` Since `std` dependencies cannot use `core` manually, it has to include it manually as a dependencies from the package `rustc-std-workspace-core`. This allow us to use `libm` to compile a dependency of `std`. This fixes the issue https://github.com/rust-lang/compiler-builtins/issues/576 --- Cargo.toml | 11 +++++++++++ build.rs | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index d33ca61cd..e93a61af3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,12 @@ version = "0.2.8" edition = "2018" exclude = ["/ci/", "/.github/workflows/"] +[dependencies] +# Internal feature, only used when building as part of libstd, not part of the +# stable interface of this crate. +core = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-core' } +compiler_builtins = { version = '0.1.2', optional = true } + [features] default = [] @@ -23,6 +29,11 @@ unstable = [] # musl libc. musl-reference-tests = ['rand'] + +# Internal feature, only used when building as part of libstd, not part of the +# stable interface of this crate. +rustc-dep-of-std = ['core', 'compiler_builtins'] + [workspace] members = [ "crates/compiler-builtins-smoke-test", diff --git a/build.rs b/build.rs index af4793e90..c7614fb44 100644 --- a/build.rs +++ b/build.rs @@ -12,6 +12,11 @@ fn main() { println!("cargo:rustc-cfg=assert_no_panic"); } } + // add cfg flags to suppress warnings generated from compiling `std` specifically + if cfg!(feature = "rustc-dep-of-std") { + println!("cargo:rustc-check-cfg=cfg(rustfmt)"); + println!("cargo:rustc-check-cfg=cfg(assert_no_panic)"); + } } #[cfg(feature = "musl-reference-tests")]