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

Add support for Bazel 7 #795

Closed
7 tasks done
luispadron opened this issue Oct 27, 2023 · 16 comments · Fixed by #796 or #843
Closed
7 tasks done

Add support for Bazel 7 #795

luispadron opened this issue Oct 27, 2023 · 16 comments · Fixed by #796 or #843
Labels
enhancement New feature or request

Comments

@luispadron
Copy link
Collaborator

luispadron commented Oct 27, 2023

Bazel 7 is coming out soon (November 2023), building with USE_BAZEL_VERSION=last_rc we get the following error:

ERROR: /Users/lpadron/Development/rules_xcodeproj/examples/rules_ios/iOSApp/Source/BUILD:32:26: //iOSApp/Source:iOSApp: no such attribute 'output_discriminator' in 'ios_application' rule
ERROR: /Users/lpadron/Development/rules_xcodeproj/examples/rules_ios/iOSApp/Source/BUILD:32:26: errors encountered resolving select() keys for //iOSApp/Source:iOSApp

Tasks

  • output_discriminator is not a valid attr: fixed in Remove missing output_discriminator attribute usage #796
  • Remove apple_grte_top usage: bazelbuild/bazel@fb4106b
    • /Users/runner/work/rules_ios/rules_ios/rules/transition_support.bzl:125:36: transition inputs [//command_line_option:apple_compiler, //command_line_option:apple_grte_top] do not correspond to valid settings
  • Remove apple_compiler usage: bazelbuild/bazel@1acdfc4
    • /Users/runner/work/rules_ios/rules_ios/rules/transition_support.bzl:125:36: transition inputs [//command_line_option:apple_compiler, //command_line_option:apple_grte_top] do not correspond to valid settings
  • Add toolchains argument to rules
    • Error in fail: In order to use find_cpp_toolchain, you must include the '@bazel_tools//tools/cpp:toolchain_type' in the toolchains argument to your rule.
  • sysroot issues on CI
  • ld: Undefined symbols, we'll need to audit ObjcProvider for use in Bazel 7 given: incompatible_objc_linking_info_migration bazelbuild/bazel#17377
@mattrobmattrob
Copy link
Collaborator

Are you working on this actively, @luispadron?

@luispadron
Copy link
Collaborator Author

I was going to pick it up next week (if I wasn't too busy) but if you want to take it, I wouldn't mind at all!

@luispadron luispadron removed their assignment Oct 27, 2023
@mattrobmattrob
Copy link
Collaborator

I find it pretty bizarre that in rules_apple on the 3.1.1 tag, this doesn't work:

$ USE_BAZEL_VERSION=6.3.2 bazel build //examples/ios/HelloWorld
Starting local Bazel server and connecting to it...
ERROR: /Users/mattrobinson/Developer/github/bazelbuild/rules_apple/examples/ios/HelloWorld/BUILD:29:16: //examples/ios/HelloWorld:HelloWorld: no such attribute 'output_discriminator' in 'ios_application' rule
ERROR: Skipping '//examples/ios/HelloWorld': Error evaluating '//examples/ios/HelloWorld': error loading package 'examples/ios/HelloWorld': Package 'examples/ios/HelloWorld' contains errors
WARNING: Target pattern parsing failed.
ERROR: Error evaluating '//examples/ios/HelloWorld': error loading package 'examples/ios/HelloWorld': Package 'examples/ios/HelloWorld' contains errors
INFO: Elapsed time: 4.567s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)

With these changes:

diff --git a/.bazelrc b/.bazelrc
index 44e77dbe..9872ad12 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -1,3 +1,5 @@
+common --experimental_enable_bzlmod
+
 # NOTE: These are mainly just for the BazelCI setup so they don't have
 # to be repeated multiple times in .bazelci/presubmit.yml.

diff --git a/examples/ios/HelloWorld/BUILD b/examples/ios/HelloWorld/BUILD
index 10edbf0b..ce41f4a3 100644
--- a/examples/ios/HelloWorld/BUILD
+++ b/examples/ios/HelloWorld/BUILD
@@ -39,6 +39,7 @@ ios_application(
     minimum_os_version = "11.0",
     version = ":HelloWorldVersion",
     deps = [":Sources"],
+    output_discriminator = "",
 )

But maybe I'm missing something. Haven't been able to determine where that attribute is coming from WRT rules_ios on non-Bazel 7.

@luispadron
Copy link
Collaborator Author

Hm yah that is confusing, if it's failing in rules_apple with Bazel 6 I'd expect the same here since output_discriminator was added in the rules_apple 3 pr

@luispadron
Copy link
Collaborator Author

@mattrobmattrob fwiw output_discriminator usage in the rules_ios which is failing seems to be old and set to None like in app.bzl.

Should we just remove setting this to None?

@mattrobmattrob
Copy link
Collaborator

That was my initial (and current) thought, @luispadron. I was just trying to explain what had changed because it didn't really make all that much sense to me.

@luispadron
Copy link
Collaborator Author

Yeah I searched a lil yesterday and couldn't find where that attr was removed

@mattrobmattrob
Copy link
Collaborator

Ah, okay. Now I've got it! It seems like it's Bazel validating the input attributes better when they come directly from macros.

With these changes:

diff --git a/apple/versioning.bzl b/apple/versioning.bzl
index c65ae432..7d309f79 100644
--- a/apple/versioning.bzl
+++ b/apple/versioning.bzl
@@ -23,11 +23,15 @@ load(
     "AppleXPlatToolsToolchainInfo",
     "apple_toolchain_utils",
 )
+load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
 load(
     "@bazel_skylib//lib:dicts.bzl",
     "dicts",
 )

+def fake_ios_application(**kwargs):
+    ios_application(output_discriminator = None, **kwargs)
+
 def _collect_group_names(s):
     """Returns the list of placeholder names found in the given string.

diff --git a/examples/ios/HelloWorld/BUILD b/examples/ios/HelloWorld/BUILD
index 10edbf0b..dc05455d 100644
--- a/examples/ios/HelloWorld/BUILD
+++ b/examples/ios/HelloWorld/BUILD
@@ -4,6 +4,7 @@ load("//apple:xcarchive.bzl", "xcarchive")
 load(
     "//apple:versioning.bzl",
     "apple_bundle_version",
+    "fake_ios_application",
 )

 licenses(["notice"])
@@ -26,7 +27,7 @@ apple_bundle_version(
     build_version = "1.0",
 )

-ios_application(
+fake_ios_application(
     name = "HelloWorld",
     app_icons = ["//examples/resources:PhoneAppIcon.xcassets"],
     bundle_id = "com.example.hello-world",

Works on 6.3.2 and not on last_rc:

$ USE_BAZEL_VERSION=6.3.2 bazel build //examples/ios/HelloWorld
INFO: Analyzed target //examples/ios/HelloWorld:HelloWorld (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //examples/ios/HelloWorld:HelloWorld up-to-date:
  bazel-bin/examples/ios/HelloWorld/HelloWorld.ipa
INFO: Elapsed time: 0.089s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

$ USE_BAZEL_VERSION=last_rc bazel build //examples/ios/HelloWorld
Starting local Bazel server and connecting to it...
ERROR: /Users/mattrobinson/Developer/github/bazelbuild/rules_apple/examples/ios/HelloWorld/BUILD:30:21: //examples/ios/HelloWorld:HelloWorld: no such attribute 'output_discriminator' in 'ios_application' rule
WARNING: Target pattern parsing failed.
ERROR: Skipping '//examples/ios/HelloWorld': Error evaluating '//examples/ios/HelloWorld': error loading package 'examples/ios/HelloWorld': Package 'examples/ios/HelloWorld' contains errors
ERROR: Error evaluating '//examples/ios/HelloWorld': error loading package 'examples/ios/HelloWorld': Package 'examples/ios/HelloWorld' contains errors
INFO: Elapsed time: 3.681s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

mattrobmattrob added a commit that referenced this issue Oct 30, 2023
Fixes #795

Signed-off-by: Matt Robinson <mattrob@hey.com>
@mattrobmattrob mattrobmattrob self-assigned this Oct 30, 2023
mattrobmattrob added a commit that referenced this issue Oct 30, 2023
Fixes #795. Bazel 7 seems to validate the usage of non-defined attributes better than Bazel 6 and lower.

~Testing Bazel 7 in CI using #797 This gets us one step closer to being prepared for Bazel 7.

Signed-off-by: Matt Robinson <mattrob@hey.com>
@luispadron
Copy link
Collaborator Author

Updated to include the two issues we've found

@luispadron
Copy link
Collaborator Author

@mattrobmattrob Have you made any more progress here? Thanks again for working on this!

@mattrobmattrob
Copy link
Collaborator

@mattrobmattrob Have you made any more progress here? Thanks again for working on this!

Nope. I haven’t had time to investigate the oddity in platform SDK selection yet. All PRs should link to this issue though if you want to pick it up.

@mattrobmattrob
Copy link
Collaborator

The clang: error: using sysroot for 'iPhoneSimulator' but targeting 'MacOSX' [-Werror,-Wincompatible-sysroot] error that's occurring after that toolchain fix is discussed a bit in: https://bazelbuild.slack.com/archives/CD3QY5C2X/p1701890904270059

@mattrobmattrob mattrobmattrob removed their assignment Dec 14, 2023
@karim-alweheshy
Copy link
Contributor

USE_BAZEL_VERSION=7.0.0 bazel build //examples/ios/HelloWorld works fine on latest master rules_apple:f37305163dd7546f87839f3187e153c955cd20d8

@mattrobmattrob
Copy link
Collaborator

#797 is an example of the CI moved over to Bazel 7.0.0, @karim-alweheshy. It has some issues that'll need fixed as well if you want to look at the errors on CI.

@luispadron
Copy link
Collaborator Author

The current issue seems to be:

ld: Undefined symbols:
  _main, referenced from:
      <initial-undefines>

This is failing when running the following:

bazel build \
    --config=ios \
    --config=vfs \
    --ios_multi_cpus=sim_arm64 \
    -- \
    //tests/ios/... \
    -//tests/ios/unit-test/test-imports-app/...

This might be related to ObjcProvider changes made in: bazelbuild/bazel#17377

We'll likely need to audit and update our usage of ObjcProvider for Bazel 7 specifically.

@karim-alweheshy
Copy link
Contributor

@luispadron confirming your findings
The overall effort is described in more details here

More details here

luispadron pushed a commit that referenced this issue Mar 4, 2024
Add support for apple platform command line options.
Works towards #795
luispadron added a commit that referenced this issue Mar 4, 2024
Updates GitHub CI to make it easier to add more Bazel/Xcode Versions.

Changes:

- Update `checkout` and `upload-artifacts` actions to `v4`, this fixes
warnings we get on every PR for deprecated Node versions
- Add `matrix` strategy for all jobs, this adds a `bazel_version` and
`xcode_version` which each job will be configured to run against. We can
add Bazel 7 once #795 is done.
- Merge the `--config=vfs` and non-vfs job, this can be set with a
custom matrix without duplicating the job code.
- Remove `--remote-cache` flag, this was set by every job already.
luispadron added a commit that referenced this issue Apr 18, 2024
This PR adds 7.1.0 as a tested version in CI. It additionally updates
the README to specify the next release will officially support Bazel 7+

Depends on: 

- #848 
- #847
- #850 

Closes #795
nataliejameson pushed a commit to discord/rules_ios that referenced this issue Aug 13, 2024
Fixes bazel-ios/rules_ios#795. Bazel 7 seems to validate the usage of non-defined attributes better than Bazel 6 and lower.

~Testing Bazel 7 in CI using bazel-ios/rules_ios#797 This gets us one step closer to being prepared for Bazel 7.

Signed-off-by: Matt Robinson <mattrob@hey.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants