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

swap to bindgen cli for no_std #2

Merged
merged 1 commit into from
Jan 28, 2020
Merged

Conversation

jacobrosenthal
Copy link
Contributor

Thanks so much for your recent no_std support. There is one problem still, in that using deps with shared features from build.rs pollutes the no_std features with std features. Its sadly a well known problem with the only solution being to swap bindgen api for cli.
rust-lang/cargo#5730

I think this is pretty close to complete, but not quite right yet as the pathing on the headers is broken but thought Id open the pr to start discussion

jacobrosenthal@Jacobs-MacBook-Air pygamer (embedded-graphics-addons) $ cargo run --example ferris_img --release
   Compiling wasm3-sys v0.1.0 (/Users/jacobrosenthal/Downloads/wasm3-rs/wasm3-sys)
   Compiling atsamd-hal v0.8.2 (/Users/jacobrosenthal/Downloads/atsamd/hal)
error: failed to run custom build command for `wasm3-sys v0.1.0 (/Users/jacobrosenthal/Downloads/wasm3-rs/wasm3-sys)`

Caused by:
  process didn't exit successfully: `/Users/jacobrosenthal/Downloads/atsamd/boards/pygamer/target/release/build/wasm3-sys-cdaaa8881bf2f36a/build-script-build` (exit code: 101)
--- stdout
cargo:warning=couldn't execute `llvm-config --prefix` (error: No such file or directory (os error 2))
cargo:warning=set the LLVM_CONFIG_PATH environment variable to a valid `llvm-config` executable

--- stderr
/Users/jacobrosenthal/Downloads/atsamd/boards/pygamer/target/thumbv7em-none-eabihf/release/build/wasm3-sys-a2cd32265d2c23a2/out/wrapper.h:1:10: fatal error: 'wasm3/source/m3_api_wasi.h' file not found
/Users/jacobrosenthal/Downloads/atsamd/boards/pygamer/target/thumbv7em-none-eabihf/release/build/wasm3-sys-a2cd32265d2c23a2/out/wrapper.h:1:10: fatal error: 'wasm3/source/m3_api_wasi.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', src/libcore/result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
thread 'main' panicked at 'Failed to run bindgen: ExitStatus(ExitStatus(256))', /Users/jacobrosenthal/Downloads/wasm3-rs/wasm3-sys/build.rs:61:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed
jacobrosenthal@Jacobs-MacBook-Air pygamer (embedded-graphics-addons) $ 

@Veykril
Copy link
Collaborator

Veykril commented Jan 28, 2020

Seems reasonable to me. The problem with the headers being not found is that the new header you are creating is in the OUT_DIR path, while you are trying to reference the other headers relatively to this header. This doesn't work since those headers arent in the OUT_DIR.

A quick solution would be to just create the wrapper header manually and put it into the wasm3-sys directory. Then the includes would look something like

#include "wasm3/source/m3_compile.h
...

@jacobrosenthal
Copy link
Contributor Author

Thanks, that was it. The only change I know that I made was removing default_enum_style as it is the command line default anyway I think.

As for no_std cross compile still doesnt successfully build for me as it doesnt have target arch stuff. Does this run for you as expected?

@jacobrosenthal jacobrosenthal marked this pull request as ready for review January 28, 2020 19:24
@Veykril
Copy link
Collaborator

Veykril commented Jan 28, 2020

Ah, you can even use CARGO_MANIFEST_DIR great, I didn't even think of that one and the default_enum_style was chosen by me at random so far so it doesn't really matter for now. Regarding cross compile I can't say much as I haven't worked with myself so far unfortunately.

Edit: Turns out the enum default is consts while I was using constmodules, I should really set up CI for this 😅

@Veykril Veykril merged commit 6e53656 into wasm3:master Jan 28, 2020
Cashmaney pushed a commit to scrtlabs/wasm3-rs that referenced this pull request Jun 21, 2022
…otector

wasm3-sys: Compile with -fno-stack-protector on SGX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants