Skip to content

[cxx-interop] Install swift/bridging header in a different location #72154

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

Closed
wants to merge 1 commit into from

Conversation

egorzhdan
Copy link
Contributor

The recent Clang compiler change makes -fno-modulemap-allow-subdirectory-search the default behavior. This means that projects that use C++ interop and #include <swift/bridging> no longer compile, since Clang won't search for the SwiftBridging module under usr/include/swift anymore.

This change moves the header to usr/include/SwiftBridging. The directory name matches the Clang module name, which will help Clang find this header along with the modulemap.

rdar://123334601

The recent Clang compiler change makes `-fno-modulemap-allow-subdirectory-search` the default behavior. This means that projects that use C++ interop and `#include <swift/bridging>` no longer compile, since Clang won't search for the SwiftBridging module under `usr/include/swift` anymore.

This change moves the header to `usr/include/SwiftBridging`. The directory name matches the Clang module name, which will help Clang find this header along with the modulemap.

rdar://123334601
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Mar 7, 2024
@egorzhdan egorzhdan requested review from zoecarver and hyp as code owners March 7, 2024 14:02
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan requested a review from vsapsai March 7, 2024 14:03
@vsapsai
Copy link
Contributor

vsapsai commented Mar 8, 2024

Let me test it on an actual project.

@vsapsai
Copy link
Contributor

vsapsai commented Mar 8, 2024

Let me test it on an actual project.

Ok, with SwiftBridging it works on a test project.

Copy link
Contributor

@vsapsai vsapsai left a comment

Choose a reason for hiding this comment

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

As far as I can tell, the change is correct (though I'm not a CMake expert). What I really don't know is if some other CMakeLists.txt files need to be updated too. I usually deal with that through the trial-and-error.

As for migrating existing code from "swift/bridging" to "SwiftBridging/bridging" I have no opinion. At least I believe it is possible to support both versions with

#if __has_include(<SwiftBridging/bridging>)
# include <SwiftBridging/bridging>
#else
# include <swift/bridging>
#endif

@egorzhdan
Copy link
Contributor Author

Hmm, I think we don't actually want to change the user-facing path of the header (<swift/bridging>). Let me tweak this.

@egorzhdan
Copy link
Contributor Author

Trying out another approach: #72186

@egorzhdan egorzhdan closed this Mar 11, 2024
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.

2 participants