Skip to content

Conversation

@daxpedda
Copy link
Member

@daxpedda daxpedda commented Nov 18, 2024

This PR adds support for the wasm32v1-none target and should enable all features previously behind cfg(feature = "std") for both wasm32-unknown-unknown and wasm32v1-none. Additionally, now js-sys, web-sys, wasm-bindgen-futures and wasm-bindgen-test support no_std.

Changes:

  • Use any(target_os = "unknown", target_os = "none") instead of target_os = "unknown".
  • For globals:
    • Continue to use once_cell::sync::Lazy when targeting std.
    • Use Send + Sync wrapped once_cell::unsync::Lazy when targeting no_std without target_feature = "atomics".
    • Use once_cell/critical_section when targeting no_std with target_feature = "atomics". As recommended by critical_section, this is something the user has to enable. Notable this only affects link_to!, any other feature will work as expected with no additional work required from the user.
  • For thread locals:
    • Continue to use std::thread_local! when targeting std.
    • Use static mut when targeting no_std without target_feature = "atomics".
    • Use #[thread_local] when targeting no_std with target_feature = "atomics".
  • Add std crate feature to js-sys, web-sys, wasm-bindgen-futures and wasm-bindgen-test and enable by default. This makes it possible to use these crates with no_std for both targets as well.
  • Inlined console_error_panic_hook and a no_std version of scoped_tls.

Missing:

  • Add wasm32v1-none to CI. Probably in a follow-up when its stable, ergo Rust v1.84.
@daxpedda daxpedda force-pushed the wasm32v1-none branch 14 times, most recently from cc7e2ee to c4a864e Compare November 21, 2024 00:04
@daxpedda daxpedda force-pushed the wasm32v1-none branch 3 times, most recently from 8aa5390 to ce85f6a Compare November 21, 2024 13:10
@daxpedda daxpedda marked this pull request as ready for review November 21, 2024 13:17
Copy link
Contributor

@RunDevelopment RunDevelopment left a comment

Choose a reason for hiding this comment

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

I think thread_local_v2 still needs to be documented, right?

@daxpedda
Copy link
Member Author

I think thread_local_v2 still needs to be documented, right?

I had just amended the already existing documentation which wasn't very clear. I improved it a bit now.

@daxpedda daxpedda merged commit f071c7e into main Nov 28, 2024
40 checks passed
@daxpedda daxpedda deleted the wasm32v1-none branch November 28, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants