diff --git a/Cargo.lock b/Cargo.lock index 3b4408e..3623c5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1010,6 +1010,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "libredox" version = "0.1.3" @@ -1945,6 +1951,7 @@ dependencies = [ "acpi", "built", "goblin", + "libm", "log", "multiboot12", "scroll", diff --git a/towboot/Cargo.toml b/towboot/Cargo.toml index e082f58..ded8509 100644 --- a/towboot/Cargo.toml +++ b/towboot/Cargo.toml @@ -26,5 +26,9 @@ scroll = { version = "0.12", default-features = false } towboot_config = { path = "../towboot_config" } +# i686-unknown-uefi currently lacks float functions, see hacks.rs +[target.'cfg(target_arch = "x86")'.dependencies] +libm = "0.2" + [build-dependencies] built = { version = "0.7", features = ["git2"] } diff --git a/towboot/src/hacks.rs b/towboot/src/hacks.rs index 5c44bd7..2f6619d 100644 --- a/towboot/src/hacks.rs +++ b/towboot/src/hacks.rs @@ -5,19 +5,18 @@ //! This module contains missing symbols. //! //! The fmod and fmodf functions are [currently missing](https://github.com/rust-lang/rust/issues/128533) -//! on i686-unknown-uefi. In the long run, this should be fixed in -//! `compiler_builtins`. For now, this monkeypatching seems to be enough. +//! on i686-unknown-uefi, so let's use the ones of libm. +//! In the long run, this should be fixed in `compiler_builtins`. +//! For now, this monkeypatching seems to be enough. //! //! see https://github.com/rust-lang/compiler-builtins/blob/master/src/math.rs -//! We could also use libm::fmod{,f} here, but then we'd need __truncdfsf2. -//! Let's just hope they are never called. #[cfg(target_arch = "x86")] #[no_mangle] -pub extern "C" fn fmod(_x: f64, _y: f64) -> f64 { - unimplemented!(); +pub extern "C" fn fmod(x: f64, y: f64) -> f64 { + libm::fmod(x, y) } #[cfg(target_arch = "x86")] #[no_mangle] -pub extern "C" fn fmodf(_x: f32, _y: f32) -> f32 { - unimplemented!(); +pub extern "C" fn fmodf(x: f32, y: f32) -> f32 { + libm::fmodf(x, y) }