Skip to content

[SymbolGraphGen] consider modules not equal if they're not from the same compiler #58421

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 5, 2022

Conversation

QuietMisdreavus
Copy link
Contributor

Resolves rdar://92263972

In #41577, symbols were lifted into the main module's symbol graph if they originated from an @_exported import module. However, the comparison was based on the modules' names, which caused the comparison to spuriously consider symbols to be "re-exported" if an underlying Clang module was present.1 This PR tightens that check to also consider whether the modules being compared for re-exporting are both Swift or non-Swift modules.

Footnotes

  1. When -import-underlying-module is given to the frontend, any headers considered to be part of the same module are aggregated into a separate module with the same name as the Swift module, which is then implicitly @_exported imported into the Swift module. As the comparison added in [SymbolGraphGen] Emit symbols from exported modules #41577 was based on the name of the module, this means that everything that was declared in the Swift module was considered to be re-exported, even if it is technically an extension on a foreign type! Check the test that was added in this PR for an example.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@franklinsch franklinsch 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!

@@ -0,0 +1,19 @@
// RUN: %empty-directory(%t)
// RUN: cp -r %S/Inputs/EmitWhileBuilding/EmitWhileBuilding.framework %t
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-module-path %t/EmitWhileBuilding.framework/Modules/EmitWhileBuilding.swiftmodule/%target-swiftmodule-name -import-underlying-module -F %t -module-name EmitWhileBuilding -disable-objc-attr-requires-foundation-module %s %S/Inputs/EmitWhileBuilding/Extra.swift -emit-symbol-graph -emit-symbol-graph-dir %t
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also have a test that checks the behavior when using swift-symbolgraph-extract, since the behaviors regarding @_export import are different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense! I'll write up a test and push it today.

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test and merge

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please smoke test Linux

@QuietMisdreavus QuietMisdreavus merged commit c885dc6 into main May 5, 2022
@QuietMisdreavus QuietMisdreavus deleted the QuietMisdreavus/module-collision branch May 5, 2022 20:47
QuietMisdreavus added a commit that referenced this pull request Sep 12, 2022
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.

2 participants