Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scopeguard breaking no_std build #168

Closed
unovongalixor opened this issue Jul 6, 2023 · 8 comments · Fixed by #169 or #170
Closed

scopeguard breaking no_std build #168

unovongalixor opened this issue Jul 6, 2023 · 8 comments · Fixed by #169 or #170
Assignees
Labels
K-bug Kind: existing code isn’t behaving as expected

Comments

@unovongalixor
Copy link

unovongalixor commented Jul 6, 2023

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

@danielhenrymantilla danielhenrymantilla added the K-bug Kind: existing code isn’t behaving as expected label Jul 6, 2023
@danielhenrymantilla danielhenrymantilla self-assigned this Jul 6, 2023
@danielhenrymantilla
Copy link
Collaborator

danielhenrymantilla commented Jul 6, 2023

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

@unovongalixor
Copy link
Author

unovongalixor commented Jul 6, 2023

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

@danielhenrymantilla
Copy link
Collaborator

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 🤔

@unovongalixor
Copy link
Author

unovongalixor commented Jul 7, 2023

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

@unovongalixor
Copy link
Author

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.

@unovongalixor
Copy link
Author

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.

@danielhenrymantilla
Copy link
Collaborator

danielhenrymantilla commented Jul 7, 2023

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 🤔

@danielhenrymantilla
Copy link
Collaborator

danielhenrymantilla commented Jul 7, 2023

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
K-bug Kind: existing code isn’t behaving as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants