Skip to content

Upgrade to Bazel 8 #78

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 16 commits into from
Feb 27, 2025
Merged

Upgrade to Bazel 8 #78

merged 16 commits into from
Feb 27, 2025

Conversation

jadenPete
Copy link

This PR upgrades the ruleset to Bazel 8. It should also make the upgrade to future Bazel versions easier by enabling a number of --incompatible_* flags. These enforce that we're not using deprecated features that will be removed in a future major Bazel version.

Note that I wasn't able to enable path mapping because the same bug that prevented us from enabling it with Bazel 7 seems to be pervasive in Bazel 8 as well. I'll look into that soon; I just wanted to get us upgraded first.

@jadenPete jadenPete requested a review from jjudd January 17, 2025 21:52
@jadenPete jadenPete self-assigned this Jan 17, 2025
Copy link

@jjudd jjudd left a comment

Choose a reason for hiding this comment

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

This LGTM for the most part. I had a question or two, but nothing major.

Thanks for doing this!

.bazelrc_shared Outdated
common --incompatible_strict_action_env

# Unfortunately, this can't be enabled just yet because of
# https://github.com/bazelbuild/rules_java/issues/264
Copy link

Choose a reason for hiding this comment

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

Reading through that issue it looks like this was fixed and we should be able to flip this now.

Copy link
Author

Choose a reason for hiding this comment

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

Yup, I think it got resolved. Let me try re-enabling it.

Copy link
Author

Choose a reason for hiding this comment

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

Unfortunately, we're still getting this error, despite CcInfo being imported:

ERROR: Traceback (most recent call last):
	File "/home/jpeterson/.cache/bazel/_bazel_jpeterson/b85aa227a3460f0c7b51d6bd8d9136a3/external/rules_java+/java/common/rules/java_runtime.bzl", line 197, column 48, in <toplevel>
		"hermetic_static_libs": attr.label_list(
Error in label_list: Illegal argument: element in 'providers' is of unexpected type. Either all elements should be providers, or all elements should be lists of providers, but got an element of type com.google.devtools.build.lib.starlarkbuildapi.core.ContextAndFlagGuardedValue$1.

I'll have to keep it disabled for now. I'll update the comment, though.

.bazelversion Outdated
@@ -1 +1 @@
7.4.1
8.0.0
Copy link

Choose a reason for hiding this comment

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

It took me so long to review this that 8.1.0 is out, so I think we could upgrade to that.

Copy link
Author

Choose a reason for hiding this comment

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

Will do.

MODULE.bazel Outdated

bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True)

bazel_dep(name = "protobuf", version = "29.3")
bazel_dep(name = "rules_java", version = "7.12.2")
Copy link

Choose a reason for hiding this comment

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

Any advantage to upgrading rules_java to the 8.x versions now that we're on Bazel 8? 8.9.0 is the latest version.

Copy link
Author

Choose a reason for hiding this comment

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

Yup, I upgraded to v8.9.0 in my other fixup! commit 🙂

providers = g.out.providers,
**dynamic
)
return g.out.providers
Copy link

Choose a reason for hiding this comment

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

Are these equivalent? I'm having a hard time following the diff here.

Copy link
Author

Choose a reason for hiding this comment

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

I believe so. Now that struct-provider syntax is disabled, I had to refactor this. Since I wasn't able to find anywhere where instrumented_files or java are used (and all the tests passed without them), I opted to remove them.

),
replacements = replacements,
)
return struct(replacements = replacements)
Copy link

Choose a reason for hiding this comment

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

Do we no longer need instrumented_files?

Copy link
Author

Choose a reason for hiding this comment

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

See my comment here. This was only used in phase_coda, but I removed that reference to it. Therefore, it was no longer needed.

@@ -1 +1 @@
7.4.1
8.0.0
Copy link

Choose a reason for hiding this comment

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

Same though there about upgrading to 8.1.0

Copy link
Author

Choose a reason for hiding this comment

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

Done!

.bazelrc_shared Outdated
# Other options
build --experimental_use_hermetic_linux_sandbox
build --experimental_worker_cancellation
build --experimental_worker_multiplex_sandboxing
Copy link

Choose a reason for hiding this comment

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

Looks like the CI build is failing because of the multiplex sandboxing bug. Which suggests that bug is either a bug in our rule set or still present in Bazel 8. We'll want to disable this for now.

Copy link
Author

Choose a reason for hiding this comment

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

Yup, I'll re-disable this.

@jjudd
Copy link

jjudd commented Feb 20, 2025

I implemented several of the changes I requested here, fixed a bug, and updated CI to be on Bazel 8. You can just cherry-pick my commits from this branch as it should save you some time https://github.com/lucidsoftware/rules_scala/pull/81/commits

Jaden Peterson added 5 commits February 27, 2025 11:16
Bazel 8 deprecates the rulesets bundled with Bazel (which includes the
Protobuf rules) in favor of their Starlark-ified equivalents. For that
reason, we switch to the `protobuf` ruleset for `proto_library` and
`java_proto_library`.

In doing so, we can't use `com.github.os72:protoc-jar` because the
version of protoc it bundles is extremely out of date and incompatible
with the version of protobuf provided by the Starlark-ified protobuf
ruleset. In its place, we use the protoc provided by that ruleset.
@jadenPete
Copy link
Author

Squashed.

@jadenPete
Copy link
Author

Squashed.

@jadenPete
Copy link
Author

Squashed.

@jadenPete jadenPete merged commit cb5c268 into lucid-master Feb 27, 2025
1 check passed
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