Rust FFI for Haiku and #[cfg(haiku)]?

This may be a question for @nielx . I found the Rust FFI for Haiku under the name haiku-sys but unfortunately when trying to access it from wrapper code using
#[cfg(haiku)]
mod haiku;
it doesn’t appear to even try to load it. Using cargo --verbose test on the wrapper it appears to try to load the unix cfg path but doesn’t find the os-target of freebsd11 that it seemed to think it was using earlier. Does rust_bin on HaikuPorts think it’s running on a BSD target? When I tried adding a linking target of -lbsd it didn’t think closely enough to POSIX to load the wrapper as a BSD anyway.

What I’m trying to do is use the area_info type and functions from the Region wrapper. It doesn’t appear to even try to load my code when I test it. Sorry to bother you with such a newbie Rust problem but this one is very Haiku specific.

EDIT

The link to my half-finished commit is https://github.com/SamuraiCrow/region-rs if you have the time to look.

Two points:

  • As for your problem, you would check if target_os = "haiku", that should resolve properly.
  • The haiku-sys crate is no longer necessary. Since libc 0.2.95 many of the native functions in libroot (including the area functions) are available in that crate.

I hope this helps.

3 Likes

Thanks! LibC is loading properly. I’ll try the target_os configuration.

Update

It compiles but needs debugging. Due to interfacing with unsafe C++ code it’s not completely foolproof but at least it compiles the iterator now.

2 Likes

You’re more than welcome to post longer updates about this and WebAssembly on the Haiku blog too - I’m sure people who aren’t on the forums would love to hear about this :slight_smile:

Thanks! Once Wasmer works on Haiku it will be worthwhile to make a full blog post.

1 Like