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

Remove the "cdylib" crate-type from all proc-blocks #34

Merged
merged 3 commits into from
Mar 3, 2022

Conversation

Michael-F-Bryan
Copy link
Contributor

@Michael-F-Bryan Michael-F-Bryan commented Feb 28, 2022

As part of #19 we added crate-type = ["cdylib", "rlib"] to the [lib] section of each proc-block's Cargo.toml file, letting us compile the crate directly to a *.wasm file that can be loaded at runtime.

This works well when you build a proc-block normally (e.g. cd normalize && cargo build) or when generating a *.wasm file for the purpose of extracting metadata (cargo build --target=wasm32-unknown-unknown --features=metadata). However, when the crate is used as a dependency without the metadata feature (i.e. as part of rune build), we try to generate the cdylib and fail because it expects certain language items.

error: no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait

error: `#[alloc_error_handler]` function required, but not found
note: Use `#![feature(default_alloc_error_handler)]` for a default error handler

error: `#[panic_handler]` function required, but not found

This PR removes the crate-type declarations and modifies cargo xtask dist to build each crate using cargo rustc --crate-type=cdylib. It should be good to merge, I'm just waiting for rust-lang/cargo#10388 (fixed 14 hours ago) to hit nightly so we get the fix for rust-lang/cargo#10356.

This also moves the cargo xtask dist step in CI to its own job because the --crate-type argument requires nightly Rust and the normal tests are compiled/run on the host while cargo xtask dist cross-compiles to WebAssembly.

@Michael-F-Bryan Michael-F-Bryan merged commit 9e97080 into master Mar 3, 2022
@Michael-F-Bryan Michael-F-Bryan deleted the hotfix/remove-cdylib-crate-type branch March 3, 2022 17:37
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.

1 participant