Skip to content

Commit 9cc78b2

Browse files
committed
Check function crate name
I think local onlyt applies when you are compiling a crate directly? To be safe check the fn's crate as well.
1 parent abfeb7b commit 9cc78b2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crates/rustc_codegen_nvvm/src/override_fns.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ fn should_override<'tcx>(func: Instance<'tcx>, cx: &CodegenCx<'_, 'tcx>) -> bool
3333
}
3434

3535
// there is no better way to do this without putting some sort of diagnostic/lang item in libm
36-
let is_libm = cx.tcx.crate_name(LOCAL_CRATE).as_str() == "libm";
36+
let func_crate_name = cx.tcx.crate_name(func.def_id().krate).as_str();
37+
let local_crate_name = cx.tcx.crate_name(LOCAL_CRATE).as_str();
38+
let is_libm = func_crate_name == "libm" || local_crate_name == "libm";
3739
if !is_libm {
3840
return false;
3941
}

0 commit comments

Comments
 (0)