Skip to content

Fix libm intrinsics for versions newer than 0.2.11 #364

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

Merged
merged 1 commit into from
Aug 16, 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
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3.3", features = ["env-filter", "json"] }
num-traits = { version = "0.2.15", default-features = false }
glam = { version = ">=0.22, <=0.30", default-features = false }
# libm 0.2.12 is a breaking change with new intrinsics
libm = { version = ">=0.2.5, <=0.2.11", default-features = false }
libm = { version = ">=0.2.5", default-features = false }
bytemuck = { version = "1.23", features = ["derive"] }

# Enable incremental by default in release mode.
Expand Down
20 changes: 7 additions & 13 deletions crates/rustc_codegen_spirv/src/codegen_cx/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,14 @@ impl<'tcx> CodegenCx<'tcx> {
.insert(def_id, mode);
}

if self.tcx.crate_name(def_id.krate) == self.sym.libm {
// Check for usage of `libm` intrinsics outside of `libm` itself
if self.tcx.crate_name(def_id.krate) == self.sym.libm && !def_id.is_local() {
let item_name = self.tcx.item_name(def_id);
let intrinsic = self.sym.libm_intrinsics.get(&item_name);
if self.tcx.visibility(def_id) == ty::Visibility::Public {
match intrinsic {
Some(&intrinsic) => {
self.libm_intrinsics.borrow_mut().insert(def_id, intrinsic);
}
None => {
self.tcx.dcx().err(format!(
"missing libm intrinsic {symbol_name}, which is {instance}"
));
}
}
if let Some(&intrinsic) = self.sym.libm_intrinsics.get(&item_name) {
self.libm_intrinsics.borrow_mut().insert(def_id, intrinsic);
} else {
let message = format!("missing libm intrinsic {symbol_name}, which is {instance}");
self.tcx.dcx().err(message);
}
}

Expand Down
Loading