Skip to content

Consider adding platform flags (E.g --browser, --wasi) / Easier defaults for newcomers #1132

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

Closed
torch2424 opened this issue Feb 28, 2020 · 7 comments

Comments

@torch2424
Copy link
Contributor

Hello!

So I have seen more than a handful of issues that creep up in multiple places (the latest being bytecodealliance/lucet#436 but I can definitely find more examples), that cause headaches for people because they happened to miss something in the docs.

As more "platforms" for wasm start coming around, I think it'd be nice to have some alias flags for certain envioronments.

Like for example, on all of my wasi applications (like as-echo), I always have to take the extra step of adding: --use wasi_abort from as-wasis wasi_abort

Maybe it'd be a good idea for as different platforms require different things, we can add some default alises for said platform? Or maybe another solution works?

Just wanted to hear some thoughts on this. And I totally think I can open a PR for this one whatever we decide to do 😄

@dcodeIO
Copy link
Member

dcodeIO commented Feb 29, 2020

Hm, yeah, the abort (and trace) functions have been introduced due to the lack of (standardized) alternatives, which WASI now provides. Potential soltutions:

  • Add a compiler flag (that also automatically sets up a global Wasi?)
  • Move the abort implementation to stdlib and make it detect isDefined(SomeGlobalWasiSymbol) which would be true if import "bindings/wasi_something" is used, and conditionally compile matching abort logic? Requires that a user imports the wasi interface somewhere.

Not sure what's more user-friendly.

@torch2424
Copy link
Contributor Author

Hm, yeah, the abort (and trace) functions have been introduced due to the lack of (standardized) alternatives, which WASI now provides.

Ah that makes sense! :) So what about abort in the browser case? I remember I needed it for WasmBoy, which has no WASI. And it seems like in the issue I linked, they also were not using WASI? 🤔

Add a compiler flag (that also automatically sets up a global Wasi?)
Move the abort implementation to stdlib and make it detect isDefined(SomeGlobalWasiSymbol) which would be true if import "bindings/wasi_something" is used, and conditionally compile matching abort logic? Requires that a user imports the wasi interface somewhere.

Would it be too much to ask for a combination of these actually? 😄

Like if we detect they are using WASI. Default to adding the --use=abort ... for WASI, and if not one for the browser. But still allow the user to override and provide their own? 😄

And yeah, I think it'd be good if we had an abort like built into the stdlib (if that means you don't have to manually import the one that as-wasi provides 😂 )

Thanks! 😄 And again, down to look into getting my feet (more) wet with the compiler for this one 😄

@torch2424 torch2424 changed the title Consider adding platform flags (E.g --browser, --wasi) Consider adding platform flags (E.g --browser, --wasi) / Easier defaults for newcomers Mar 4, 2020
@torch2424
Copy link
Contributor Author

Also, this came up in the beginners channel int he discord recently. @MaxGraey and I were helping someone, and gave some feedback here I thought was useful to this issue 😄

the loader example literally says { /* Your imports if needed */ } I now suspect the lack of index and env was what what caused the syntax error, but since the comment says 'if needed', it's reasonable for a newcomer to assume NO imports are needed.

This has to mostly do with the JS side of things. But I don't think we need to expect this imports in these cases really if we provide them 😄

@dcodeIO
Copy link
Member

dcodeIO commented Mar 4, 2020

When using the loader, there is no need to specify an abort import as the loader ships one already and fills it in. As such, the example there is correct, with /* Your imports if needed */ being user-defined imports exclusively. Reading through the discussion there, I guess what we'd need is an easily usable version of the loader for the browser, so everyone can just use it without bundling / worrying about details?

@torch2424
Copy link
Contributor Author

torch2424 commented Mar 5, 2020

@dcodeIO Ah! I didn't know that was the issue. Personally, I never used the loader, outside of wrapping it for as-bind (which in that case I have) 😂

But now that I know the loader provides this, I think it's probably more about improving the docs on this one section? 🤔 It's hard to assume what someone new may think when playing with it 😢

@dcodeIO
Copy link
Member

dcodeIO commented Mar 12, 2020

Initial implementions to make WASI modules "just work": #1159

@dcodeIO
Copy link
Member

dcodeIO commented May 28, 2020

Closing this issue as part of 2020 vacuum since the new import "wasi" functionality has landed meanwhile, and seems to sufficiently cover the issue. Feel free to open a new issue if there are problems with the new mechanism.

@dcodeIO dcodeIO closed this as completed May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants