Skip to content

Commit 9010e02

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. To make the repo compatible with bazelisk out of the box, a bazelversion file has been added. FUTURE_COPYBARA_INTEGRATE_REVIEW=#11935 from konstantin-s-bogom:master 7e936f4 PiperOrigin-RevId: 794312865
1 parent 14f317c commit 9010e02

File tree

16 files changed

+1896
-95
lines changed

16 files changed

+1896
-95
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

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.3.1

WORKSPACE

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ http_archive(
6565
# Export .x files.
6666
"//tools:rules_go_export.patch",
6767
],
68-
sha256 = "af47f30e9cbd70ae34e49866e201b3f77069abb111183f2c0297e7e74ba6bbc0",
68+
sha256 = "9d72f7b8904128afb98d46bbef82ad7223ec9ff3718d419afb355fddd9f9484a",
6969
urls = [
70-
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
71-
"https://github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
70+
"https://mirror.bazel.build/github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.1.zip",
71+
"https://github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.1.zip",
7272
],
7373
)
7474

@@ -89,12 +89,32 @@ switched_rules_by_language(
8989
go = False, # Disable building proto Go libraries; use org_golang_google_genproto instead.
9090
)
9191

92+
# rules_python needed by bazel_gazelle
93+
http_archive(
94+
name = "rules_python",
95+
sha256 = "fa532d635f29c038a64c8062724af700c30cf6b31174dd4fac120bc561a1a560",
96+
strip_prefix = "rules_python-1.5.1",
97+
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.5.1/rules_python-1.5.1.tar.gz",
98+
)
99+
100+
load("@rules_python//python:repositories.bzl", "py_repositories")
101+
102+
py_repositories()
103+
104+
# Load C++ rules. Needs to come early because something else pulls in an older
105+
# version of rules_cc which is incompatible with Bazel 8.
106+
http_archive(
107+
name = "rules_cc",
108+
sha256 = "0d3b4f984c4c2e1acfd1378e0148d35caf2ef1d9eb95b688f8e19ce0c41bdf5b",
109+
strip_prefix = "rules_cc-0.1.4",
110+
url = "https://github.com/bazelbuild/rules_cc/releases/download/0.1.4/rules_cc-0.1.4.tar.gz",
111+
)
112+
92113
http_archive(
93114
name = "bazel_gazelle",
94-
sha256 = "32938bda16e6700063035479063d9d24c60eda8d79fd4739563f50d331cb3209",
115+
sha256 = "49b14c691ceec841f445f8642d28336e99457d1db162092fd5082351ea302f1d",
95116
urls = [
96-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
97-
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
117+
"https://github.com/bazel-contrib/bazel-gazelle/releases/download/v0.44.0/bazel-gazelle-v0.44.0.tar.gz"
98118
],
99119
)
100120

@@ -386,19 +406,14 @@ go_repository(
386406
version = "v1.67.1",
387407
)
388408

