RazrFalcon / rustybuzz

A complete harfbuzz's shaping algorithm port to Rust
MIT License
498 stars 34 forks source link

Use `core_maths` instead of `libm` #118

Closed RazrFalcon closed 1 day ago

RazrFalcon commented 4 days ago

core_maths should simplify no_std build support. And while it has just one star, it is already used by skrifa and other projects.

CryZe commented 1 day ago

This seems like at least a little bit of a mistake. Without any detection of whether the native libm is available, you always get slow emulated versions of all these functions now. Though arguably, maybe that's something that can be fixed in the libm crate directly? Though that's hard to do without libm being part of the std / core / stdarch / ... set of crates, as that means it can't just lower to LLVM intrinsics.

LaurenzV commented 1 day ago

Could we do:

#[cfg(not(feature = "std"))]
use core_maths::CoreFloat;

and something similar for ttf-parser? Then, the core_maths library only gets used when std is explicitly disabled, while it uses the std one when it's enabled? It will still be in the dependency tree when using std, but it's still better than nothing.

CryZe commented 1 day ago

nvm, the fact that it's a trait with the exact same method names as the ones in std means that the inherent methods have higher priority in name resolution, so it should resolve to the std methods automatically if they are available. Pretty nice solution, though not explicitly documented by them.

RazrFalcon commented 1 day ago

Yes, to my understanding the whole point behind core_maths is that it does everything automatically.

I would prefer for it to skip libm linking when std is enabled. But well. Still better then the previous solution.