-
Notifications
You must be signed in to change notification settings - Fork 30
Emit thunk function for specific ABI on WebAssembly. #6
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
Emit thunk function for specific ABI on WebAssembly. #6
Conversation
Wow! This is amazing! Thank you so much! I haven't tested this: does this also handle the optional protocol witness parameters? |
@zhuowei Thanks 😊
I didn't care about that and I can't figure out how the problem happens. Could you give me an example for the case? |
ff96f45
to
c4645e3
Compare
e244560
to
2c73d6c
Compare
c4645e3
to
6fd3e31
Compare
I tracked upstream branch 👍 (BTW rebasing main branch |
I'm sorry about that, I thought about using merge commits instead of rebase, but downside is that the main swift repository uses merge commits too. Adding our own would potentially make commit history quite unreadable. Please let us know if you think there's a better solution 🙏 |
@MaxDesiatov Thanks for maintaining this downstream repo 👍 |
@zhuowei Sorry for pinging you. Can I merge this patch? |
When building an SDK with this branch using swiftwasm-package-sdk and using the packaged
I currently don't have any knowledge of what this file is expected to contain, a basic check shows this:
I've built everything using this branch with @kateinoigakukun hope you could provide some pointers to where things could have gone wrong? |
Just got the artifacts uploaded for
yields
It's not that the isue is caused by this PR, but it seems to be caused by #11 or some other changes since the last binary packages were built for |
@MaxDesiatov I think $ wasm-ld --version
LLD 9.0.0 (https://github.com/llvm/llvm-project 0399d5a9682b3cef71c653373e38890c63c4c365) If you can't resolve by updating
Yeah, need to remove |
@kateinoigakukun thanks for the tip! I've managed to get fresh
|
@MaxDesiatov Ah, I faced same error too |
f2bdbfe
to
42c6603
Compare
This PR will need to be rebased on top of |
Changed to make thunk to convert thin-to-thick and non-throws-to-throws, We needs it on WebAssembly host because WASM checks number of arguments strictly for indirect function call.
99a81ce
to
3070daf
Compare
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in #11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and #6 are merged, `print("Hello")` will work again! 🎉
Seems legit, let's get it merged 🙌 |
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in swiftwasm#11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and swiftwasm#6 are merged, `print("Hello")` will work again! 🎉
Changed to make thunk to convert thin-to-thick and non-throws-to-throws. We needs it on WebAssembly host because WASM checks number of arguments strictly for indirect function call. This patch allows you to run the Swift code below. ```swift func f(_ a: (Int) -> Void) { g(a) } func g(_ b: (Int) throws -> Void) { try! b(1) } f { _ in } ```
https://forums.swift.org/t/reality-vs-reality/31835/24 HELP OPEN THE FLOOD GATES |
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in swiftwasm#11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and swiftwasm#6 are merged, `print("Hello")` will work again! 🎉
Changed to make thunk to convert thin-to-thick and non-throws-to-throws. We needs it on WebAssembly host because WASM checks number of arguments strictly for indirect function call. This patch allows you to run the Swift code below. ```swift func f(_ a: (Int) -> Void) { g(a) } func g(_ b: (Int) throws -> Void) { try! b(1) } f { _ in } ```
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in swiftwasm#11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and swiftwasm#6 are merged, `print("Hello")` will work again! 🎉
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in swiftwasm#11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and swiftwasm#6 are merged, `print("Hello")` will work again! 🎉
Changed to make thunk to convert thin-to-thick and non-throws-to-throws. We needs it on WebAssembly host because WASM checks number of arguments strictly for indirect function call. This patch allows you to run the Swift code below. ```swift func f(_ a: (Int) -> Void) { g(a) } func g(_ b: (Int) throws -> Void) { try! b(1) } f { _ in } ```
Changed to make thunk to convert thin-to-thick and non-throws-to-throws.
We needs it on WebAssembly host because WASM checks number of arguments strictly for indirect function call.
This patch allows you to run the Swift code below.