Skip to content

Conversation

@qiongsiwu
Copy link
Contributor

@qiongsiwu qiongsiwu commented Nov 18, 2025

This PR teaches Swift to take advantage of the new clang dependency scanning API to use a single clang compiler instance per dependency scanning worker to perform by-name queries.

rdar://136303612

@qiongsiwu
Copy link
Contributor Author

qiongsiwu commented Nov 18, 2025

Note that CAS/plugin_cas.swift may fail before #85547 lands.

@qiongsiwu
Copy link
Contributor Author

Please test with following PR:
swiftlang/llvm-project#11821

@swift-ci please smoke test

@qiongsiwu qiongsiwu force-pushed the eng_136303612_SharingCI branch from fffde38 to 59c3895 Compare November 18, 2025 17:23
@qiongsiwu
Copy link
Contributor Author

Please test with following PR:
swiftlang/llvm-project#11821

@swift-ci please smoke test

@qiongsiwu
Copy link
Contributor Author

Please test with following PR:
swiftlang/llvm-project#11821

@swift-ci please smoke test

@qiongsiwu
Copy link
Contributor Author

@swift-ci please smoke test

@qiongsiwu
Copy link
Contributor Author

@swift-ci please test

@qiongsiwu
Copy link
Contributor Author

@swift-ci please test llvm

@qiongsiwu
Copy link
Contributor Author

@swift-ci please smoke test

@qiongsiwu
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

Very cool!

@qiongsiwu
Copy link
Contributor Author

@swift-ci please smoke test

@qiongsiwu qiongsiwu requested a review from artemcm December 2, 2025 16:26
@qiongsiwu
Copy link
Contributor Author

Thanks for the suggestions!

The latest commit folds the initialization into a create static method and move the constructor to a private method. The finalization is folded into the destructor of the ModuleDependencyScanner. I will need to update the clang side because the finalization implementation on the clang side cannot handle the situation where the initialization was never successful. Now we call the finalization in the destructor, we can be in a situation where the initialization never succeeds, and finalization is still called. I don't feel like having a status flag in the Swift ModuleDependencyScanner to track the initialization state so we can finalize correctly.

@qiongsiwu qiongsiwu requested a review from artemcm December 16, 2025 03:52
 Conflicts:
	include/swift/DependencyScan/ModuleDependencyScanner.h
	lib/DependencyScan/ModuleDependencyScanner.cpp
	lib/DependencyScan/ScanDependencies.cpp
@qiongsiwu
Copy link
Contributor Author

Please test with following PR:
swiftlang/llvm-project#12029

@swift-ci please smoke test

@qiongsiwu
Copy link
Contributor Author

Please test with following PR:
swiftlang/llvm-project#12029

@swift-ci please smoke test Windows

qiongsiwu added a commit to swiftlang/llvm-project that referenced this pull request Jan 3, 2026
…xt instance that does not exist. (#12029)

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.

rdar://136303612
@qiongsiwu qiongsiwu merged commit 954c8a2 into swiftlang:main Jan 3, 2026
3 checks passed
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