Skip to content

[embedded] Fix calling convention on embedded runtime APIs (switch @_silgen_name for @_cdecl) #71226

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

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

kubamracek
Copy link
Contributor

We've had @_silgen_name-annotated runtime APIs in the embedded Swift runtime, which is a mismatched calling convention on the SIL level, @convention(thin) vs @convention(c), as well as the LLVM IR level, swiftcc vs no swiftcc. In most cases this doesn't matter, but there is one case where it does, it's described in the attached testcase and involves LTO, and results in a miscompile (LLVM optimizer turns the runtime API call into an unconditional trap). Let's fix that by using @_extern(c), and @_cdecl on APIs that are expected to follow the C calling convention (non swiftcc).

rdar://121672536

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek kubamracek merged commit 0655578 into swiftlang:main Jan 30, 2024
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.

2 participants