Skip to content

[ModuleInterface] Ignore export_as in private swiftinterface #62476

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
Dec 13, 2022

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Dec 9, 2022

Introduce a new behavior when printing references to modules with an export_as definition. Use the export_as name in the public swiftinterface and the real module name in the private swiftinterface.

This has some limits but should still be an improvement over the current behavior. First, the we use the export_as names only for references to clang decls, not Swift decls with an underlying module defining an export_as. Second, we always print the export_as name in the public swiftinterface, even in the original swiftinterface file when the export_as target is likely not know, so that generated swiftinterface is still broken.

This behavior is enabled by the flags -enable-experimental-feature ModuleInterfaceExportAs or the SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY env var. We may consider turning it on by default in the future.

rdar://98532918

@xymus
Copy link
Contributor Author

xymus commented Dec 9, 2022

@swift-ci Please smoke test

@xymus xymus changed the title [ModuleInterface] Always use the exported name in private swiftinterface [ModuleInterface] Ignore export_as in private swiftinterface Dec 9, 2022
@xymus xymus force-pushed the module-interface-export-as branch from 85ae6ec to 49f6ea9 Compare December 9, 2022 17:42
@xymus
Copy link
Contributor Author

xymus commented Dec 9, 2022

@swift-ci Please smoke test

@xymus xymus force-pushed the module-interface-export-as branch from 49f6ea9 to 91a207f Compare December 9, 2022 18:44
@xymus
Copy link
Contributor Author

xymus commented Dec 9, 2022

@swift-ci Please smoke test

@xymus xymus requested a review from tshortli December 12, 2022 22:35
@xymus
Copy link
Contributor Author

xymus commented Dec 12, 2022

I tried this version in a rather large project and it appears to work as desired, except for a single imported framework that didn't behave as expected. I suspect a conflict with the logic overriding the imported name to workaround poorly modularized clang modules. We can keep this behind a flag for now until we track down that issue.

Introduce a new behavior when printing references to modules with an
`export_as` definition. Use the `export_as` name in the public swiftinterface
and the real module name in the private swiftinterface.

This has some limits but should still be an improvement over the current
behavior. First, the we use the `export_as` names only for references to clang
decls, not Swift decls with an underlying module defining an `export_as`.
Second, we always print the `export_as` name in the public swiftinterface,
even in the original swiftinterface file when the `export_as` target is likely
not know, so that generated swiftinterface is still broken.

This behavior is enabled by the flags `-enable-experimental-feature ModuleInterfaceExportAs`
or the `SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY` env var. We may
consider turning it on by default in the future.

rdar://98532918
@xymus xymus force-pushed the module-interface-export-as branch from 91a207f to ab38752 Compare December 12, 2022 22:58
@xymus
Copy link
Contributor Author

xymus commented Dec 12, 2022

@swift-ci Please smoke test

@xymus
Copy link
Contributor Author

xymus commented Dec 12, 2022

The issue with a single imported framework was likely just caused by a clang module cached while using different search paths. This shouldn't be a problem in practice.

@xymus xymus merged commit 276281d into swiftlang:main Dec 13, 2022
@xymus xymus deleted the module-interface-export-as branch December 13, 2022 17:12
@xymus xymus restored the module-interface-export-as branch December 13, 2022 17:12
@xymus xymus deleted the module-interface-export-as branch December 13, 2022 17:12
@xymus xymus restored the module-interface-export-as branch December 13, 2022 17:12
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.

1 participant