Skip to content

builtin,v.gen.wasm: support -b wasm -d no_imports #24188

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

Merged
merged 4 commits into from
Apr 13, 2025

Conversation

Xyndra
Copy link
Contributor

@Xyndra Xyndra commented Apr 11, 2025

All currently existing WASM targets use some kind of imports by default. This one doesn't.

All currently existing WASM targets use some kind of imports by default. This one doesn't.
@spytheman
Copy link
Member

I do not get it.

Why add another mode?

Your explanation that:

All currently existing WASM targets use some kind of imports by default. This one doesn't.

Does not make sense to me, because rg 'import ' vlib/builtin/wasm/ returns 0 results already.

@spytheman
Copy link
Member

Can you please describe in more details, the use case/workflow, that is enabled by this, that was not available before, but will be in this PR?

@Xyndra
Copy link
Contributor Author

Xyndra commented Apr 11, 2025

I did not mean v imports, I meant WASM imports (the imports that the binary does). Browsers mode takes two functions:

fn JS.__panic_abort(&u8, int)
fn JS.__writeln(&u8, int)

Wasi also takes some:

@[wasm_import_namespace: 'wasi_snapshot_preview1']
fn WASM.fd_write(fd FileDesc, iovs &CIOVec, iovs_len usize, retptr &usize) Errno

@[wasm_import_namespace: 'wasi_snapshot_preview1']
@[noreturn]
fn WASM.proc_exit(rval int)

@Xyndra
Copy link
Contributor Author

Xyndra commented Apr 11, 2025

If you have a custom WASM runtime and can't easily offer the required functions (I am in that situation right now) this is very useful and there aren't any ways to do that at the moment because the requirements are inside the builtins and therefore not removable

@spytheman
Copy link
Member

Why not use another mechanism for customization, for example -d no_whatever, and then @[if !no_whatever] fn ..., to allow for those usecases, which will only need local changes in a few places, rather than a whole new mode, that will have to be maintained, explained and documented separately from the other ones?

I am afraid, that we already do have too many wasm related modes, and adding more does not look to me like a good idea at all, from a maintenance point of view.

@Xyndra
Copy link
Contributor Author

Xyndra commented Apr 12, 2025

note that I also made custom comptime flags work with this

@Xyndra
Copy link
Contributor Author

Xyndra commented Apr 12, 2025

CI seems to have failed during installing dependencies (?), doesn't seem like V even ran

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman
Copy link
Member

Yes, the CI error is unrelated, and already fixed on master.

@spytheman spytheman changed the title Add pure_wasm target builtin,v.gen.wasm: support -b wasm -d no_imports Apr 13, 2025
@spytheman spytheman merged commit d559a62 into vlang:master Apr 13, 2025
75 of 77 checks passed
@Xyndra Xyndra deleted the pure_wasm branch April 16, 2025 08:01
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

Successfully merging this pull request may close these issues.

2 participants