Skip to content
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

[SILGen] Fix swift_once initializer signature for lazy global var #42155

Merged

Conversation

kateinoigakukun
Copy link
Member

Builtin.once has type (Builtin.RawPointer, (Builtin.RawPointer) -> ())
at Swift level, but lazy global init passes its initializer as () -> (),
so their callee and caller signatures doesn't match.

// (RawPointer, @convention(c) (Context) -> ()[, Context]) -> ()

This PR adds an explicit context argument to the initializer function implementation.
This is to avoid runtime crash in WebAssembly

@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

`Builtin.once` has type `(Builtin.RawPointer, (Builtin.RawPointer) -> ())`
at Swift level, but lazy global init passes its initializer as `() -> ()`,
so their callee and caller signatures doesn't match.
@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

Copy link
Collaborator

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality wise, this seems correct. I’m not sure about the implications for Darwin, so please wait for @jckarter to chime in.

@jckarter
Copy link
Member

jckarter commented Apr 4, 2022

I think this should be fine.

@kateinoigakukun kateinoigakukun merged commit 09d0fe3 into apple:main Apr 5, 2022
@kateinoigakukun kateinoigakukun deleted the katei/fix-lazy-global-init-sig branch April 5, 2022 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants