Skip to content

Conversation

@qiongsiwu
Copy link

The by-name lookup APIs are intended for Swift. swiftlang/swift#85555 teaches Swift to use it. The original intention was to invoke the finalization API explicitly. swiftlang/swift#85555 folds the finalization step into the module dependency scanner's destructor. This leads to a case where if an initialization error occurs, the CIWithContext may not be setup for some workers, and calling the finalization API is incorrect.

This PR checks against the existence of the CIWithContext and then performs the finalization.

@qiongsiwu qiongsiwu requested a review from a team as a code owner December 19, 2025 18:55
@qiongsiwu
Copy link
Author

qiongsiwu commented Dec 19, 2025

Note to reviewers:

  1. I don't think the current API design fits well into the use case (especially being called in the destructor of its users). I'd like to redesign the API for finalization, but I feel like that may be too much for this PR and its twin [DependencyScanning] Perform Clang Module By-Name Dependency Query Using a Shared Clang Compiler Instance swift#85555. I plan to come back to this once these two PRs land.
  2. We have test coverage for Swift https://github.com/swiftlang/swift/blob/6b3e5613203007b9a0494082b9046736e2a008b4/unittests/DependencyScan/ModuleDeps.cpp#L447 for exactly this case. That's how I discovered the problem. I will add a similar unit test case on the clang side when I refactor the API.

@qiongsiwu
Copy link
Author

Please test with following PR:
swiftlang/swift#85555

@swift-ci please test

Copy link

@jansvoboda11 jansvoboda11 left a comment

Choose a reason for hiding this comment

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

Makes sense. I agree that we should make the API more ergonomic.

@qiongsiwu qiongsiwu force-pushed the fix_finalization_136303612 branch from a8bf360 to 03f31d7 Compare December 21, 2025 03:24
@qiongsiwu
Copy link
Author

Please test with following PR:
swiftlang/swift#85555

@swift-ci please test

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.

3 participants