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

Update to bazel5 #385

Merged
merged 8 commits into from
Jan 10, 2022
Merged

Update to bazel5 #385

merged 8 commits into from
Jan 10, 2022

Conversation

amberdixon
Copy link
Collaborator

No description provided.

@amberdixon amberdixon changed the base branch from master to amber/minor-bazel5-tweaks December 17, 2021 18:51
@@ -971,7 +971,8 @@ def apple_library(name, library_tools = {}, export_private_headers = True, names
"@build_bazel_rules_ios//:virtualize_frameworks": framework_vfs_objc_copts,
"//conditions:default": framework_vfs_objc_copts if enable_framework_vfs else [],
})

if module_map:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We solve a problem with modulemaps by appending the module_map to the objc headers list. An alternative approach is here: 7f4fe87

However this approach may be preferable because bazel sees that modulemap is a dependency of the objc-library target.

Copy link
Collaborator Author

@amberdixon amberdixon Jan 6, 2022

Choose a reason for hiding this comment

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

For this change, we return module_map target from the apple_library macro, since the objc-provider in bazel5 no longer supports it. See bazelbuild/bazel@31bec27#diff-eb9c179576423931e9db781a5acff548a82a4361a23ce1c1dc0c6b73b30d114bL35

@@ -89,7 +89,7 @@ cc_toolchain_suite(
compiler = "compiler",
cpu = arch,
cxx_builtin_include_directories = [
"/Applications/",
"/",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a temporary change to workaround a problem here (bazelbuild/bazel#14346) with inclusion validation logic. We won't need this bazel5 toolchain stuff once we update to the next bazel5.0 release candidate. We need the following change (bazelbuild/bazel@005361c) which the bazel release team accidentally omitted from the rc3 cut. see bazelbuild/bazel#14440 (comment) as well.

The current bazel5 release candidate is rc3, which can be determined by checking the bazel-discuss email list: https://groups.google.com/g/bazel-discuss/

Copy link
Contributor

@jerrymarino jerrymarino left a comment

Choose a reason for hiding this comment

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

@amberdixon LGTM and great this is working. We should have a followup to ensure the M1 CPU is working natively: removing the hack that we needed to make it work under Bazel 4.

@@ -1 +1 @@
4.1.0
5.0.0rc3
Copy link
Contributor

Choose a reason for hiding this comment

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

Great that this is all working now!

@@ -279,6 +279,8 @@ def _get_framework_files(ctx, deps):
header_in.append(hdr)
destination = paths.join(framework_dir, "Headers", hdr.basename)
header_out.append(destination)
elif hdr.path.endswith(".modulemap") and hdr.owner != dep.label:
Copy link
Contributor

Choose a reason for hiding this comment

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

So we're guaranteed that the owner isn't going to be the dep? Would you mind dropping a comment about why this is so? If we make a dep of some modulemap rule is that going to work?

Copy link
Collaborator Author

@amberdixon amberdixon Jan 6, 2022

Choose a reason for hiding this comment

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

Thanks for catching this. The check for hdr.owner != dep.label is no longer necessary, so I will remove it.

This logic was introduced by https://github.com/bazel-ios/rules_ios/pull/180/files when traversing the direct_module_maps attribute. It seems that in bazel4, module_maps are sometimes generated by objc_library. In bazel5, we don't expect objc_library to be returning modulemaps in its providers, and the direct_headers won't be containing auto generated modulemaps!

  • remove filtering with hdr.owner != dep.label

@amberdixon amberdixon force-pushed the amber/bazel5-changes branch from 6490782 to 4aa0885 Compare January 6, 2022 02:28
@amberdixon amberdixon force-pushed the amber/minor-bazel5-tweaks branch from 2fba56d to 1dc8594 Compare January 6, 2022 18:34
@amberdixon amberdixon force-pushed the amber/bazel5-changes branch from 4aa0885 to 841fc01 Compare January 6, 2022 18:47
@amberdixon amberdixon changed the base branch from amber/minor-bazel5-tweaks to master January 6, 2022 20:42
@jerrymarino
Copy link
Contributor

@amberdixon are we able to merge this and the other other Bazel 5 fix? It looks like a problem with github actions - e.g. the check ran but it didn't ping back with status? https://github.com/bazel-ios/rules_ios/actions/runs/1664400771

@jerrymarino jerrymarino enabled auto-merge (squash) January 10, 2022 21:58
@jerrymarino jerrymarino disabled auto-merge January 10, 2022 21:58
@jerrymarino jerrymarino merged commit 99b51ab into master Jan 10, 2022
@jerrymarino jerrymarino deleted the amber/bazel5-changes branch January 10, 2022 21:59
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