389-
# Load C++ rules.
390-
http_archive(
391-
name = "rules_cc",
392-
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
393-
strip_prefix = "rules_cc-0.0.17",
394-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
395-
)
396-
397-
# Load C++ cross-compilation toolchains.
409+
# # Load C++ cross-compilation toolchains.
398410
http_archive(
399411
name = "coral_crosstool",
400412
patch_args = ["-p1"],
401-
patches = ["//tools:crosstool-arm-dirs.patch"],
413+
patches = [
414+
"//tools:crosstool-arm-dirs.patch",
415+
"//tools:remove_windows_deps.patch",
416+
],
402417
sha256 = "f86d488ca353c5ee99187579fe408adb73e9f2bb1d69c6e3a42ffb904ce3ba01",
403418
strip_prefix = "crosstool-8e885509123395299bed6a5f9529fdc1b9751599",
404419
urls = [
@@ -429,9 +444,9 @@ http_archive(
429444
)
430445

431446
# Load LLVM dependencies.
432-
LLVM_COMMIT = "926f85db98aae66ab8f57b9981f47ddddb868c51"
447+
LLVM_COMMIT = "cbcb48a88c3a6227cfc09f91880d5cb92a26f5f9"
433448

434-
LLVM_SHA256 = "c78c94b2a03b2cf6ef1ba035c31a6f1b0bb7913da8af5aa8d5c2061f6499d589"
449+
LLVM_SHA256 = "356cb88e5975104628494bd02b8edef1889ea30a7dbe96b5abe6ad74ed8ba74b"
435450

436451
http_archive(
437452
name = "llvm-raw",
@@ -479,6 +494,15 @@ http_archive(
479494
],
480495
)
481496

497+
# rules_java needed for rules_proto and grpc both.
498+
http_archive(
499+
name = "rules_java",
500+
urls = [
501+
"https://github.com/bazelbuild/rules_java/releases/download/8.6.2/rules_java-8.6.2.tar.gz",
502+
],
503+
sha256 = "a64ab04616e76a448c2c2d8165d836f0d2fb0906200d0b7c7376f46dd62e59cc",
504+
)
505+
482506
http_archive(
483507
name = "com_google_protobuf",
484508
sha256 = "e7a50ac2a8ae3754c6f1ab6123424627920e4abddd894ee4bc47d6506e86aeb9",
@@ -1759,10 +1783,6 @@ go_repository(
17591783
version = "v56.0.0",
17601784
)
17611785

1762-
rules_proto_dependencies()
1763-
1764-
rules_proto_toolchains()
1765-
17661786
http_archive(
17671787
name = "rules_pkg",
17681788
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/bazeldefs/go.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def go_context(ctx, goos = None, goarch = None, std = False):
173173
goos = goos,
174174
gotags = go_ctx.tags,
175175
nogo_args = [],
176-
runfiles = depset([go_ctx.go] + go_ctx.sdk.srcs + go_ctx.sdk.tools + go_ctx.stdlib.libs),
176+
runfiles = depset([go_ctx.go] + go_ctx.sdk.srcs.to_list() + go_ctx.sdk.tools.to_list() + go_ctx.stdlib.libs.to_list()),
177177
stdlib_srcs = go_ctx.sdk.srcs,
178178
)
179179

tools/bigquery/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ go_library(
1414
"//:sandbox",
1515
],
1616
deps = [
17-
"@com_google_cloud_go//bigquery:go_default_library",
17+
"@com_google_cloud_go_bigquery//:go_default_library",
1818
"@org_golang_google_api//option:go_default_library",
1919
"@org_golang_x_oauth2//:go_default_library",
2020
],

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
}

tools/nogo/defs.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ def _nogo_stdlib_impl(ctx):
7070
# Build the analyzer command.
7171
facts_file = ctx.actions.declare_file(ctx.label.name + ".facts")
7272
findings_file = ctx.actions.declare_file(ctx.label.name + ".raw_findings")
73+
stdlib_srcs = go_ctx.stdlib_srcs if type(go_ctx.stdlib_srcs) == "list" else go_ctx.stdlib_srcs.to_list()
7374
ctx.actions.run(
7475
# For the standard library, we need to include the full set of Go
7576
# sources in the inputs.
76-
inputs = inputs + go_ctx.stdlib_srcs,
77+
inputs = inputs + stdlib_srcs,
7778
outputs = [facts_file, findings_file],
7879
tools = depset(go_ctx.runfiles.to_list() + ctx.files._nogo),
7980
executable = ctx.files._nogo[0],
@@ -90,7 +91,7 @@ def _nogo_stdlib_impl(ctx):
9091
"-findings=%s" % findings_file.path,
9192
"-facts=%s" % facts_file.path,
9293
"-root=.*?/src/",
93-
] + [f.path for f in go_ctx.stdlib_srcs],
94+
] + [f.path for f in stdlib_srcs],
9495
toolchain = None,
9596
)
9697

0 commit comments

Comments
 (0)