-
Notifications
You must be signed in to change notification settings - Fork 715
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
Add wasm2c output samples to tests #2006
Conversation
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.
Wow, this is kind of cool.
I was thinking of simpler test that just runs wasm2c and includes the output without pigging backing on the spec test stuff, and without even trying to actually compile the code, let alone run it, but this more compressive that what I had in mind.
I'm not sure about the name of the sub-directory? Do we need to sub-directory at all? I'm also not sure about how to select things for inclusion here.
I think these three all seem reasonable. We might want to add another one later which tries to use every possible feature of wasm2c (so any wasm2c change would cause its output to change).
Do you think there is any value in the simpler testing that just shows the output of wasm2c (without compiling and running it as if it was a spec test)?
Not at all -- here's a commit that moves them into test/wasm2c and gets rid of the
Agreed -- this does seem like a good idea.
I do... and we can certainly add a |
8b09a5a
to
08c63f2
Compare
08c63f2
to
5414976
Compare
5414976
to
888114c
Compare
@sbc100 @shravanrn Could you render a verdict on whether this is still wanted? It could be nice with the changes to c-writer.cc and the source templates that are in the hopper, or we could decide it's not worth it... I'm happy either way but wanted to bump this and hopefully move towards consensus one way or the other. |
Sorry, I am just trying to get caught up on this discussion. Is the question do we want a simple hello-world with wasi example? I currently have been an uncommitted test which I manually run So this definitely looks great to me :) (Let me know if you wanted me to code review) |
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.
I think the idea is great but we might want to tweak the implementation a little. I'm happy to land this as is an do followups though.
- I'm not sure about using run-spec-wasm2c for this. I seems to be overloading this script a little. Would just running wasm2c directly be better/enough?
- I wonder if it would make diffs and reading easier if we use separate output files rather than inlining all the generated code. For example, doign it this way makes harder to distinguish header changes from source changes.
test/wasm2c/add.txt
Outdated
|
||
(register "adder" $adder) | ||
|
||
(assert_return (invoke $adder "add" (i32.const 3) (i32.const 4)) (i32.const 7)) |
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.
Is there any reason to include the register
and assert_return
line, if we are just interested in storing the output code? i.e. Isn't the functionality of adding already covered by the spec tests?
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.
I had initially done the register
so that run-spec-wasm2c.py
would give the module a nicer name (e.g. adder_instance_t
instead of add_0_wasm_instance_t
) but now that we're using wasm2c directly this doesn't matter -- removed.
@shravanrn Awesome, would be grateful for your input. I think the backstory here was that if we're making a lot of changes to c-writer.cc and the wasm2c source templates, it can be challenging to figure out "how does this affect the wasm2c output?" just by looking at the diffs on GitHub. So @sbc100 had suggested maybe we should commit some fully-worked examples in the repo that have an input .wat file and the corresponding expected .h and .c outputs, and now every time we change the wasm2c output, the PR will have to rebase those tests to match the new output and that diff will be readable on GitHub. The pro is that the bottom-line impact to wasm2c output will be more easily visible when doing reviews on GitHub; the con is that it's more friction on each change. |
I think that given how easy it is to run |
888114c
to
fba2c26
Compare
I just gave it a shot and it went a lot smoother than I thought it would when I first did it the other way. Done (and run-spec-wasm2c.py is now unchanged).
That also seems doable but a slightly bigger lift from where we are now... Would you want to have like add_c.txt and add_h.txt and each one runs wasm2c and then prints out just the .c or just the .h file? |
fba2c26
to
ef6ce88
Compare
Separate output files if possible would be nice, but happy to go with whatever is easily possible. Other than that the only one thing I wanted to add --- Not sure if this already exists and I missed it, but we possibly want to document somewhere how we can update the tests in case we change c-writer.cc |
Yes, perhaps even in the test failure message it could say something like |
Per #1877 (comment), adding some samples of wasm2c output to the repository so we can track them when it changes. The three samples are:
add
functionfd_write
andproc_exit
that it links with