Skip to content

[5.9 🍒][Dependency Scanner] Ensure the Clang dependency scanner working directory matches the invocation when querying bridging header dependencies #65438

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
Apr 27, 2023

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Apr 26, 2023

Cherry-pick of #65436

• Release: Swift 5.9
• Explanation: The Swift compiler does not have a concept of a working directory. It is instead handled by the Swift driver by resolving relative paths according to the driver's working directory argument. On the other hand, Clang does have a concept working directory which may be specified on this Clang invocation with '-working-directory'. If so, it is crucial that we use this directory as an argument to the Clang scanner API. Otherwiswe, we risk having a mismatch between the working directory specified on the scanner's Clang invocation and the one use from the scanner API entry-points, which leads to downstream inconsistencies and errors.
• Scope of Issue: Scanner may crash or produce incorrect results when queried by the Swift scanner which decides on a working directory that may differ from that the built-in Clang is instantiated with.
• Origination: The scanner has been designed in this way from the beginning, this relevant check was simply missing. It was previously fixed for the main code-path of querying Clang dependencies, but not for the code-path of Bridging Header dependencies.
• Risk: Zero risk to implicit module builds, minimal risk to explicit module builds.

Resolves rdar://108464467

…ctory matches the invocation when querying bridging header dependencies

The Swift compiler does not have a concept of a working directory. It is instead handled by the Swift driver by resolving relative paths according to the driver's working directory argument. On the other hand, Clang does have a concept working directory which may be specified on this Clang invocation with '-working-directory'. If so, it is crucial that we use this directory as an argument to the Clang scanner API. Otherwiswe, we risk having a mismatch between the working directory specified on the scanner's Clang invocation and the one use from the scanner API entry-points, which leads to downstream inconsistencies and errors.

This was originally fixed for the main by-name module dependencies query in swiftlang#61025 (03136e0), but the Bridging Header dependencies code has continued to incorrectly expect the Swift ASTContext to both have the working directory set *and* be consistent with that of the Clang scanner instance.

Resolves rdar://108464467
@artemcm artemcm requested a review from nkcsgexi April 26, 2023 18:09
@artemcm artemcm requested a review from a team as a code owner April 26, 2023 18:09
@artemcm
Copy link
Contributor Author

artemcm commented Apr 26, 2023

@swift-ci test

@artemcm artemcm merged commit af7cb73 into swiftlang:release/5.9 Apr 27, 2023
@artemcm artemcm deleted the 59DepScanPCHWorkingDir branch April 27, 2023 14:29
@AnthonyLatsis AnthonyLatsis added the 🍒 release cherry pick Flag: Release branch cherry picks label May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants