-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Generate the compatibility header for libraries on all platforms #8695
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
Conversation
Enable generating the compatibility header for library targets on all platforms by lifting the restriction on Darwin. As part of the work to formalize `@cdecl` we've been adding content to the compatibility header that is usable by C compilers without the need for Objective-C or modules. Lifting this restriction will allow Linux and Windows users to generate and import the compatibility header in their packages.
@swift-ci Please test |
Woohoo! |
Now that compatibility header tests run on Windows we need to update how we check for paths to support the platform properly.
@swift-ci Please test |
@swift-ci test windows |
Took a quick look at Swift Build and I think we don't need any changes there; I see in my Android builds that the -Swift.h file is already being generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me. I recommend doing a quick search of open GitHub issues that mention the generated header, because this probably fixes some.
@swift-ci Please test windows |
3 similar comments
@swift-ci Please test windows |
@swift-ci Please test windows |
@swift-ci Please test windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I found two related issues. #7319 should be fixed by this PR as they were only asking for the compatibility header to be generated on non-Darwin platforms. However there are still hurdles to import the compatibility header from a C/C++ source file and actually use it. I'm aware of two restrictions, both mentioned in #7257: the module map for the compatibility header is printed with |
…t libraries (#8736) Address two issues preventing a C source file to import the generated compatibility header: 1. Don't mark the module map generated for the compatibility header as `requires objc`. This triggers an error when importing it from a C source file. The compatibility header is already printed in a way where the Objective-C code is protected behind a language check. C clients can safely import it even if they may not see any content. Plus we're adding C content to the compatibility header with the official support for `@cdecl` that is independent of Objective-C. 2. Emit the generated compatibility header and module map in a new `include` directory under the temporary build directory of each Swift library. This directory is then used as a header search path for the dependent clang targets. This replaces the previous strategy that relied only the generated module map to resolve imports. It was incompatible with C source files and non-modular textual includes. The use of a header search path preserves the support for module imports via the same module map and supports textual includes of the compatibility header. Fixes #7257. Follow up to #8695.
…t libraries (swiftlang#8736) Address two issues preventing a C source file to import the generated compatibility header: 1. Don't mark the module map generated for the compatibility header as `requires objc`. This triggers an error when importing it from a C source file. The compatibility header is already printed in a way where the Objective-C code is protected behind a language check. C clients can safely import it even if they may not see any content. Plus we're adding C content to the compatibility header with the official support for `@cdecl` that is independent of Objective-C. 2. Emit the generated compatibility header and module map in a new `include` directory under the temporary build directory of each Swift library. This directory is then used as a header search path for the dependent clang targets. This replaces the previous strategy that relied only the generated module map to resolve imports. It was incompatible with C source files and non-modular textual includes. The use of a header search path preserves the support for module imports via the same module map and supports textual includes of the compatibility header. Fixes swiftlang#7257. Follow up to swiftlang#8695.
…t libraries (swiftlang#8736) Address two issues preventing a C source file to import the generated compatibility header: 1. Don't mark the module map generated for the compatibility header as `requires objc`. This triggers an error when importing it from a C source file. The compatibility header is already printed in a way where the Objective-C code is protected behind a language check. C clients can safely import it even if they may not see any content. Plus we're adding C content to the compatibility header with the official support for `@cdecl` that is independent of Objective-C. 2. Emit the generated compatibility header and module map in a new `include` directory under the temporary build directory of each Swift library. This directory is then used as a header search path for the dependent clang targets. This replaces the previous strategy that relied only the generated module map to resolve imports. It was incompatible with C source files and non-modular textual includes. The use of a header search path preserves the support for module imports via the same module map and supports textual includes of the compatibility header. Fixes swiftlang#7257. Follow up to swiftlang#8695.
Enable generating the compatibility header for library targets on all platforms by lifting the restriction to Darwin.
As part of the work to formalize
@cdecl
we've been adding content to the compatibility header that is usable by C compilers without the need for Objective-C or modules. Lifting this restriction will allow Linux and Windows users to generate and import the compatibility header to call@cdecl
functions in their package.