Skip to content

Commit 24a94ba

Browse files
konstantin-s-bogomgvisor-bot
authored andcommitted
Fix build for Bazel 8.
Specifically, build using bazel WORKSPACE. Bazel modules is still not used and requires further migration. This updates some dependencies to make them compatible with Bazel 8, which in turn requires explicitly adding some new dependencies to support new versions. In some cases existing patches no longer applied and had to be updated. A new patch was added to remove windows toolchains from coral-crosstools, because that functionality requires lots of bazel intrinsics that are no longer defined. At least on my machine, when //vdso:vdso was a dependency (not targetted explicitly), the Gold linker specified in `vdso_linker_option` failed to be found (bazel build //vdso worked); however this led me to discover that the Gold linker is deprecated, hence using it is removed entirely. FUTURE_COPYBARA_INTEGRATE_REVIEW=#11935 from konstantin-s-bogom:master 9bb4afd PiperOrigin-RevId: 784288186
1 parent d7830d9 commit 24a94ba

File tree

12 files changed

+1858
-84
lines changed

12 files changed

+1858
-84
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ build:aarch64 --cpu=aarch64
4747
build:aarch64 --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64
4848

4949
common --noenable_bzlmod
50+
common --enable_workspace

WORKSPACE

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ http_archive(
5555
# Export .x files.
5656
"//tools:rules_go_export.patch",
5757
],
58-
sha256 = "af47f30e9cbd70ae34e49866e201b3f77069abb111183f2c0297e7e74ba6bbc0",
58+
sha256 = "9d72f7b8904128afb98d46bbef82ad7223ec9ff3718d419afb355fddd9f9484a",
5959
urls = [
60-
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
61-
"https://github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
60+
"https://mirror.bazel.build/github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.1.zip",
61+
"https://github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.1.zip",
6262
],
6363
)
6464

@@ -79,12 +79,23 @@ switched_rules_by_language(
7979
go = False, # Disable building proto Go libraries; use org_golang_google_genproto instead.
8080
)
8181

82+
# rules_python needed by bazel_gazelle
83+
http_archive(
84+
name = "rules_python",
85+
sha256 = "fa532d635f29c038a64c8062724af700c30cf6b31174dd4fac120bc561a1a560",
86+
strip_prefix = "rules_python-1.5.1",
87+
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.5.1/rules_python-1.5.1.tar.gz",
88+
)
89+
90+
load("@rules_python//python:repositories.bzl", "py_repositories")
91+
92+
py_repositories()
93+
8294
http_archive(
8395
name = "bazel_gazelle",
84-
sha256 = "32938bda16e6700063035479063d9d24c60eda8d79fd4739563f50d331cb3209",
96+
sha256 = "49b14c691ceec841f445f8642d28336e99457d1db162092fd5082351ea302f1d",
8597
urls = [
86-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
87-
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
98+
"https://github.com/bazel-contrib/bazel-gazelle/releases/download/v0.44.0/bazel-gazelle-v0.44.0.tar.gz"
8899
],
89100
)
90101

