diff --git a/compiler/generator/rust/rust_code_container.cpp b/compiler/generator/rust/rust_code_container.cpp index 36bfa26198..c9c81ee5b0 100644 --- a/compiler/generator/rust/rust_code_container.cpp +++ b/compiler/generator/rust/rust_code_container.cpp @@ -178,11 +178,14 @@ void RustCodeContainer::produceClass() // Missing math functions // See: https://users.rust-lang.org/t/analog-of-c-std-remainder/59670 if (gGlobal->gFloatSize == 1) { + *fOut << "mod ffi {"; tab(n + 1, *fOut); *fOut << "use std::os::raw::{c_float};"; tab(n + 1, *fOut); - *fOut << "#[link(name = \"m\")]"; + *fOut << "// Conditionally compile the link attribute only on non-Windows platforms"; + tab(n + 1, *fOut); + *fOut << "#[cfg_attr(not(target_os=\"windows\"), link(name=\"m\"))]"; tab(n + 1, *fOut); *fOut << "extern {"; tab(n + 2, *fOut); @@ -206,12 +209,21 @@ void RustCodeContainer::produceClass() tab(n, *fOut); *fOut << "}"; tab(n, *fOut); + + /* + tab(n, *fOut); + *fOut << "fn remainder_f32(a: f32, b: f32) -> f32 { let n = (a/b).round(); a - b*n }"; + tab(n, *fOut); + */ } else if (gGlobal->gFloatSize == 2) { + *fOut << "mod ffi {"; tab(n + 1, *fOut); *fOut << "use std::os::raw::{c_double};"; tab(n + 1, *fOut); - *fOut << "#[link(name = \"m\")]"; + *fOut << "// Conditionally compile the link attribute only on non-Windows platforms"; + tab(n + 1, *fOut); + *fOut << "#[cfg_attr(not(target_os=\"windows\"), link(name=\"m\"))]"; tab(n + 1, *fOut); *fOut << "extern {"; tab(n + 2, *fOut); @@ -235,8 +247,15 @@ void RustCodeContainer::produceClass() tab(n, *fOut); *fOut << "}"; tab(n, *fOut); + + /* + tab(n, *fOut); + *fOut << "fn remainder_f64(a: f64, b: f64) -> f64 { let n = (a/b).round(); a - b*n }"; + tab(n, *fOut); + */ } + tab(n, *fOut); *fOut << "#[cfg_attr(feature = \"default-boxed\", derive(default_boxed::DefaultBoxed))]"; if (gGlobal->gReprC) { diff --git a/tools/faust-config b/tools/faust-config index 477e9705f3..838903060d 100755 --- a/tools/faust-config +++ b/tools/faust-config @@ -38,7 +38,7 @@ function get { esac } -SYSTEMLIBS="-lm -lz -lzstd -lcurses -lxml2" +SYSTEMLIBS="-lm -lz -lcurses -lxml2" if [ "$#" -eq 0 ] then