argmin icon indicating copy to clipboard operation
argmin copied to clipboard

Support `wasm32-unknown-unknown` without `wasm-bindgen`

Open rikhuijzer opened this issue 8 months ago • 2 comments

Thank you for making this software available. I think numerical packages in pure Rust are really important.

This PR allows for succesfully building armin with

$ cargo build -p argmin --no-default-features --target wasm32-unknown-unknown

As a bit of background, the wasm (synonym: WebAssembly) situation is a bit complication right now. As I understand it, most wasm targets assume that Javascript is available too. So that's why getrandom/js often works. However, more and more wasm targets are moving away from Javascript. Wasmtime, for example, is a wasm runtime that does not support Javascript. This is useful for example for plugin systems like is used by Typst or Zellij. Both allow developers to write plugins which then can be used by users. But to not compromise the whole system, the plugins are sandboxed by default. So these plugins typically are not allowed to access the filesystem, or other system interfaces; also not via JS bindgen.

But I think it would be very nice if we could argmin in these barebone environments. To do so, this PR suggests to fix the build.

rikhuijzer avatar Mar 29 '25 16:03 rikhuijzer

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.12%. Comparing base (b35808a) to head (9a45f2c). Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #583      +/-   ##
==========================================
- Coverage   92.13%   92.12%   -0.02%     
==========================================
  Files         177      177              
  Lines       23672    23672              
==========================================
- Hits        21810    21807       -3     
- Misses       1862     1865       +3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Mar 29 '25 19:03 codecov-commenter

@stefan-k My apologies for the failing CI jobs in 68cf721 and dc43934.

I now tested this PR in my own fork (https://github.com/rikhuijzer/argmin/pull/1) and CI should pass now. I also added a test that explicitly tests this wasm32-unknown-unknown without wasm-bindgen.

My compliments by the way for the CI testing setup. The tests are very thorough.

rikhuijzer avatar Apr 01 '25 08:04 rikhuijzer

@rikhuijzer Apologies that I didn't address this earlier. Strangely, the CI runs are gone and even more strangely, triggering the CI doesn't work either.

Edit: now they are running. Let's hope for the best.

stefan-k avatar Jul 12 '25 09:07 stefan-k

@rikhuijzer Hooray, the CI still passes (more or less, I'll fix the clippy lints later). Thanks a lot for addressing this issue and apologies again for the long wait.

stefan-k avatar Jul 12 '25 09:07 stefan-k

@rikhuijzer Hooray, the CI still passes (more or less, I'll fix the clippy lints later). Thanks a lot for addressing this issue and apologies again for the long wait.

Thank you. I'm happy to see it got merged 👍 I've abandoned my use-case for now but probably someone else will benefit from it one day

rikhuijzer avatar Jul 12 '25 17:07 rikhuijzer