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

[cxx-interop] Do not emit C++ interop flag in textual interfaces #77754

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

egorzhdan
Copy link
Contributor

This makes sure that the compiler does not emit -enable-experimental-cxx-interop/-cxx-interoperability-mode flags in .swiftinterface files. Those flags were breaking explicit module builds. The module can still be rebuilt from its textual interface if C++ interop was enabled in the current compilation.

rdar://140203932

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Nov 21, 2024
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@tshortli
Copy link
Contributor

It makes sense to me that when Cxx interop is an implementation detail of a module, but not used in its interface, that the flag should be hidden to avoid affecting the mode in which downstream dependencies are compiled with respect to the client. What about when the interface does depend on Cxx interop, though?

Xazax-hun
Xazax-hun previously approved these changes Nov 21, 2024
@Xazax-hun Xazax-hun dismissed their stale review November 21, 2024 11:28

I have not read Allan's comment before reviewing.

egorzhdan added a commit to swiftlang/swift-driver that referenced this pull request Nov 21, 2024
This change is a counterpart of swiftlang/swift#77754.

rdar://140203932
@egorzhdan
Copy link
Contributor Author

What about when the interface does depend on Cxx interop, though?

If the -cxx-interoperability-flag was passed to the current compiler invocation, it should get propagated to the compiler sub-instance that rebuilds the module from its interface, and the build would succeed. If the flag wasn't passed, the user would see a compiler error when trying to build the module.

The user-facing message isn't ideal, it could explicitly mention the fix of adding the missing flag – we should improve that in the future.

egorzhdan added a commit to swiftlang/swift-driver that referenced this pull request Nov 21, 2024
@egorzhdan
Copy link
Contributor Author

@swift-ci please test with following PR:

swiftlang/swift-driver#1737

@tshortli
Copy link
Contributor

The user-facing message isn't ideal, it could explicitly mention the fix of adding the missing flag – we should improve that in the future.

Ok, yeah I'd like to see something like that in the future to make failures to build textual interfaces more explainable and debuggable. For example, we could require that owners of libraries that emit textual interfaces which externally depend on Cxx interop specify a new flag that does get printed in the interface that causes client builds to fail fast if they do not enable interop themselves. The module interface verification build task should be able to diagnose whether this new flag is needed for the library owner.

@egorzhdan
Copy link
Contributor Author

Please test with following PR:

swiftlang/swift-driver#1737

@swift-ci please test

@egorzhdan egorzhdan force-pushed the egorzhdan/swiftinterface-no-cxx-flag branch from be4698f to 18d9766 Compare November 21, 2024 20:32
@egorzhdan
Copy link
Contributor Author

Please test with following PR:

swiftlang/swift-driver#1737

@swift-ci please test

@egorzhdan egorzhdan force-pushed the egorzhdan/swiftinterface-no-cxx-flag branch from 18d9766 to 2ad47af Compare November 22, 2024 00:55
@egorzhdan
Copy link
Contributor Author

Please test with following PR:

swiftlang/swift-driver#1737

@swift-ci please test

This makes sure that the compiler does not emit `-enable-experimental-cxx-interop`/`-cxx-interoperability-mode` flags in `.swiftinterface` files. Those flags were breaking explicit module builds. The module can still be rebuilt from its textual interface if C++ interop was enabled in the current compilation.

rdar://140203932
@egorzhdan egorzhdan force-pushed the egorzhdan/swiftinterface-no-cxx-flag branch from 2ad47af to a273999 Compare November 22, 2024 02:02
@egorzhdan
Copy link
Contributor Author

Please test with following PR:

swiftlang/swift-driver#1737

@swift-ci please test

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