Skip to content

Import _CSwiftSyntax using @_implementationOnly. #140

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
Aug 23, 2019

Conversation

allevato
Copy link
Member

This lets us add an actual header for the C function it defines, so that Swift can import it directly (while still retaining the property that it is a standalone module) instead of relying on the dlsym trick that fails on Linux unless additional flags are passed to the linker for any binary that depends on SwiftSyntax (see https://bugs.swift.org/browse/SR-11293).

Note: I tested this by taking the resulting SwiftSyntax.swiftmodule and importing it into a context where the _CSwiftSyntax module map wasn't present, and it succeeded, so the @_implementationOnly import worked as intended. Even though this is currently a private feature, is there any reason we shouldn't move forward with this, since it's a cleaner fix for bugs like the one above than to ask folks on Linux to pass additional linker flags to all their executables?

@allevato allevato requested a review from akyrtzi August 22, 2019 22:27
Copy link
Contributor

@akyrtzi akyrtzi 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! 🙏
I don't have any concerns about using @_implementationOnly.

@akyrtzi
Copy link
Contributor

akyrtzi commented Aug 22, 2019

@swift-ci Please test

@akyrtzi
Copy link
Contributor

akyrtzi commented Aug 22, 2019

Ah, it would be good for the implementation file to include its header.

@allevato allevato force-pushed the fix-atomic-counter branch from e59c675 to d66ea53 Compare August 22, 2019 23:27
@allevato
Copy link
Member Author

Ah, it would be good for the implementation file to include its header.

Done!

@@ -1,3 +1,5 @@
#include "atomic-counter.h"

#include <stdint.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, this #include can be removed now.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was wondering if you'd ask me to remove that or not! I usually try not to rely on indirect inclusions for unrelated types, but since it's part of the signature in this case, it doesn't really matter. Done.

This lets us add an actual header for the C function it defines,
so that Swift can import it directly (while still retaining the
property that it is a standalone module) instead of relying on
the dlsym trick that fails on Linux unless additional flags are
passed to the linker for any binary that depends on SwiftSyntax
(see https://bugs.swift.org/browse/SR-11293).
@allevato allevato force-pushed the fix-atomic-counter branch from d66ea53 to efd4dc8 Compare August 22, 2019 23:40
@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e59c675

@akyrtzi
Copy link
Contributor

akyrtzi commented Aug 22, 2019

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e59c675

@SDGGiesbrecht
Copy link

...a cleaner fix for bugs like the one above than to ask folks on Linux to pass additional linker flags to all their executables...

❤️

@akyrtzi akyrtzi merged commit 89ce45a into swiftlang:master Aug 23, 2019
adevress pushed a commit to adevress/swift-syntax that referenced this pull request Jan 14, 2024
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