Skip to content

Commit 1a0a5fb

Browse files
committed
Fix libm intrinsics for versions newer that 0.2.11
1 parent 72943b5 commit 1a0a5fb

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ tracing = "0.1"
5959
tracing-subscriber = { version = "0.3.3", features = ["env-filter", "json"] }
6060
num-traits = { version = "0.2.15", default-features = false }
6161
glam = { version = ">=0.22, <=0.30", default-features = false }
62-
# libm 0.2.12 is a breaking change with new intrinsics
63-
libm = { version = ">=0.2.5, <=0.2.11", default-features = false }
62+
libm = { version = ">=0.2.12", default-features = false }
6463
bytemuck = { version = "1.23", features = ["derive"] }
6564

6665
# Enable incremental by default in release mode.

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,14 @@ impl<'tcx> CodegenCx<'tcx> {
161161
.insert(def_id, mode);
162162
}
163163

164-
if self.tcx.crate_name(def_id.krate) == self.sym.libm {
164+
// Check for usage of `libm` intrinsics outside of `libm` itself
165+
if self.tcx.crate_name(def_id.krate) == self.sym.libm && !def_id.is_local() {
165166
let item_name = self.tcx.item_name(def_id);
166-
let intrinsic = self.sym.libm_intrinsics.get(&item_name);
167-
if self.tcx.visibility(def_id) == ty::Visibility::Public {
168-
match intrinsic {
169-
Some(&intrinsic) => {
170-
self.libm_intrinsics.borrow_mut().insert(def_id, intrinsic);
171-
}
172-
None => {
173-
self.tcx.dcx().err(format!(
174-
"missing libm intrinsic {symbol_name}, which is {instance}"
175-
));
176-
}
177-
}
167+
if let Some(&intrinsic) = self.sym.libm_intrinsics.get(&item_name) {
168+
self.libm_intrinsics.borrow_mut().insert(def_id, intrinsic);
169+
} else {
170+
let message = format!("missing libm intrinsic {symbol_name}, which is {instance}");
171+
self.tcx.dcx().err(message);
178172
}
179173
}
180174

0 commit comments

Comments
 (0)