-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Method with i64 return type fails on Safari 13+14 #127
Comments
Is this reproducible with |
Unfortunately it is, getting same results with import Foundation
print("Hello, world!")
let date = Date() (Running with carton dev/bundle) |
Here's an issue that seems related to me WebAssembly/WASI#334 |
What people mention there is possible optimization with |
I addressed this issue by pollyfilling i64 into two i32 values https://github.com/kateinoigakukun/swiftwasm-pad/tree/master/Frontend/Sources/i64_polyfill |
This would require generating additional SwiftPM modules that contain the polyfills for our users. What do you think about the |
Hmm, that option doesn't work well. If it works well, it would be an option to recommend. |
I didn't have luck with wasm-opt either. There's also wasmer's lowering pass which we can use at runtime, presumably only if needed by browser detection. |
BTW, I hope |
I've had some success running the i64->i32 transformer directly in rust on the pre-optimized bundle. It fails on optimized bundle and when running in javascript. |
Do I understand correctly that polyfilling this purely on JS side or even within the Swift codebase of JavaScriptKit is not possible? Maybe this issue should be transferred to either toolchain or |
(For posterity, this is also tracked in WebKit). |
Today and yesterday I've been playing with Binaryen bindings, and binaryen is what powers |
I'll try to look into that. Meanwhile I realized the wasmer js transformer is not working because... the rust->wasm module it's running itself has i64 calls. I've been trying to transform the transformer offline but got bogged down in rust and npm failures. |
oh dear |
I've seen your great progress on https://github.com/MaxDesiatov/binaryen. But not sure it's the right way forward:
Wasmer's pass does seem to handle our output, though I've only ran some rudimentary tests. We can incorporate it either:
|
Thanks for the detailed update!
To clarify, there's not much there, and I'm thinking of abandoning that repository for now and merging my work into previously available bindings, which I weren't fully aware of. I knew there were some, but didn't know their API coverage was much greater than what I managed to get on my own. My foray into Binaryen bindings was provoked by dreaming of a Swift to WebAssembly compiler running directly in the browser. This is not something I plan to work on very soon, but rather an exploration in background. LLVM is too heavy, so I wonder how difficult it would be to take the Swift compiler frontend as is, get SIL output from it, and then transform SIL (at least some very limited subset of it as PoC) to Wasm with Binaryen. This is a long-term project, and fixing high priority issues we have in SwiftWasm right now is what I'm focused on. I only hoped that Binaryen bindings could bring me one step closer to that Binaryen compiler backend PoC.
Forking has some overhead, especially for frequent builds as we have to run for But you've convinced me that trying |
|
Moving it to the |
I'll work on porting |
Looks like Binaryen bindings with full API coverage I was referring to are in a bit broken state, I'm fixing those right now. |
`TestApp/.swift-version` is removed as it was mostly duplicating the default toolchain version. Downloads of recent toolchains is fixed now with the new `macos` tarball suffix that replaces `osx`. `TestApp/main.swift` is updated to make #127 easily reproducible.
Resolves #127. * Add separate Builder class, use WasmTransformer * Don't apply the transformer in non-browser environments * Fix macOS Swift 5.2 build failure * Fix Package.swift errors * Fix cyclic dependency in `Package.swift` * Bump WasmTransformer requirement to 0.0.1 * Rename `case wasmer` to `case other`
Using JavaScriptKit as only dependency, trying to instantiate a
Date()
fails on Safari (13.1.1, 14) with:TypeError: i64 not allowed as return type or argument to an imported function
Stacktrace
Same code runs fine on Chrome and Firefox. Tried with latest blessed carton versions and with latest swiftwasm+JavaScriptKit, same results.
Assuming it's related to swiftwasm/JavaScriptKit#56. Could/should we incorporate this polyfill in JavaScriptKit?
The text was updated successfully, but these errors were encountered: