Skip to content

Rely on libSwiftScan for dependency scanning actions. #427

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 20 commits into from
Feb 5, 2021

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Jan 8, 2021

This PR changes the dependency scanning action to rely on the newly-introduced libSwiftScan library, instead of making calls to swift-frontend -scan-dependencies and parsing back their JSON output.

  • Adds target CSwiftScan that contains the C header which captures all the required symbols from libSwiftScan.
    • Adds a SwiftScan subdirectory in the SwiftDriver target which contains code responsible for interactiosn with libSwiftScan.
  • Adds a library instance wrapper (SwiftScan) which takes care of initialization, shutdown, and dispatching dependency scanning queries to a library instance.
  • Adds a collection of utilities (in DependencyGraphBuilder.swift) to translate dependency scanning query inputs into the C library expected format and translate the dependency scanning binary output format into the format the driver understands (InterModuleDependencyGraph).

Merging this is dependent on swiftlang/swift#34786 being merged and making it into a snapshot toolchain.

Additional cleanup will follow this once clients (SwiftPM) switch to the new API. For example, the notion of a placeholder module will go away completely so all of the placeholder resolution code will become unnecessary.

@artemcm artemcm requested a review from nkcsgexi January 8, 2021 01:11
@artemcm
Copy link
Contributor Author

artemcm commented Jan 11, 2021

@swift-ci please test

1 similar comment
@artemcm
Copy link
Contributor Author

artemcm commented Jan 11, 2021

@swift-ci please test

@nkcsgexi
Copy link
Contributor

So excited to see libSwiftScanner is used here to enhance build performance! Is it difficult to also preserve the old interaction form of JSON files? One benefit of that is we can get a peek inside the scanning process for debugging purposes.

@artemcm
Copy link
Contributor Author

artemcm commented Jan 11, 2021

So excited to see libSwiftScanner is used here to enhance build performance! Is it difficult to also preserve the old interaction form of JSON files? One benefit of that is we can get a peek inside the scanning process for debugging purposes.

No, shouldn't be difficult. I'll add an option for this.

@artemcm
Copy link
Contributor Author

artemcm commented Jan 11, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Jan 11, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Jan 12, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Jan 12, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Jan 25, 2021

@swift-ci please test

4 similar comments
@artemcm
Copy link
Contributor Author

artemcm commented Jan 26, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Jan 26, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Jan 26, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Jan 26, 2021

@swift-ci please test

@artemcm
Copy link
Contributor Author

artemcm commented Feb 3, 2021

@nkcsgexi ping

… libSwiftScan, instead of launching `swift-frontend` processes and capturing their output.

- Adds target `CSwiftScan` that contains the C header which captures all the required symbols from `libSwiftScan`.
- Adds a `SwiftScan` subdirectory in the `SwiftDriver` target which contains code responsible for interactiosn with `libSwiftScan`.
  - A wrapper class (`SwiftScan`) taking care of initialization, shutdown, and dispatching dependency scanning queries to a library instance.
  - A collection of utilities (in `DependencyGraphBuilder.swift`) to translate dependency scanning query inputs into the C library expected format and translate the dependency scanning output into the format the driver understands (`InterModuleDependencyGraph`).
Using a persistent libSwiftScan instance across targets of the same build allows us to forego the notion of a placeholder module.
Instead of communicating a placeholder module for some external target `C` to the scanner, the scanner will have previously scanned `C` because targets are planned in dependency order. This means the scanner will have an entry for module `C` as a module to be built from source-code.

The driver needs to detect external targets and update the dependency graph to represent them as binary pre-built modules, instead of building them once again.
The latter subsumes the former's purpose now.
…tion"

This reverts commit 00678f3.
Placeholder resolution needs to stick around while SwiftPM transitions to the new Oracle API.
…able dependency scanner instead of using libSwiftScan
And add an environment variable to overload the toolchain used to locate the swiftScan dylib
…constructing the `InterModuleDependencyGraph`
To have more information for debugging when failing in one environment (e.g. CI) but not other.
…pendency scanning queries if no instance of libSwiftScan is found.
@artemcm
Copy link
Contributor Author

artemcm commented Feb 5, 2021

@swift-ci please test

@artemcm artemcm merged commit 9b20c9d into swiftlang:main Feb 5, 2021
@nkcsgexi
Copy link
Contributor

nkcsgexi commented Feb 5, 2021

🥳

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