Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

fix(no_std): use libm to polyfill riscv64 powi function (#13479)

Jonas Kruckenbergea9d1fedfdec
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 9b0b67249b..a7dfd3249f 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -605,7 +605,7 @@ jobs:
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,pulley,async,debug,debug-builtins,demangle,anyhow &&
cargo check -p cranelift-control --no-default-features &&
cargo check -p cranelift-assembler-x64 --lib &&
- cargo check -p cranelift-codegen --no-default-features --features x86,arm64 &&
+ cargo check -p cranelift-codegen --no-default-features --features x86,arm64,riscv64 &&
cargo check -p cranelift-frontend --no-default-features &&
cargo check -p pulley-interpreter --features encode,decode,disas,interp &&
cargo check -p wasmtime-wasi-io --no-default-features
diff --git a/cranelift/codegen/src/isa/riscv64/inst/args.rs b/cranelift/codegen/src/isa/riscv64/inst/args.rs
index cc6e668b91..1f120686c7 100644
--- a/cranelift/codegen/src/isa/riscv64/inst/args.rs
+++ b/cranelift/codegen/src/isa/riscv64/inst/args.rs
@@ -367,10 +367,10 @@ impl FliConstant {
(F32, f) if f == (f32::MIN_POSITIVE as f64) => Self::new(1),
(F64, f) if f == f64::MIN_POSITIVE => Self::new(1),
- (_, f) if f == 2.0f64.powi(-16) => Self::new(2),
- (_, f) if f == 2.0f64.powi(-15) => Self::new(3),
- (_, f) if f == 2.0f64.powi(-8) => Self::new(4),
- (_, f) if f == 2.0f64.powi(-7) => Self::new(5),
+ (_, f) if f == libm::pow(2.0, -16.0) => Self::new(2),
+ (_, f) if f == libm::pow(2.0, -15.0) => Self::new(3),
+ (_, f) if f == libm::pow(2.0, -8.0) => Self::new(4),
+ (_, f) if f == libm::pow(2.0, -7.0) => Self::new(5),
(_, f) if f == 0.0625 => Self::new(6),
(_, f) if f == 0.125 => Self::new(7),
(_, f) if f == 0.25 => Self::new(8),
diff --git a/cranelift/codegen/src/isa/riscv64/mod.rs b/cranelift/codegen/src/isa/riscv64/mod.rs
index f41700825d..21b899d3b5 100644
--- a/cranelift/codegen/src/isa/riscv64/mod.rs
+++ b/cranelift/codegen/src/isa/riscv64/mod.rs
@@ -6,9 +6,11 @@ use crate::isa::riscv64::settings as riscv_settings;
use crate::isa::{
Builder as IsaBuilder, FunctionAlignment, IsaFlagsHashKey, OwnedTargetIsa, TargetIsa,
};
+#[cfg(feature = "unwind")]
+use crate::machinst::CompiledCode;
use crate::machinst::{
- CompiledCode, CompiledCodeStencil, MachInst, MachTextSectionBuilder, Reg, SigSet,
- TextSectionBuilder, VCode, compile,
+ CompiledCodeStencil, MachInst, MachTextSectionBuilder, Reg, SigSet, TextSectionBuilder, VCode,
+ compile,
};
use crate::result::CodegenResult;
use crate::settings::{self as shared_settings, Flags};