Skip to content

[cxx-interop] Fix compiler crash when importing non-public members with -g #80485

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 5 commits into from
Apr 10, 2025

Conversation

j-hui
Copy link
Contributor

@j-hui j-hui commented Apr 3, 2025

Importing private members while the compiler is passed the -g flag causes an assertion to be tripped. This patch fixes it.

This PR is stacked on top of #80515, which introduces a new test case (without changing the compiler itself). This PR includes adds -g to that test case.

rdar://148481025

@j-hui j-hui force-pushed the fix-interop-private-debug-symbols branch from 4a88a4a to d78c77d Compare April 3, 2025 23:16
@j-hui j-hui marked this pull request as ready for review April 3, 2025 23:16
@j-hui
Copy link
Contributor Author

j-hui commented Apr 3, 2025

@swift-ci please test

@j-hui j-hui force-pushed the fix-interop-private-debug-symbols branch from d78c77d to 6b6eb28 Compare April 3, 2025 23:21
@j-hui
Copy link
Contributor Author

j-hui commented Apr 3, 2025

@swift-ci please test

@j-hui j-hui force-pushed the fix-interop-private-debug-symbols branch from 6b6eb28 to a3eaa34 Compare April 4, 2025 01:52
@j-hui
Copy link
Contributor Author

j-hui commented Apr 4, 2025

@swift-ci please test

Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

Good question what is going on on the Windows build bot but the change itself looks good to me.

@j-hui j-hui force-pushed the fix-interop-private-debug-symbols branch from a3eaa34 to 2bfe95e Compare April 4, 2025 16:45
@j-hui
Copy link
Contributor Author

j-hui commented Apr 4, 2025

@swift-ci please test

@j-hui j-hui force-pushed the fix-interop-private-debug-symbols branch from 2bfe95e to 3bb3794 Compare April 6, 2025 03:27
j-hui added 2 commits April 8, 2025 16:25
When generating debug symbols for private Clang types (which we started
importing recently), the compiler crashes due to an assertion failure
from ClangModuleUnit::getDiscriminatorForPrivateDecl(), which is called
by getFilePrivateScope().

This patch fixes the issue crash by not calling getFilePrivateScope()
for Clang types types. A discriminator is usually needed to disambiguate
private Swift types declared in different files, but Clang types follow
different scoping conventions that make this discriminator unnecessary.

rdar://148481025
@j-hui j-hui force-pushed the fix-interop-private-debug-symbols branch from 3bb3794 to db1dc9f Compare April 9, 2025 00:05
@j-hui
Copy link
Contributor Author

j-hui commented Apr 9, 2025

@swift-ci please test

@j-hui j-hui enabled auto-merge (squash) April 9, 2025 18:07
@j-hui
Copy link
Contributor Author

j-hui commented Apr 9, 2025

@swift-ci please smoke test

1 similar comment
@j-hui
Copy link
Contributor Author

j-hui commented Apr 9, 2025

@swift-ci please smoke test

@j-hui
Copy link
Contributor Author

j-hui commented Apr 9, 2025

@swift-ci please test

@j-hui j-hui merged commit dd2f465 into main Apr 10, 2025
5 checks passed
@j-hui j-hui deleted the fix-interop-private-debug-symbols branch April 10, 2025 05:32
j-hui added a commit to j-hui/swift that referenced this pull request Apr 10, 2025
swiftlang#80485)

When generating debug symbols for private Clang types (which we started
importing recently), the compiler crashes due to an assertion failure
from ClangModuleUnit::getDiscriminatorForPrivateDecl(), which is called
by getFilePrivateScope().

This patch fixes the issue crash by not calling getFilePrivateScope()
for Clang types. A discriminator is usually needed to disambiguate
private Swift types declared in different files, but Clang types follow
different scoping conventions that make this discriminator unnecessary.

rdar://148481025
(cherry picked from commit dd2f465)
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.

5 participants