@@ -379,16 +390,19 @@ go_repository(
379390
# Load C++ rules.
380391
http_archive(
381392
name = "rules_cc",
382-
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
383-
strip_prefix = "rules_cc-0.0.17",
384-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
393+
sha256 = "64cb81641305dcf7b3b3d5a73095ee8fe7444b26f7b72a12227d36e15cfbb6cb",
394+
strip_prefix = "rules_cc-0.1.3",
395+
url = "https://github.com/bazelbuild/rules_cc/releases/download/0.1.3/rules_cc-0.1.3.tar.gz",
385396
)
386397

387-
# Load C++ cross-compilation toolchains.
398+
# # Load C++ cross-compilation toolchains.
388399
http_archive(
389400
name = "coral_crosstool",
390401
patch_args = ["-p1"],
391-
patches = ["//tools:crosstool-arm-dirs.patch"],
402+
patches = [
403+
"//tools:crosstool-arm-dirs.patch",
404+
"//tools:remove_windows_deps.patch",
405+
],
392406
sha256 = "f86d488ca353c5ee99187579fe408adb73e9f2bb1d69c6e3a42ffb904ce3ba01",
393407
strip_prefix = "crosstool-8e885509123395299bed6a5f9529fdc1b9751599",
394408
urls = [
@@ -469,6 +483,15 @@ http_archive(
469483
],
470484
)
471485

486+
# rules_java needed for rules_proto and grpc both.
487+
http_archive(
488+
name = "rules_java",
489+
urls = [
490+
"https://github.com/bazelbuild/rules_java/releases/download/8.6.2/rules_java-8.6.2.tar.gz",
491+
],
492+
sha256 = "a64ab04616e76a448c2c2d8165d836f0d2fb0906200d0b7c7376f46dd62e59cc",
493+
)
494+
472495
http_archive(
473496
name = "com_google_protobuf",
474497
sha256 = "e7a50ac2a8ae3754c6f1ab6123424627920e4abddd894ee4bc47d6506e86aeb9",
@@ -1749,10 +1772,6 @@ go_repository(
17491772
version = "v56.0.0",
17501773
)
17511774

1752-
rules_proto_dependencies()
1753-
1754-
rules_proto_toolchains()
1755-
17561775
http_archive(
17571776
name = "rules_pkg",
17581777
sha256 = "62eeb544ff1ef41d786e329e1536c1d541bb9bcad27ae984d57f18f314018e66",

images/default/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ RUN curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud
3030
ln -s /google-cloud-sdk/bin/gcloud /usr/bin/gcloud
3131

3232
# Download the official bazel binary. The APT repository isn't used because there is not packages for arm64.
33-
RUN sh -c 'curl -o /usr/local/bin/bazel https://releases.bazel.build/7.5.0/release/bazel-7.5.0-linux-$(uname -m | sed s/aarch64/arm64/) && chmod ugo+x /usr/local/bin/bazel'
33+
RUN sh -c 'curl -o /usr/local/bin/bazel https://releases.bazel.build/8.3.1/release/bazel-8.3.1-linux-$(uname -m | sed s/aarch64/arm64/) && chmod ugo+x /usr/local/bin/bazel'
3434
WORKDIR /workspace
3535
ENTRYPOINT ["/usr/local/bin/bazel"]

tools/bazeldefs/cc.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""C++ rules."""
22

33
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", _cc_grpc_library = "cc_grpc_library")
4-
load("@rules_cc//cc:defs.bzl", _cc_binary = "cc_binary", _cc_library = "cc_library", _cc_proto_library = "cc_proto_library", _cc_test = "cc_test")
4+
load("@com_google_protobuf//bazel:cc_proto_library.bzl", _cc_proto_library = "cc_proto_library")
5+
load("@rules_cc//cc:defs.bzl", _cc_binary = "cc_binary", _cc_library = "cc_library", _cc_test = "cc_test")
56

67
cc_library = _cc_library
78
cc_proto_library = _cc_proto_library
@@ -11,7 +12,6 @@ gtest = "@com_google_googletest//:gtest"
1112
gbenchmark = "@com_google_benchmark//:benchmark"
1213
gbenchmark_internal = "@com_google_benchmark//:benchmark"
1314
grpcpp = "@com_github_grpc_grpc//:grpc++"
14-
vdso_linker_option = "-fuse-ld=gold "
1515

1616
def _cc_flags_supplier_impl(ctx):
1717
variables = platform_common.TemplateVariableInfo({

tools/defs.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ automagically creating cc_ and go_ proto targets) and act as a single point of
55
change for Google-internal and bazel-compatible rules.
66
"""
77

8-
load("//tools/bazeldefs:cc.bzl", _cc_binary = "cc_binary", _cc_flags_supplier = "cc_flags_supplier", _cc_grpc_library = "cc_grpc_library", _cc_library = "cc_library", _cc_proto_library = "cc_proto_library", _cc_test = "cc_test", _cc_toolchain = "cc_toolchain", _gbenchmark = "gbenchmark", _gbenchmark_internal = "gbenchmark_internal", _grpcpp = "grpcpp", _gtest = "gtest", _select_gtest = "select_gtest", _vdso_linker_option = "vdso_linker_option")
8+
load("//tools/bazeldefs:cc.bzl", _cc_binary = "cc_binary", _cc_flags_supplier = "cc_flags_supplier", _cc_grpc_library = "cc_grpc_library", _cc_library = "cc_library", _cc_proto_library = "cc_proto_library", _cc_test = "cc_test", _cc_toolchain = "cc_toolchain", _gbenchmark = "gbenchmark", _gbenchmark_internal = "gbenchmark_internal", _grpcpp = "grpcpp", _gtest = "gtest", _select_gtest = "select_gtest")
99
load("//tools/bazeldefs:defs.bzl", _BuildSettingInfo = "BuildSettingInfo", _bool_flag = "bool_flag", _bpf_program = "bpf_program", _build_test = "build_test", _bzl_library = "bzl_library", _coreutil = "coreutil", _default_net_util = "default_net_util", _more_shards = "more_shards", _most_shards = "most_shards", _proto_library = "proto_library", _select_system = "select_system", _short_path = "short_path", _version = "version")
1010
load("//tools/bazeldefs:go.bzl", _gazelle = "gazelle", _go_binary = "go_binary", _go_grpc_and_proto_libraries = "go_grpc_and_proto_libraries", _go_library = "go_library", _go_path = "go_path", _go_proto_library = "go_proto_library", _go_test = "go_test", _gotsan_flag_values = "gotsan_flag_values", _gotsan_values = "gotsan_values", _select_goarch = "select_goarch", _select_goos = "select_goos")
1111
load("//tools/bazeldefs:pkg.bzl", _pkg_deb = "pkg_deb", _pkg_tar = "pkg_tar")
@@ -39,7 +39,6 @@ gbenchmark = _gbenchmark
3939
gbenchmark_internal = _gbenchmark_internal
4040
gtest = _gtest
4141
grpcpp = _grpcpp
42-
vdso_linker_option = _vdso_linker_option
4342
select_gtest = _select_gtest
4443

4544
# Go rules.

tools/go_types_memoize.patch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
diff --git a/src/go/types/scope.go b/src/go/types/scope.go
2-
index 010727eb72..0f134b872e 100644
2+
index e3fb7b6eff..683f844b42 100644
33
--- a/src/go/types/scope.go
44
+++ b/src/go/types/scope.go
5-
@@ -25,6 +25,7 @@ type Scope struct {
5+
@@ -27,6 +27,7 @@ type Scope struct {
66
children []*Scope
77
number int // parent.children[number-1] is this scope; 0 if there is no parent
88
elems map[string]Object // lazily allocated
99
+ sorted []string // lazily allocated
1010
pos, end token.Pos // scope extent; may be invalid
1111
comment string // for debugging only
1212
isFunc bool // set if this is a function scope (internal use only)
13-
@@ -33,7 +34,7 @@ type Scope struct {
13+
@@ -35,7 +36,7 @@ type Scope struct {
1414
// NewScope returns a new, empty scope contained in the given parent
1515
// scope, if any. The comment is for debugging only.
1616
func NewScope(parent *Scope, pos, end token.Pos, comment string) *Scope {
@@ -19,7 +19,7 @@ index 010727eb72..0f134b872e 100644
1919
// don't add children to Universe scope!
2020
if parent != nil && parent != Universe {
2121
parent.children = append(parent.children, s)
22-
@@ -50,14 +51,16 @@ func (s *Scope) Len() int { return len(s.elems) }
22+
@@ -52,14 +53,16 @@ func (s *Scope) Len() int { return len(s.elems) }
2323

2424
// Names returns the scope's element names in sorted order.
2525
func (s *Scope) Names() []string {
@@ -35,9 +35,9 @@ index 010727eb72..0f134b872e 100644
3535
+ s.sorted[i] = name
3636
+ i++
3737
+ }
38-
+ sort.Strings(s.sorted)
38+
+ slices.Sort(s.sorted)
3939
}
40-
- sort.Strings(names)
40+
- slices.Sort(names)
4141
- return names
4242
+ return s.sorted
4343
}

0 commit comments

Comments
 (0)