getditto/safer_ffi

scopeguard breaking no_std build

unovongalixor opened this issue ยท 8 comments

I'm trying to use safer_ffi to handle ffi stuff on an embedded device. i'm building my no_std project for --target thumbv7em-none-eabi, and i've included safer_ffi in cargo.toml with default-features = false, yet when i try to build, i get errors about missing STD from scopeguard. i checked and it seems scopeguard should work without std as well if default features are disabled. Is it possible this feature isn't getting forwarded to the dependencies?

Compiling scopeguard v1.1.0 error[E0463]: can't find crate for std

Thanks for the report! This should have been fixed in the v0.1.1 that I've just released ๐Ÿ™‚

thanks for the help. upgraded to 1.1.0, now I get the following error re: libc

for the sake of clarity i am writing a no_std, no_main staticlib. i'm contemplating conditionally including everything related to safer_ffi (only include during tests)

image

I'll look at this and fix it tomorrow (in 14h-ish); are you using wasm? In theory libc should be pulled in for non-wasm32-unknown-unknown targets ๐Ÿค”

Nope, I'm building for thumbv7em-none-eabi, Cortex M4 bare metal, no_std, no_main, nightly rust.

is it possible my target is unsupported for libc? seeing as how i have no os.. how are wasm targets handled?

the library will be used from zephyr, which has it's own minimal libc library. not sure if i can link to it

if you look here libc doesn't support my target. curious to know how you think i can approach this, as I really want to use safer_ffi for bare metal static libraries.

there's an old commit that fixes this issue for wasm (got to it from this issue), i believe the thumb targets need the same handling. if you use size_t like with wasm, it will work here too. basically any platform without libc support will need this handling.

Yes, exactly. Thanks for pointing that out. I think I'll exceptionally put in place a feature flag for these platforms rather than trying to list them all:

[dependencies.safer_ffi]
version = "โ€ฆ"
default-features = false  # no std
features = ["libc-is-empty"]  # opt out of libc types

Although currently my usage of libc is so low I think I could get rid of it altogether ๐Ÿค”

@unovongalixor #170 should be fixing this, you can test it early with a patch directive:

[patch.crates-io.safer-ffi]
git = "https://github.com/getditto/safer_ffi.git"
rev = "7d0770d7936c5a732a67bd59f447eb1655011622"

Otherwise it will eventually be released as 0.1.2. EDIT: done!