-
Notifications
You must be signed in to change notification settings - Fork 245
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
wit-component
should accept modules with shared memories
#1674
Comments
At this time there's generally no support for shared memories with components. Excluding the actual ability to spawn threads there's not really any reason for this other than elbow grease has not been applied. In other words if you're not spawning threads it's mostly just todos here and there to get the stars to align correctly and support shared memories. Given this I think it would be reasonable to support this, but it would require changes at the component model validation layer to accept shared memories as the target for lifts/lowers/etc. Once you actually spawn threads that's an entirely separate can of worms that I'd defer to the shared-everything-threads proposal. |
Thanks. To be clear I'm not asking for support for spawning threads in |
Oh for sure and makes sense yeah. IMO the "best answer" here is WebAssembly/wasi-libc#501 where |
I have found that the "mismatch in the shared flag for memories" comes from this line:
How should a fix look like? Is altering the subtype check the right thing to do here? I'm not completely sure if a shared memory is a subtype of a non-shared memory; intuitively I feel like it probably is (all operations for a non-shared memory apply to the shared memory but not vice versa), seeing as the atomics are defined as:
But I'm not completely sure and I'd rather defer to an expert in this area. |
Oh no definitely no subtyping here, that would have ramifications on the core wasm level and affect quite a few moving pieces. I don't disagree with you that it's theoretically possible but that should be done as a first-class modification to the wasm specification. For example these are the formal semantics of matching with the threads proposal and I believe the intention is that there's no subtyping. (that would also affect JS which I'm not sure wants to be affected). Anyway other than that there's a few somewhat related issues here which is going to make fixing this not exactly trivial:
Overall this I don't think is as simple as a game of whack-a-mole for now. I think the first thing to do is to get alignment at the component model level that shared memories are ok to use here. From there then it's a bit more whack-a-mole but there's a lot of places to touch. I'd expect this to require a nontrivial investment of time to push a change like this through. |
I see. I suppose what I'll do then is to use Thanks for writing it out though! I'm sure this will eventually come in handy. |
Alas yeah unfortunately I don't think there's a great way out of this. Another option would be to implement |
(Originally filed against jco as bytecodealliance/jco#470).
To reproduce:
This example is extracted from a larger project (YoWASP Clang). LLVM currently does not compile for the
wasm32-wasip1
target (it requireswasm32-wasip1-threads
) because it extensively uses atomics even in a single-threaded build. This is difficult to change. However, an LTO build of LLVM/Clang/LLD (with the WebAssembly patchset that's likely going to be accepted in near future) doesn't importthread.spawn
and so doesn't need to be treated differently.Should this restriction be relaxed?
The text was updated successfully, but these errors were encountered: