Skip to content

[cxx-interop] [nfc] Remove swift namespace from SwiftShims in C++ mode. #32715

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
Jul 8, 2020

Conversation

zoecarver
Copy link
Contributor

Most SwiftShims were put in the swift namespace in C++ mode which broke certain things when importing them in a swift file with C++ interop enabled. This was OK when they were only imported as part of the swift runtime but, now they are used in C++ mode both in the swift runtime and when C++ interop is enabled.

@zoecarver zoecarver added the c++ interop Feature: Interoperability with C++ label Jul 5, 2020
@zoecarver zoecarver requested a review from gribozavr July 5, 2020 23:42
Copy link
Contributor

@gribozavr gribozavr left a comment

Choose a reason for hiding this comment

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

To be more specific, the Swift serialized module file contains references to symbols in SwiftShims headers. Since the standard library is built in default mode (without C++ interop) the symbols in SwiftShims headers are in the global namespace. When we enable C++ interop, it affects SwiftShims headers, too, and the symbols can't be found in the global namespace anymore. Therefore, the compiler can't deserialize certain parts of the Swift module.

@zoecarver I'd appreciate if you could put that into your commit description for future readers.

@gribozavr
Copy link
Contributor

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 6, 2020

Build failed
Swift Test Linux Platform
Git Sha - e8c01df92332a75efec0df2dfef9d9929c56f8f3

@swift-ci
Copy link
Contributor

swift-ci commented Jul 6, 2020

Build failed
Swift Test OS X Platform
Git Sha - e8c01df92332a75efec0df2dfef9d9929c56f8f3

@gottesmm
Copy link
Contributor

gottesmm commented Jul 6, 2020

@gribozavr I would prefer if we just fix this here now. A force push doesn't hurt anyone and commit msgs are important;

@zoecarver
Copy link
Contributor Author

zoecarver commented Jul 6, 2020

@gottesmm I'm in the process of rebasing/fixing the build errors now. Once that's done, I'll squash the commits and update the commit message.

@zoecarver zoecarver force-pushed the fix/cxx/swift-namespace branch from e8c01df to 5183caf Compare July 6, 2020 21:39
@zoecarver
Copy link
Contributor Author

@gottesmm @gribozavr I've updated the commit message.

Sorry for the delay. I had to rebuild everything after updating checkouts, then had to update Xcode and rebuild everything again 🤦

@zoecarver
Copy link
Contributor Author

@swift-ci please test.

1 similar comment
@zoecarver
Copy link
Contributor Author

@swift-ci please test.

@zoecarver
Copy link
Contributor Author

@swift-ci please test windows platform.

@zoecarver
Copy link
Contributor Author

@swift-ci please test Windows platform.

@swift-ci
Copy link
Contributor

swift-ci commented Jul 6, 2020

Build failed
Swift Test Linux Platform
Git Sha - 5183caf472abe75bf42acba245193a15b332f462

@zoecarver zoecarver force-pushed the fix/cxx/swift-namespace branch from 5183caf to 3948176 Compare July 7, 2020 16:13
@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test

@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test.

Most SwiftShims were put in the swift namespace in C++ mode which broke certain things when importing them in a swift file in C++ mode. This was OK when they were only imported as part of the swift runtime but, now they are used in C++ mode both in the swift runtime and when C++ interop is enabled.

This broke when C++ interop was enabled because the `Swift` module contains references to symbols in the SwiftShims headers which are built without C++ interop enabled (no "swift" namespace). But, when C++ interop is enabled, the SwiftShims headers would put everything in the swift namespace meaning the symbols couldn't be found in the global namespace. Then, the compiler would error when trying to deserialize the Swift module.
@zoecarver zoecarver force-pushed the fix/cxx/swift-namespace branch from 3948176 to 7f91f03 Compare July 7, 2020 18:03
@zoecarver
Copy link
Contributor Author

@swift-ci Please smoke test Linux platform

@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test Linux platform.

@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test Linux platform

@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test OS X platform

1 similar comment
@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test OS X platform

@zoecarver
Copy link
Contributor Author

zoecarver commented Jul 8, 2020

I've updated the commit message. @gottesmm @gribozavr unless you want me to change the commit message further or have any other review comments, I'm going to plan to commit this tomorrow.

@gribozavr
Copy link
Contributor

LGTM, including the commit message! Please merge when you're ready.

@zoecarver zoecarver merged commit 7eff49c into swiftlang:master Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants