-
Notifications
You must be signed in to change notification settings - Fork 953
Add WASI platform support #2001
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
Conversation
72e4e48
to
def8bed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM besides the show
-related nitpick
@cliffordwolf There's another question, related to this PR. For nMigen I would really like to have a PyPI package with small (~low single MB at most) wasm code and equally small (~single seconds on midrange laptop at most) cold startup latency. To do this I pretty much have to remove any pass nMigen doesn't use. Currently that's not really doable in a nice way and I resort to overriding Do you think it would make sense to add a Makefile function for adding a pass and its dependencies so that it's possible to do something like |
This is awesome! Congrats on the work 🎉 I'd love to try running it with Wasmer and the LLVM backend, I curious to know if the speeds will be closer to native. Could be possible to share the wasm somewhere? Note: If you want, you can also try it with: curl https://get.wasmer.io -sSfL | sh
# Note we use a single `:` as separator, instead of `::`
wasmer --backend=llvm --mapdir=/share:share --dir=. ./yosys.wasm -- -p synth_ice40 picorv32.v |
727b0fc
to
dfb68ff
Compare
This includes the following significant changes: * Patching ezsat and minisat to disable resource limiting code on WASM/WASI, since the POSIX functions they use are unavailable. * Adding a new definition, YOSYS_DISABLE_SPAWN, present if platform does not support spawning subprocesses (i.e. Emscripten or WASI). This definition hides the definition of `run_command()`. * Adding a new Makefile flag, DISABLE_SPAWN, present in the same condition. This flag disables all passes that require spawning subprocesses for their function.
Thanks!! |
I just tried it with wasmer (0.16.2) and comparing (just startup time) vs wasmtime (0.16): Wasmtime: 0.387s
Wasmer - LLVM: 0.072s
Wasmer - Cranelift: 0.081s
If you provide it me with some command that I can execute to measure runtime speed, that would be great... I expect wasmer speed with LLVM backend should be very close to native. Extra! 🎉I just tried Note: if yosys is published to WAPM, the |
The file I gave you is a highly limited and highly experimental development artifact. I really don't think it should be delivered to any end user without a significant amount of polishing going into it first. In my case, Yosys (in the role of a Verilog backend) is an implementation detail of nMigen, so I can be sure it never has to deal with unexpected input or handle errors gracefully. |
Yeah, no worries! I will not publish it anywhere... excited for the polishing phase! :) Is there any command that you recommend to run inside |
Try |
@eddiehung Thanks for review! Yosys on WASI will still currently fail to build due to outdated abc revision checked out by the build system on master. What's the process for updating that? |
Update this in your PR: Line 139 in bbde241
|
Ah, so no process is necessary beyond the actual required techical step, gotcha. |
@syrusakbary I happened to rebuild Yosys with abc just now, so here you are: |
See PR #1483 for a previous attempt (for some reason I can't reopen that PR).
This PR includes the following significant changes:
YOSYS_DISABLE_SPAWN
, present if platform does not support spawning subprocesses (i.e. Emscripten or WASI). This definition hides the definition ofrun_command()
.DISABLE_SPAWN
, present in the same condition. This flag disables all passes that require spawning subprocesses for their function. It replaces ad-hoc checks of$(CONFIG)
.This PR cannot be merged yet. Unresolved issues:
ENABLE_ABC:=1
buildar
binary abc#3 required forENABLE_ABC:=1
buildENABLE_ABC:=1
buildIn practice, WASI Yosys works quite well. I can synthesize medium sized iCE40 designs with the linked ABC just fine, and in reasonable time as well (within an order of magnitude even without LTO). Compiling Yosys itself from WASM to native code can take quite a while in the maximal configuration, but, fortunately, the native code is easily cached.
I am using WASI SDK, wasmtime, patched
abc
, and the following Yosys configuration: