Fix race condition in clang_macro_fallback #3111
Open
+43
−67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, bindgen by default used the same directory of the headers as the directory for temporary files of the
clang_macro_fallback
feature. Aside from its other problems like making temporary noises in git or failing to remove these files on failing or aborted builds, this caused a race condition in build of retina that I spend two DAYS to figure it out.The problem is, if you run bindgen on the same set of files multiple times simultaneously (which happened in retina since a crate was included two times in the crate graph due different features, and it ran bindgen in its build script) one of them can remove
clang_macro_fallback
files of the other one and break it.I fixed it by moving the files generated by
clang_macro_fallback
in a new temp directory each time bindgen is invoked.