-
Notifications
You must be signed in to change notification settings - Fork 716
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
wasm2c: Add experimental no-sandbox option #2084
Conversation
Before we land anything like this can we land some documentation about no sandbox mode and why its useful to you? (we can add those docs are part of this initial CL if you like). |
Would it be possible to share a little more about where/who this is intended for, more broadly? Given the opposition at #1432 from some areas of the Wasm community, perhaps we could gate it behind a flag like BTW, what would it mean to "unify host and WebAssembly address space" in a world with multi-memory? How does a load from memory index #x translate into a native load? Is it expected that running with |
I'll let @dimitry elaborate on the intent here, not sure how much they can share. But yes, I think it would likely make sense to put this behind
I think it would only apply to a first/primary/chosen memory. But I also think it would fine (initially) to simply not support multi-memory in this mode.
Yes, it would crash just like native program accessing address zero. |
Not today, no...
Hmm, honestly, I didn't quite realize the implications. Currently I think basically all of the flags in WABT are about adding "extra" abilities to the module -- e.g. they implement a proposal to extend the Wasm spec in a backwards-compatible way, or they relax some of the mandatory validation-time traps (the A |
The context here is using Wasm as a portable intermediate representation for native libraries for Android apps. So the idea is to have wasm2c in no-sandbox code generate a code (almost) as if it was generated by compiling it directly to native platform.
yes - the end goal is to have modules using |
One of the implications of Position independent code can be generated using |
I'm actually not 100% sure why that would be the case. In my mind it works like this: We will use wasm2c with --no-sandbox to generate C code that looks as close as we can make it to what original C would have looked like. It is then up to how the final translation of that generated C code is configured to determine things like PiC and relocatability. But I admit that I'm still too new to this space to be confident about what I just wrote. In any case, is this ready to be merged? |
I agree its up to the final translation of that generated C to determine memory layout, but it can't do that without either being given PIC or relocatable wasm module. If you don't build the wasm module as PIC or relocatable it would contain unannounced absolute addresses .. which obviously won't work in the general case. For example, static data would start at address 1024 which would just crash when compiled on most native platforms.
|
Ah - right. For some reason I had already tacitly assumed that we have relocation info, so "relocatable" would be true in that case. In fact, the part of the un-sandboxing implementation that I already have sitting around fundamentally depends on relocation info being present - precisely so that it can identify integer constants that are actually addresses. Thanks for the clarification! |
Perhaps we can call this |
Sure. I will rename it. |
On second thought ... would it make sense to have a separate --experimental flag, gating the acceptance of --no-sandbox and (for the time being, while general support is not fully baked) --memory64 on that? (Sorry for the late suggestion. I don't know if this has been discussed already.) |
sgtm |
It is hidden behind --experimental flag.
26d0b9b
to
3662133
Compare
done. |
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 to this initial addition of the flag. @keithw WDYT?
No objections to adding the flag. (Perhaps |
I plan to use wasm2c build sqlite to provide multi thread lock-free sqlite instance. (original sqlite must use lock with multi thread) with this the VFS IO speed will have a huge speedup. (no need copy from host page into WASM instance) |
this PR is outdated and no longer needed. |
No description provided.