Skip to content
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

Use with wasi-shim? #127

Closed
nickwesselman opened this issue Sep 23, 2022 · 8 comments
Closed

Use with wasi-shim? #127

nickwesselman opened this issue Sep 23, 2022 · 8 comments

Comments

@nickwesselman
Copy link

nickwesselman commented Sep 23, 2022

I see you've updated to use wasi-shim, but it's not clear how usage/configuration has changed.

  • No more need to import "wasi", right?
  • How do I correctly configure my asconfig.json?

Adding nothing results in a module that won't execute:

Error: failed to run main module `build/debug.wasm`

Caused by:
    0: failed to instantiate "build/debug.wasm"
    1: unknown import: `env::abort` has not been defined

Following the instructions from wasi-shim results in a module that won't compile.

ERROR TS2300: Duplicate identifier 'wasi_abort'.
      :
 1100 │ export function wasi_abort(
      │                 ~~~~~~~~~~
      └─ in ~lib/as-wasi/assembly/as-wasi.ts(1100,17)
    :
 19 │ export function wasi_abort(
    │                 ~~~~~~~~~~
    └─ in ~lib/wasi_internal.ts(19,17)
@nickwesselman
Copy link
Author

Note if I comment out the wasi-abort global in assembly/as-wasi.ts things seem to work great. Is this global no longer needed with the shim?

@JairusSW
Copy link

I am also having the same problem

@jedisct1
Copy link
Owner

I removed the wasi_abort() call.

Thank you!

@mariusa
Copy link

mariusa commented Nov 15, 2022

Thanks! Would you please make a new release with this fix? @jedisct1

@mariusa
Copy link

mariusa commented Nov 15, 2022

PS: there's an error on build now

> asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat --use abort=wasi_abort -O3

ERROR AS[11](https://github.com/jedisct1/as-wasi/actions/runs/3468757099/jobs/5794936368#step:5:12)1: Element 'wasi_abort' not found.

@dcodeIO
Copy link

dcodeIO commented Nov 15, 2022

I guess ideally, both wasi-shim and as-wasi are used alongside, where wasi-shim reconfigures stdlib to use WASI APIs while as-wasi provides additional APIs that are not present in stdlib. Seems this could work well as the default, given that:

  • as-wasi depends on wasi-shim already anyway
  • Could then remove redundant APIs like
    • Console.* (wasi-shim implements std console.*)
    • Time.* (wasi-shim implements std Date.* and performance.*)
    • Environ.* (wasi-shim implements node-like process.*)
  • Whereas as-wasi can focus on additional APIs like file system access
  • Then there's also no need to configure --use directives in as-wasi itself

@mariusa
Copy link

mariusa commented Nov 15, 2022

There's no console.readAll() -- should I open an issue?

btw, https://github.com/AssemblyScript/wasi-shim doesn't have issues enbabled

@dcodeIO
Copy link

dcodeIO commented Nov 15, 2022

wasi-shim only overrides APIs already in AS's stdlib, that is standard-ish JS or, where useful, Node APIs. A console.readAll with no equivalent in JS/Node should remain in as-wasi, unless it can be refactored to map to an actual JS/Node API that is first added to AS stdlib, and then overridden by wasi-shim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants