feat: improve rust codegen for wasm target #1196
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves the Rust codegen for targeting wasm, following up on ideas from #1118.
Basically now the generated code works for both non-wasm and wasm compilation. (My requirement was to have the same generated code work under both.)
To demonstrate, the generated code now looks like this:
This follows @mitchmindtree's idea in #1118 (comment) and works for both use cases:
ffiand linking tolmas before.libm, a pure Rust crate offering the same functionality. Of course, wasm users need to addlibmas a dependency.Note that this makes the
-rnlm/--rust-no-libmcommand line args (andgRustNoLibminternally) more or less obsolete. Removing it would be a breaking change though for someone expecting these command line arguments to exist. I didn't remove it yet, but if the breaking change is considered minor enough, we could do so in a follow-up. This would be more or less the inverse of ad2e156.