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

Ensures the determinism of vfsoverlay file #912

Merged
merged 1 commit into from
Sep 6, 2024
Merged

Conversation

congt
Copy link
Contributor

@congt congt commented Sep 6, 2024

hdrs, private_hdrs and swiftmodules of the same framework may be in different order when building with different build settings in Bazel 7. This change will ensure that the vfsoverlay file will be always the same for the same dependency graph.

hdrs, private_hdrs and swiftmodules of the same framework may be in different order when building with different build settings in Bazel 7. This change will ensure that the vfsoverlay file will be always the same for the same dependency graph.
Copy link
Contributor

@thiagohmcruz thiagohmcruz left a comment

Choose a reason for hiding this comment

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

LGTM, just one comment on perf.

@@ -376,6 +376,12 @@ def make_vfsoverlay(ctx, hdrs, module_map, private_hdrs, has_swift, swiftmodules
vfs_parent_len = len(vfs_parent.split("/")) - 1
vfs_prefix = _make_relative_prefix(vfs_parent_len)

# Ensures the determinism of vfsoverlay file
# hdrs, private_hdrs and swiftmodules of the same framework may be in different order.
hdrs = sorted(hdrs)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest to verify that these sort steps don't introduce a significant performance regression in the analysis phase.

Copy link
Contributor Author

@congt congt Sep 6, 2024

Choose a reason for hiding this comment

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

The overhead should be fine. apple_library has already sorted all srcs files. The number of hdrs, private_hdrs and swiftmodules is smaller than that of srcs, especially for swift modules.

Copy link
Contributor

@gyfelton gyfelton Sep 6, 2024

Choose a reason for hiding this comment

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

I wonder what kind of CI test can red green on this... sandbox mode only ensure all inputs that should be present are present in the inputs list, but nothing about ensuring no change on file content when a rebuild happens

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe start with adding before after in the PR desc? I am sure we can figure some CI test out in future based on the repro

@congt congt merged commit cf60105 into master Sep 6, 2024
23 checks passed
@congt congt deleted the cshi/hermetic-vsfoverlay branch September 6, 2024 15:40
congt added a commit that referenced this pull request Sep 9, 2024
hdrs, private_hdrs and swiftmodules of the same framework may be in
different order when building with different build settings in Bazel 7.
This change will ensure that the vfsoverlay file will be always the same
for the same dependency graph.
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