Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve monomorphization errors in compiler-builtins #524

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ exclude = [
[dev-dependencies]
no-panic = "0.1.33"


[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
# compiler-builtins sets this feature, but we use it in `libm`
'cfg(feature, values("compiler-builtins"))',
] }

# The default release profile is unchanged.

# Release mode with debug assertions
Expand Down
1 change: 1 addition & 0 deletions crates/compiler-builtins-smoke-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
"cfg(arch_enabled)",
"cfg(assert_no_panic)",
"cfg(intrinsics_enabled)",
'cfg(feature, values("compiler-builtins"))',
'cfg(feature, values("force-soft-floats"))',
'cfg(feature, values("unstable"))',
'cfg(feature, values("unstable-intrinsics"))',
Expand Down
2 changes: 2 additions & 0 deletions crates/compiler-builtins-smoke-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
//! Additionally, it provides a `#[no_mangle]` C API that can be easier to inspect than the
//! default `.rlib`.

#![compiler_builtins]
#![feature(core_intrinsics)]
#![feature(compiler_builtins)]
#![feature(f16)]
#![feature(f128)]
#![allow(internal_features)]
Expand Down
16 changes: 14 additions & 2 deletions src/math/support/hex_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,13 @@ fn fmt_any_hex<F: Float>(x: &F, f: &mut fmt::Formatter<'_>) -> fmt::Result {

impl<F: Float> fmt::LowerHex for Hexf<F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt_any_hex(&self.0, f)
cfg_if! {
if #[cfg(feature = "compiler-builtins")] {
unreachable!()
} else {
fmt_any_hex(&self.0, f)
}
}
}
}

Expand All @@ -264,7 +270,13 @@ impl<F: Float> fmt::LowerHex for Hexf<(F, i32)> {

impl fmt::LowerHex for Hexf<i32> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::LowerHex::fmt(&self.0, f)
cfg_if! {
if #[cfg(feature = "compiler-builtins")] {
unreachable!()
} else {
fmt::LowerHex::fmt(&self.0, f)
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/math/support/int_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ macro_rules! cast_into_float {
($ty:ty; $($into:ty),*) => {$(
impl CastInto<$into> for $ty {
fn cast(self) -> $into {
#[cfg(not(feature = "compiler-builtins"))]
debug_assert_eq!(self as $into as $ty, self, "inexact float cast");
self as $into
}
Expand Down
Loading