Skip to content

Ensure that bridged types are indirectly returned on Windows ARM64 #76589

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
Sep 23, 2024

Conversation

hjyamauchi
Copy link
Contributor

On Windows ARM64, how a struct value type is returned is sensitive to conditions including whether a user-defined constructor exists, etc. See

https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#return-values

That caused a calling convention mismatch between the non-USED_IN_CPP_SOURCE (Swift) side and the USE_IN_CPP_SOURCE (C++) side and a crash.

Following #76433 add constructors to several bridged C++ struct/class types so that the calling convention matches.

This is a partial fix for #74866

On Windows ARM64, how a struct value type is returned is sensitive to
conditions including whether a user-defined constructor exists,
etc. See

https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#return-values

That caused a calling convention mismatch between the
non-USED_IN_CPP_SOURCE (Swift) side and the USE_IN_CPP_SOURCE (C++)
side and a crash.

Following swiftlang#76433 add
constructors to several bridged C++ struct/class types so that the
calling convention matches.

This is a partial fix for swiftlang#74866
@hjyamauchi
Copy link
Contributor Author

@swift-ci please test

@hjyamauchi
Copy link
Contributor Author

@swift-ci please test linux platform

1 similar comment
@hjyamauchi
Copy link
Contributor Author

@swift-ci please test linux platform

@hjyamauchi
Copy link
Contributor Author

@DougGregor Would you take a look? This is a follow-up to the previous #76433.

@eeckstein
Copy link
Contributor

Thanks!
I found that we can get rid of some (most?) #ifdef USED_IN_CPP_SOURCE by forward-declaring the C++ types and defining the methods out of line. Prove of concept: eeckstein@f4af4d1
We can do this also after this PR has been merged.

@hjyamauchi hjyamauchi merged commit 34def0e into swiftlang:main Sep 23, 2024
5 checks passed
@hjyamauchi
Copy link
Contributor Author

Oh nice! Merged (hoping it's not too much trouble rebasing that). Thank you!
If you can rebase/adapt eeckstein@f4af4d1 after it, it'd be great. (Or I could also do that myself, just please lmk.)

@hjyamauchi
Copy link
Contributor Author

@eeckstein Actually I'll test eeckstein@f4af4d1 in my local setup and create a PR, if that's okay.

@hjyamauchi
Copy link
Contributor Author

@eeckstein I locally tested and it can build the toolchain as before (no regression.) I created #76675 based on eeckstein@f4af4d1.
Please take a look. The CI is currently running.

hjyamauchi added a commit to hjyamauchi/swift that referenced this pull request Oct 28, 2024
On Windows ARM64, how a struct value type is returned is sensitive to
conditions including whether a user-defined constructor exists,
etc. See

https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#return-values

That caused a calling convention mismatch between the
non-USED_IN_CPP_SOURCE (Swift) side and the USE_IN_CPP_SOURCE (C++)
side and a crash.

Following swiftlang#76433 add
constructors to several bridged C++ struct/class types so that the
calling convention matches.

This is a partial fix for swiftlang#74866

Cherrypick swiftlang#76589
hjyamauchi added a commit to hjyamauchi/swift that referenced this pull request Oct 28, 2024
On Windows ARM64, how a struct value type is returned is sensitive to
conditions including whether a user-defined constructor exists,
etc. See

https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#return-values

That caused a calling convention mismatch between the
non-USED_IN_CPP_SOURCE (Swift) side and the USE_IN_CPP_SOURCE (C++)
side and a crash.

Following swiftlang#76433 add constructors to several bridged C++ struct/class
types so that the calling convention matches.

This is a partial fix for swiftlang#74866

Cherrypick swiftlang#76589
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