Skip to content
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

Swift: turn extractor into a swift-frontend plugin #12713

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

redsun82
Copy link
Contributor

This change turns the extractor into a plugin to a slightly modified swift-extractor binary, providing only a swift::FrontendObserver instance.

This makes it so that we inherit the behaviours of the released swift-frontend, among the known solved issues are:

  • work around the issue preventing the Linux extractor from compiling stdlib .swiftinterface files, which was preventing the extractor from working on top of earlier versions of the swift SDK
  • @-prefixed parameter files are now supported

Under the hood the Swift build system has been tweaked so that calls to performFrontend in the driver executable use a FrontendObserver built from a dynamic library, and the extractor now provides an alternative frontend observer dynamic library.

Some special treatment needed to retain the same features:

  • a new finished method was added to swift::FrontendObserver to implement the file_is_successfully_extracted predicate
  • part of the swift AST library (Identifier) needed to be extracted into a separate dynamic library as well, as behaviour was depending on the value of static pointers that therefore needed to be shared between swift-frontend and the extractor
  • the CODEQL_EXTRACTOR_SWIFT_RUN_UNDER functionality has been moved to the extractor bash wrapper, which also makes it work better to catch crashes happening before main is even entered (which can happen with tracer problems)

@github-actions github-actions bot added the Swift label Mar 30, 2023
@redsun82 redsun82 force-pushed the redsun82/swift-extractor-as-plugin branch 4 times, most recently from ab96bc6 to aef4f79 Compare April 5, 2023 04:12
redsun82 added 2 commits April 5, 2023 13:20
This change turns the extractor into a plugin to a slightly modified
`swift-extractor` binary, providing only a `swift::FrontendObserver`
instance.

This makes it so that we inherit the behaviours of the released
`swift-frontend`, among the known solved issues are:
* work around the issue preventing the Linux extractor from compiling
  stdlib `.swiftinterface` files, which was preventing the extractor
  from working on top of earlier versions of the swift SDK
* `@`-prefixed parameter files are now supported

Under the hood the Swift build system has been tweaked so that calls to
`performFrontend` in the driver executable use a `FrontendObserver`
built from a dynamic library, and the extractor now provides an
alternative frontend observer dynamic library.

Some special treatment needed to retain the same features:
* a new `finished` method was added to `swift::FrontendObserver` to
  implement the `file_is_successfully_extracted` predicate
* part of the swift AST library (`Identifier`) needed to be extracted
  into a separate dynamic library as well, as behaviour was depending on
  the value of static pointers that therefore needed to be shared
  between `swift-frontend` and the extractor
* the `CODEQL_EXTRACTOR_SWIFT_RUN_UNDER` functionality has been moved
  to the `extractor` bash wrapper, which also makes it work better to
  catch crashes happening before `main` is even entered (which can
  happen with tracer problems)
@redsun82 redsun82 force-pushed the redsun82/swift-extractor-as-plugin branch from d0c8677 to d5b219b Compare April 5, 2023 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant