Shopify Functions and Rust 1.84

Hello Shopify Functions developers!

We want to give you a heads up on compatibility of Rust 1.84 (releasing as stable on January 9) and a typical build configuration for Shopify Functions.

Rust 1.84 removes the wasm32-wasi build target. Previously our Rust function templates utilized the cargo-wasi utility, which would install wasm32-wasi, build to WebAssembly, and optimize your binary. This utility is now unsupported by the Bytecode Alliance, and will not be updated to support the new wasm32-wasip1 build target.

As of Shopify CLI 3.73, all function builds now include an optimization pass by default, which was previously performed by cargo-wasi.

Thus, before updating to Rust 1.84, we recommend that you review and follow the steps here. These changes are compatible with Rust 1.78+.

If you have any questions or issues, please post them here. Thank you!

Nick Wesselman
Product Lead, Shopify

2 Likes

Thank you Nick!

After updating the Shopify CLI to latest version I ran the following commands to upgrade Rust.

rustup update stable

Getting this error.

error: component 'rust-std' for target 'wasm32-wasi' is unavailable for download for channel 'stable'

To fix this issue, I had to remove the wasm32-wasi before updating rust version.

rustup target remove wasm32-wasi
rustup update stable

It might help others too :slight_smile:

Thanks

1 Like

Thanks for this @hujjatnazari!! As you say, it appears with the release of 1.84 that the deprecated target needs to be removed explicitly. We’ve added this to the docs.

2 Likes

Hi @NickWesselman After moving to Rust 1.84 using the instructions provided the wasm file size is now 18KB larger than it was before. This is problematic for us as it causes a validation error that prevents the extensions from deploying (Wasm file size must be less than 256KB).

@BartCoppens Are you sure you are on the latest Shopify CLI? If you add --verbose do you see the wasm being optimized with wasm-opt?

If you can confirm it’s being optimized, can you DM me the before and after wasm binaries?

@NickWesselman shopify version shows 3.72.2. Not sure if wasm-opt is running. I see ``release profile [optimized] target(s) in the console feedback when using --verbose though.

@BartCoppens You need to be on Shopify CLI 3.73+ to get the wasm-opt pass that is lost by removing cargo-wasi.

Thanks @NickWesselman. 3.73.1 does the trick indeed!
Note: I’ve noticed that the console shows a warning on the line that runs the generate_types! macro: warning: use of deprecated field output::ResponseData::handle_result: Use the target-specific field instead.