Repository navigation
Add LITTLEFS_CONFIG support and adjust bindings for wasm32 target - #28
AlixANNERAUD wants to merge 2 commits into
Conversation
|
Any updates ? |
|
Rebased on v0.4.0. The
I checked that it builds with and without |
sosthene-nitrokey
left a comment
There was a problem hiding this comment.
Hi, thank you for your contributions and sorry for the late reply, I did not have notifications on for this repo.
| #[cfg(not(feature = "malloc"))] | ||
| builder.flag("-DLFS_NO_MALLOC"); | ||
|
|
||
| if let Ok(lfs_config) = env::var("LITTLEFS_CONFIG") { |
There was a problem hiding this comment.
Can you please rename it to UNSAFE_LITTLEFS_CONFIG ?
It's technically unsafe from the Rust meaning of the term to override this.
Can you please also document this in the Readme?
There was a problem hiding this comment.
Done, renamed to UNSAFE_LITTLEFS_CONFIG and added a section to the README.
|
|
||
| if let Ok(target) = env::var("TARGET") { | ||
| if target == "wasm32-unknown-unknown" { | ||
| bindings_builder = bindings_builder.clang_arg("-fvisibility=default"); |
There was a problem hiding this comment.
Can you please explain what this does and why it's required for wasm32 specifically?
There was a problem hiding this comment.
On wasm, clang implicitly uses -fvisibility=hidden, and bindgen skips functions that don't have default visibility. Since littlefs doesn't annotate its functions, the bindings end up with all the types but none of the lfs_* functions. -fvisibility=default restores them. It only affects how bindgen parses the headers, not the compiled C code.
While checking this I noticed wasm32-wasip1 had the same problem, so the flag is now applied to the whole wasm target family, with a comment explaining why.
Overriding the littlefs configuration is unsafe, so the variable name now says so, and it is documented in the README. On wasm targets, clang implicitly uses -fvisibility=hidden and bindgen skips functions without default visibility, so the bindings had no lfs_* functions. The flag was only passed for wasm32-unknown-unknown; it is now passed for the whole wasm target family (wasm32-wasip1 was also affected).
Hi,
Thanks for this very useful repository.
This pull request introduces enhancements to the build configuration in
build.rsand a minor header file adjustment instring.c. The key changes include adding support for environment-based configuration andfvisibilityfix for wasm32 for bindgen in the build script and replacing a header file instring.c, improving portability for bare metal environment (for examplewasm32_unknown_unknowntarget).