Skip to content

[Dependency Scanning] Initialize Swift modules in libSwiftScan on scanner creation #72104

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 1 commit into from
Mar 20, 2024

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Mar 5, 2024

Resolves rdar://124100615

@artemcm
Copy link
Contributor Author

artemcm commented Mar 5, 2024

@swift-ci test

@artemcm artemcm force-pushed the InitSwiftModulesInDepScan branch from f2c8941 to 96d09d2 Compare March 6, 2024 22:34
@@ -110,8 +110,8 @@ void registerBridgedClass(BridgedStringRef bridgedClassName, SwiftMetatype metat
SILNodeKind kind = iter->second;
SwiftMetatype existingTy = nodeMetatypes[(unsigned)kind];
if (existingTy) {
llvm::errs() << "Double registration of class " << className << '\n';
abort();
// We have already registered this class
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@egorzhdan @eeckstein
What's the possible harm in doing this?
We have a library (libSwiftScan) that gets loaded from a long-running process which needs to occasionally initialize a new instance of the tool the library provides (swiftscan_scanner_create in this same PR diff), which needs the ability to initializeSwiftModules. The same place currently calls INITIALIZE_LLVM and that seems to support doing nothing on repeated initialization calls.

Copy link
Contributor

@eeckstein eeckstein Mar 7, 2024

Choose a reason for hiding this comment

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

I added this check to catch possible inconsistencies when registering classes. Your change works, though it would be somehow nicer to keep this check and guard the initialization call with

if (!swiftModulesInitialized())
  initializeSwiftModules();

Then there is no problem if (for whatever reason) we add some registration code which truly must not run twice.

@artemcm
Copy link
Contributor Author

artemcm commented Mar 6, 2024

@swift-ci test

@artemcm artemcm force-pushed the InitSwiftModulesInDepScan branch from 96d09d2 to 11ea462 Compare March 14, 2024 22:37
@artemcm
Copy link
Contributor Author

artemcm commented Mar 14, 2024

@swift-ci test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

@artemcm
Copy link
Contributor Author

artemcm commented Mar 15, 2024

@swift-ci test macOS platform

@artemcm
Copy link
Contributor Author

artemcm commented Mar 15, 2024

@swift-ci test Windows platform

@artemcm
Copy link
Contributor Author

artemcm commented Mar 15, 2024

@swift-ci test macOS platform

1 similar comment
@artemcm
Copy link
Contributor Author

artemcm commented Mar 15, 2024

@swift-ci test macOS platform

@artemcm
Copy link
Contributor Author

artemcm commented Mar 18, 2024

@swift-ci test macOS Platform

@artemcm
Copy link
Contributor Author

artemcm commented Mar 18, 2024

Hmm, we seem to be getting:

unexpected service error: The Xcode build system has crashed. Build again to continue.

From SPM tests that actually may be using this libSwiftScan.

@artemcm
Copy link
Contributor Author

artemcm commented Mar 19, 2024

@swift-ci test macOS Platform

@artemcm artemcm force-pushed the InitSwiftModulesInDepScan branch from 11ea462 to e755e72 Compare March 19, 2024 20:01
@artemcm
Copy link
Contributor Author

artemcm commented Mar 19, 2024

@swift-ci test

@artemcm artemcm merged commit 716a1a9 into swiftlang:main Mar 20, 2024
@artemcm artemcm deleted the InitSwiftModulesInDepScan branch March 20, 2024 16:22
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