carton: Method with i64 return type fails on Safari 13+14
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
TypeError: i64 not allowed as return type or argument to an imported function
wasm-stub
<?>.wasm-function[gettimeofday]
<?>.wasm-function[CFAbsoluteTimeGetCurrent]
<?>.wasm-function[$s10Foundation4DateVACycfC]
<?>.wasm-function[main]
<?>.wasm-function[__original_main]
<?>.wasm-function[_start]
wasm-stub
_start
(anonymous function) — e8900d1b3895f276.js:1:47960
(anonymous function) — e8900d1b3895f276.js:1:184568
asyncFunctionResume
[native code]
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?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (8 by maintainers)
Commits related to this issue
- Bump default toolchain, make i64 bug reproducible (#128) `TestApp/.swift-version` is removed as it was mostly duplicating the default toolchain version. Downloads of recent toolchains is fixed now wi... — committed to swiftwasm/carton by MaxDesiatov 4 years ago
- Add separate Builder class, use WasmTransformer (#131) Resolves #127. * Add separate Builder class, use WasmTransformer * Don't apply the transformer in non-browser environments * Fix macOS ... — committed to swiftwasm/carton by MaxDesiatov 4 years ago
I’ll work on porting
wasm_transform_cliin Swift worldMoving it to the
cartonrepo in the meantime, I don’t think any changes in JavaScriptKit will be necessary.Today and yesterday I’ve been playing with Binaryen bindings, and binaryen is what powers
wasm-opt. If we can get itsi64-to-i32-loweringpass to work, it could be easily integrated incartonand applied during the build.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. JSDate does work in Safari, but naturally untenable for reusing ‘real’ Swift code. I guess it also affects a bunch of other WASI methods.
Unfortunately it is, getting same results with
carton init --template basic, then in main.swift:(Running with carton dev/bundle)