Skip to content

[clang][DependencyFile] Use atomic write for dependency file #10902

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
Jun 26, 2025

Conversation

cachemeifyoucan
Copy link

@cachemeifyoucan cachemeifyoucan commented Jun 26, 2025

Previously when switch to output backend, dependency file was relying on non-atomic write + discard to remove the out of date dependency file when there are missing headers. The reliance on non-atomic write can cause races conditions that build system is trying to read the file while the file is being updated by a different compiler instance.

rdar://154128578

Previously when switch to output backend, dependency file was relying
on non-atomic write + discard to remove the out of date dependency file
when there are missing headers. This makes the write non-atomic and can
cause races conditions that build system is trying to read the file
while the file is being updated by a different compiler instance.

rdar://154128578
@cachemeifyoucan
Copy link
Author

@swift-ci please test llvm

Copy link

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

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

LGTM. To clarify, the output backend commit didn't change this behaviour, it was always non-atomic before too. Caching just makes it more likely we will have a module context hash that matches another compilation due to the canonicalizations we perform.

@cachemeifyoucan
Copy link
Author

LGTM. To clarify, the output backend commit didn't change this behaviour, it was always non-atomic before too. Caching just makes it more likely we will have a module context hash that matches another compilation due to the canonicalizations we perform.

Message is updated.

@cachemeifyoucan cachemeifyoucan merged commit bfedc53 into swiftlang:next Jun 26, 2025
2 checks passed
cachemeifyoucan added a commit to cachemeifyoucan/llvm-project that referenced this pull request Jun 26, 2025
…ng#10902)

Previously when switch to output backend, dependency file was relying
on non-atomic write + discard to remove the out of date dependency file
when there are missing headers. The reliance on non-atomic write can
cause race conditions that build system is trying to read the file while the
file is being updated by a different compiler instance.

rdar://154128578
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