Skip to content

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

Merged
merged 2 commits into from
May 27, 2025

Conversation

xymus
Copy link
Contributor

@xymus xymus commented May 19, 2025

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.

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.
@xymus
Copy link
Contributor Author

xymus commented May 19, 2025

@swift-ci Please test

@nkcsgexi
Copy link

Woohoo!

@nkcsgexi nkcsgexi requested a review from DougGregor May 19, 2025 20:58
Now that compatibility header tests run on Windows we need to update how
we check for paths to support the platform properly.
@xymus
Copy link
Contributor Author

xymus commented May 19, 2025

@swift-ci Please test

@xymus
Copy link
Contributor Author

xymus commented May 20, 2025

@swift-ci test windows

@jakepetroules
Copy link
Contributor

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.

Copy link
Member

@DougGregor DougGregor left a 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.

@xymus
Copy link
Contributor Author

xymus commented May 20, 2025

@swift-ci Please test windows

3 similar comments
@xymus
Copy link
Contributor Author

xymus commented May 21, 2025

@swift-ci Please test windows

@xymus
Copy link
Contributor Author

xymus commented May 23, 2025

@swift-ci Please test windows

@xymus
Copy link
Contributor Author

xymus commented May 27, 2025

@swift-ci Please test windows

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Thank you!

@xymus
Copy link
Contributor Author

xymus commented May 27, 2025

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 requires objc and we don't pass a header search path to C targets that would allow non-modular includes. I'll see to lift those restrictions in my next PR.

@xymus xymus merged commit f625710 into swiftlang:main May 27, 2025
6 checks passed
@xymus xymus deleted the compat-header-enable branch May 27, 2025 22:19
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.

4 participants