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

Update cargo-component to v0.7.0, use wee_alloc in Wasm components and Miden SDK tests. #125

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

greenhat
Copy link
Contributor

@greenhat greenhat commented Feb 8, 2024

Close #107

This PR is stacked on top of #100 and should be merged after it

In this PR:

The panic handler and global allocator is now set in the lib.rs file of each component crate. Before, the cargo-component-bindings was not built correctly for no_std and was linking the stdlib allocator.

The Rust bindings for the WIT are now generated in the src directory of the component crate, instead of the target/.../bindings directory.

The Wasm bulk-memory proposal is enabled via RUSTFLAGS so that memcpy function import is replaced with Wasm memory.copy op.

@greenhat greenhat marked this pull request as ready for review February 8, 2024 15:04
@greenhat greenhat requested a review from bitwalker February 8, 2024 15:04
@greenhat greenhat linked an issue Feb 8, 2024 that may be closed by this pull request
Copy link
Contributor

@bitwalker bitwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one note about improving the code generated from the Wasm examples (i.e. reducing panics down to a single unreachable instruction), but feel free to take it or leave it.


#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you end up with even better codegen if you use core::intrinsics::abort() here, though that comes with the need for #![feature(core_intrinsics)]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I made #124 for this earlier and planned to make a separate PR for it. To keep PR sizes small and gauge the changes separately.

components and Miden SDK tests.

The panic handler and global allocator is now set in the `lib.rs` file
of each component crate. Before, the `cargo-component-bindings` was not
built correctly for `no_std` and was linking the stdlib allocator.

The Rust bindings for the WIT are now generated in the `src` directory
of the component crate, instead of the `target/.../bindings` directory.

The Wasm `bulk-memory` proposal is enabled via `RUSTFLAGS` so that
`memcpy` function import is replaced with Wasm `memory.copy` op.
@greenhat greenhat force-pushed the greenhat/i107-cargo-comp-v0.7 branch from 7bc8936 to c46ca5d Compare February 15, 2024 08:32
Base automatically changed from greenhat/i89-translate-wasm-cm to main February 15, 2024 22:47
@bitwalker bitwalker merged commit 4bdbc11 into main Feb 15, 2024
1 check passed
@bitwalker bitwalker deleted the greenhat/i107-cargo-comp-v0.7 branch February 15, 2024 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update cargo-component to v0.7
2 participants