Merge pull request #11935 from konstantin-s-bogom:master

PiperOrigin-RevId: 797465169
This commit is contained in:
gVisor bot
2025-08-20 14:31:33 -07:00
17 changed files with 1898 additions and 95 deletions
+1
View File
@@ -47,3 +47,4 @@ build:aarch64 --cpu=aarch64
build:aarch64 --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64
common --noenable_bzlmod
common --enable_workspace
+1
View File
@@ -0,0 +1 @@
images/default/bazelversion
+42 -22
View File
@@ -65,10 +65,10 @@ http_archive(
# Export .x files.
"//tools:rules_go_export.patch",
],
sha256 = "af47f30e9cbd70ae34e49866e201b3f77069abb111183f2c0297e7e74ba6bbc0",
sha256 = "9d72f7b8904128afb98d46bbef82ad7223ec9ff3718d419afb355fddd9f9484a",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
"https://mirror.bazel.build/github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.1.zip",
"https://github.com/bazel-contrib/rules_go/releases/download/v0.55.1/rules_go-v0.55.1.zip",
],
)
@@ -89,12 +89,32 @@ switched_rules_by_language(
go = False, # Disable building proto Go libraries; use org_golang_google_genproto instead.
)
# rules_python needed by bazel_gazelle
http_archive(
name = "rules_python",
sha256 = "fa532d635f29c038a64c8062724af700c30cf6b31174dd4fac120bc561a1a560",
strip_prefix = "rules_python-1.5.1",
url = "https://github.com/bazel-contrib/rules_python/releases/download/1.5.1/rules_python-1.5.1.tar.gz",
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()
# Load C++ rules. Needs to come early because something else pulls in an older
# version of rules_cc which is incompatible with Bazel 8.
http_archive(
name = "rules_cc",
sha256 = "0d3b4f984c4c2e1acfd1378e0148d35caf2ef1d9eb95b688f8e19ce0c41bdf5b",
strip_prefix = "rules_cc-0.1.4",
url = "https://github.com/bazelbuild/rules_cc/releases/download/0.1.4/rules_cc-0.1.4.tar.gz",
)
http_archive(
name = "bazel_gazelle",
sha256 = "32938bda16e6700063035479063d9d24c60eda8d79fd4739563f50d331cb3209",
sha256 = "49b14c691ceec841f445f8642d28336e99457d1db162092fd5082351ea302f1d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
"https://github.com/bazel-contrib/bazel-gazelle/releases/download/v0.44.0/bazel-gazelle-v0.44.0.tar.gz"
],
)
@@ -386,19 +406,14 @@ go_repository(
version = "v1.67.1",
)
# Load C++ rules.
http_archive(
name = "rules_cc",
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
strip_prefix = "rules_cc-0.0.17",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
)
# Load C++ cross-compilation toolchains.
# # Load C++ cross-compilation toolchains.
http_archive(
name = "coral_crosstool",
patch_args = ["-p1"],
patches = ["//tools:crosstool-arm-dirs.patch"],
patches = [
"//tools:crosstool-arm-dirs.patch",
"//tools:remove_windows_deps.patch",
],
sha256 = "f86d488ca353c5ee99187579fe408adb73e9f2bb1d69c6e3a42ffb904ce3ba01",
strip_prefix = "crosstool-8e885509123395299bed6a5f9529fdc1b9751599",
urls = [
@@ -429,9 +444,9 @@ http_archive(
)
# Load LLVM dependencies.
LLVM_COMMIT = "926f85db98aae66ab8f57b9981f47ddddb868c51"
LLVM_COMMIT = "cbcb48a88c3a6227cfc09f91880d5cb92a26f5f9"
LLVM_SHA256 = "c78c94b2a03b2cf6ef1ba035c31a6f1b0bb7913da8af5aa8d5c2061f6499d589"
LLVM_SHA256 = "356cb88e5975104628494bd02b8edef1889ea30a7dbe96b5abe6ad74ed8ba74b"
http_archive(
name = "llvm-raw",
@@ -479,6 +494,15 @@ http_archive(
],
)
# rules_java needed for rules_proto and grpc both.
http_archive(
name = "rules_java",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/8.6.2/rules_java-8.6.2.tar.gz",
],
sha256 = "a64ab04616e76a448c2c2d8165d836f0d2fb0906200d0b7c7376f46dd62e59cc",
)
http_archive(
name = "com_google_protobuf",
sha256 = "e7a50ac2a8ae3754c6f1ab6123424627920e4abddd894ee4bc47d6506e86aeb9",
@@ -1759,10 +1783,6 @@ go_repository(
version = "v56.0.0",
)
rules_proto_dependencies()
rules_proto_toolchains()
http_archive(
name = "rules_pkg",
sha256 = "62eeb544ff1ef41d786e329e1536c1d541bb9bcad27ae984d57f18f314018e66",
+2 -1
View File
@@ -30,6 +30,7 @@ RUN curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud
ln -s /google-cloud-sdk/bin/gcloud /usr/bin/gcloud
# Download the official bazel binary. The APT repository isn't used because there is not packages for arm64.
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'
COPY bazelversion .
RUN sh -c 'curl -o /usr/local/bin/bazel https://releases.bazel.build/$(cat ./bazelversion)/release/bazel-$(cat ./bazelversion)-linux-$(uname -m | sed s/aarch64/arm64/) && chmod ugo+x /usr/local/bin/bazel'
WORKDIR /workspace
ENTRYPOINT ["/usr/local/bin/bazel"]
+1
View File
@@ -0,0 +1 @@
8.3.1
+2 -2
View File
@@ -1,7 +1,8 @@
"""C++ rules."""
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", _cc_grpc_library = "cc_grpc_library")
load("@rules_cc//cc:defs.bzl", _cc_binary = "cc_binary", _cc_library = "cc_library", _cc_proto_library = "cc_proto_library", _cc_test = "cc_test")
load("@com_google_protobuf//bazel:cc_proto_library.bzl", _cc_proto_library = "cc_proto_library")
load("@rules_cc//cc:defs.bzl", _cc_binary = "cc_binary", _cc_library = "cc_library", _cc_test = "cc_test")
cc_library = _cc_library
cc_proto_library = _cc_proto_library
@@ -11,7 +12,6 @@ gtest = "@com_google_googletest//:gtest"
gbenchmark = "@com_google_benchmark//:benchmark"
gbenchmark_internal = "@com_google_benchmark//:benchmark"
grpcpp = "@com_github_grpc_grpc//:grpc++"
vdso_linker_option = "-fuse-ld=gold "
def _cc_flags_supplier_impl(ctx):
variables = platform_common.TemplateVariableInfo({
+1 -1
View File
@@ -173,7 +173,7 @@ def go_context(ctx, goos = None, goarch = None, std = False):
goos = goos,
gotags = go_ctx.tags,
nogo_args = [],
runfiles = depset([go_ctx.go] + go_ctx.sdk.srcs + go_ctx.sdk.tools + go_ctx.stdlib.libs),
runfiles = depset([go_ctx.go] + go_ctx.sdk.srcs.to_list() + go_ctx.sdk.tools.to_list() + go_ctx.stdlib.libs.to_list()),
stdlib_srcs = go_ctx.sdk.srcs,
)
+1 -1
View File
@@ -14,7 +14,7 @@ go_library(
"//:sandbox",
],
deps = [
"@com_google_cloud_go//bigquery:go_default_library",
"@com_google_cloud_go_bigquery//:go_default_library",
"@org_golang_google_api//option:go_default_library",
"@org_golang_x_oauth2//:go_default_library",
],
+1 -2
View File
@@ -5,7 +5,7 @@ automagically creating cc_ and go_ proto targets) and act as a single point of
change for Google-internal and bazel-compatible rules.
"""
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")
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")
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")
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")
load("//tools/bazeldefs:pkg.bzl", _pkg_deb = "pkg_deb", _pkg_tar = "pkg_tar")
@@ -39,7 +39,6 @@ gbenchmark = _gbenchmark
gbenchmark_internal = _gbenchmark_internal
gtest = _gtest
grpcpp = _grpcpp
vdso_linker_option = _vdso_linker_option
select_gtest = _select_gtest
# Go rules.
+6 -6
View File
@@ -1,8 +1,8 @@
diff --git a/src/go/types/scope.go b/src/go/types/scope.go
index 010727eb72..0f134b872e 100644
index e3fb7b6eff..683f844b42 100644
--- a/src/go/types/scope.go
+++ b/src/go/types/scope.go
@@ -25,6 +25,7 @@ type Scope struct {
@@ -27,6 +27,7 @@ type Scope struct {
children []*Scope
number int // parent.children[number-1] is this scope; 0 if there is no parent
elems map[string]Object // lazily allocated
@@ -10,7 +10,7 @@ index 010727eb72..0f134b872e 100644
pos, end token.Pos // scope extent; may be invalid
comment string // for debugging only
isFunc bool // set if this is a function scope (internal use only)
@@ -33,7 +34,7 @@ type Scope struct {
@@ -35,7 +36,7 @@ type Scope struct {
// NewScope returns a new, empty scope contained in the given parent
// scope, if any. The comment is for debugging only.
func NewScope(parent *Scope, pos, end token.Pos, comment string) *Scope {
@@ -19,7 +19,7 @@ index 010727eb72..0f134b872e 100644
// don't add children to Universe scope!
if parent != nil && parent != Universe {
parent.children = append(parent.children, s)
@@ -50,14 +51,16 @@ func (s *Scope) Len() int { return len(s.elems) }
@@ -52,14 +53,16 @@ func (s *Scope) Len() int { return len(s.elems) }
// Names returns the scope's element names in sorted order.
func (s *Scope) Names() []string {
@@ -35,9 +35,9 @@ index 010727eb72..0f134b872e 100644
+ s.sorted[i] = name
+ i++
+ }
+ sort.Strings(s.sorted)
+ slices.Sort(s.sorted)
}
- sort.Strings(names)
- slices.Sort(names)
- return names
+ return s.sorted
}
+3 -2
View File
@@ -70,10 +70,11 @@ def _nogo_stdlib_impl(ctx):
# Build the analyzer command.
facts_file = ctx.actions.declare_file(ctx.label.name + ".facts")
findings_file = ctx.actions.declare_file(ctx.label.name + ".raw_findings")
stdlib_srcs = go_ctx.stdlib_srcs if type(go_ctx.stdlib_srcs) == "list" else go_ctx.stdlib_srcs.to_list()
ctx.actions.run(
# For the standard library, we need to include the full set of Go
# sources in the inputs.
inputs = inputs + go_ctx.stdlib_srcs,
inputs = inputs + stdlib_srcs,
outputs = [facts_file, findings_file],
tools = depset(go_ctx.runfiles.to_list() + ctx.files._nogo),
executable = ctx.files._nogo[0],
@@ -90,7 +91,7 @@ def _nogo_stdlib_impl(ctx):
"-findings=%s" % findings_file.path,
"-facts=%s" % facts_file.path,
"-root=.*?/src/",
] + [f.path for f in go_ctx.stdlib_srcs],
] + [f.path for f in stdlib_srcs],
toolchain = None,
)
File diff suppressed because it is too large Load Diff
-6
View File
@@ -1,9 +1,3 @@
commit 6df2a94ece32425f53ea6fecdca3af7148dcc48b
Author: Andrei Vagin <[email protected]>
Date: Wed Feb 5 20:18:13 2025 +0000
../gvisor/tools/rules_cgo.patch
diff --git a/go/private/rules/cgo.bzl b/go/private/rules/cgo.bzl
index b8fc93a6..3fec27e4 100644
--- a/go/private/rules/cgo.bzl
+43 -29
View File
@@ -1,8 +1,8 @@
diff --git a/go/private/actions/archive.bzl b/go/private/actions/archive.bzl
index 3bf0bffd..7cfe2fcc 100644
index ab56991c..ebe43ca2 100644
--- a/go/private/actions/archive.bzl
+++ b/go/private/actions/archive.bzl
@@ -201,6 +201,7 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
@@ -219,6 +219,7 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
data = data,
direct = direct,
libs = depset(direct = [out_lib], transitive = [a.libs for a in direct]),
@@ -11,22 +11,22 @@ index 3bf0bffd..7cfe2fcc 100644
x_defs = x_defs,
cgo_deps = depset(transitive = [cgo_deps] + [a.cgo_deps for a in direct]),
diff --git a/go/private/rules/binary.bzl b/go/private/rules/binary.bzl
index 40b4011e..688a90b8 100644
index 064831bb..3ca16253 100644
--- a/go/private/rules/binary.bzl
+++ b/go/private/rules/binary.bzl
@@ -124,6 +124,7 @@ def _go_binary_impl(ctx):
source,
@@ -157,6 +157,7 @@ def _go_binary_impl(ctx):
providers = [
archive,
OutputGroupInfo(
+ export_files = archive.export_files,
cgo_exports = archive.cgo_exports,
compilation_outputs = [archive.data.file],
),
nogo_fix = [nogo_diagnostics] if nogo_diagnostics else [],
diff --git a/go/private/rules/library.bzl b/go/private/rules/library.bzl
index ac563544..e3dbfe81 100644
index 68a1d3b9..53c38cb2 100644
--- a/go/private/rules/library.bzl
+++ b/go/private/rules/library.bzl
@@ -53,6 +53,8 @@ def _go_library_impl(ctx):
@@ -64,6 +64,8 @@ def _go_library_impl(ctx):
extensions = ["go"],
),
OutputGroupInfo(
@@ -34,45 +34,59 @@ index ac563544..e3dbfe81 100644
+ libs = archive.libs,
cgo_exports = archive.cgo_exports,
compilation_outputs = [archive.data.file],
),
@@ -102,8 +104,7 @@ go_library = rule(
with the same path (for example, from different vendor directories).
""",
),
- "importpath_aliases": attr.string_list(
- ), # experimental, undocumented
+ "importpath_aliases": attr.string_list(), # experimental, undocumented
"embed": attr.label_list(
providers = [GoLibrary],
doc = """
nogo_fix = [nogo_diagnostics] if nogo_diagnostics else [],
@@ -214,9 +216,23 @@ def _go_tool_library_impl(ctx):
go_info = new_go_info(go, ctx.attr)
archive = go.archive(go, go_info)
+ validation_output = archive.data._validation_output
+ nogo_diagnostics = archive.data._nogo_diagnostics
+
return [
go_info,
archive,
+ DefaultInfo(
+ files = depset([archive.data.export_file]),
+ ),
+ OutputGroupInfo(
+ export_files = archive.export_files,
+ libs = archive.libs,
+ cgo_exports = archive.cgo_exports,
+ compilation_outputs = [archive.data.file],
+ nogo_fix = [nogo_diagnostics] if nogo_diagnostics else [],
+ _validation = [validation_output] if validation_output else [],
+ ),
]
go_tool_library = rule(
diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl
index 554cd30c..4aeab1b4 100644
index dcb4eb63..660505b4 100644
--- a/go/private/rules/test.bzl
+++ b/go/private/rules/test.bzl
@@ -183,6 +183,8 @@ def _go_test_impl(ctx):
@@ -215,6 +215,8 @@ def _go_test_impl(ctx):
),
OutputGroupInfo(
compilation_outputs = [internal_archive.data.file],
+ export_files = internal_archive.export_files,
+ libs = internal_archive.libs,
nogo_fix = nogo_diagnosticss,
_validation = validation_outputs,
),
coverage_common.instrumented_files_info(
ctx,
@@ -697,6 +699,7 @@ def _recompile_external_deps(go, external_source, internal_archive, library_labe
@@ -723,6 +725,7 @@ def _recompile_external_deps(go, external_go_info, internal_archive, library_lab
data = arc_data,
direct = deps,
libs = depset(direct = [arc_data.file], transitive = [a.libs for a in deps]),
+ export_files = depset(direct = [arc_data.export_file], transitive = [a.export_files for a in deps]),
transitive = depset(direct = [arc_data], transitive = [a.transitive for a in deps]),
x_defs = source.x_defs,
cgo_deps = depset(direct = arc_data._cgo_deps, transitive = [a.cgo_deps for a in deps]),
x_defs = go_info.x_defs,
cgo_deps = depset(transitive = [arc_data._cgo_deps] + [a.cgo_deps for a in deps]),
diff --git a/proto/def.bzl b/proto/def.bzl
index 6a2a2d72..0fa8f800 100644
index 7b70b83c..5c120de5 100644
--- a/proto/def.bzl
+++ b/proto/def.bzl
@@ -136,10 +136,11 @@ def _go_proto_library_impl(ctx):
@@ -154,10 +154,11 @@ def _go_proto_library_impl(ctx):
if valid_archive:
archive = go.archive(go, source)
archive = go.archive(go, go_info)
output_groups["compilation_outputs"] = [archive.data.file]
+ output_groups["export_files"] = archive.export_files
providers.extend([
+12 -18
View File
@@ -1,14 +1,8 @@
commit 441d5858370a443b117e1bcc19288b79d092147e
Author: Andrei Vagin <[email protected]>
Date: Wed Feb 5 20:18:48 2025 +0000
../gvisor/tools/rules_go_sdk.patch
diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl
index ca70b237..71149eba 100644
index 156bb255..619c5395 100644
--- a/go/private/sdk.bzl
+++ b/go/private/sdk.bzl
@@ -130,6 +130,8 @@ def _go_download_sdk_impl(ctx):
@@ -129,6 +129,8 @@ def _go_download_sdk_impl(ctx):
"sdks": ctx.attr.sdks,
"urls": ctx.attr.urls,
"version": version,
@@ -17,7 +11,7 @@ index ca70b237..71149eba 100644
"strip_prefix": ctx.attr.strip_prefix,
}
return None
@@ -145,6 +147,7 @@ go_download_sdk_rule = repository_rule(
@@ -144,6 +146,7 @@ go_download_sdk_rule = repository_rule(
),
"urls": attr.string_list(default = ["https://dl.google.com/go/{}"]),
"version": attr.string(),
@@ -25,12 +19,12 @@ index ca70b237..71149eba 100644
"strip_prefix": attr.string(default = "go"),
"patches": attr.label_list(
doc = "A list of patches to apply to the SDK after downloading it",
@@ -462,6 +465,8 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256):
res = ctx.execute(["tar", "-xf", "go_sdk.tar.gz", "--strip-components=1"])
if res.return_code:
fail("error extracting Go SDK:\n" + res.stdout + res.stderr)
+ if ctx.attr.patch:
+ ctx.patch(ctx.attr.patch, strip=ctx.attr.patch_strip)
ctx.delete("go_sdk.tar.gz")
elif (urls[0].endswith(".zip") and
host_goos == "darwin" and
@@ -432,6 +435,8 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256):
sha256 = sha256,
auth = auth,
)
+ if ctx.attr.patch:
+ ctx.patch(ctx.attr.patch, strip = ctx.attr.patch_strip)
def _local_sdk(ctx, path):
for entry in ctx.path(path).readdir():
+3 -3
View File
@@ -1,12 +1,12 @@
diff --git a/go/private/rules/test.bzl b/go/private/rules/test.bzl
index 1283776a..bc868296 100644
index 12dd1cc5..dcb4eb63 100644
--- a/go/private/rules/test.bzl
+++ b/go/private/rules/test.bzl
@@ -124,9 +124,6 @@ def _go_test_impl(ctx):
@@ -150,9 +150,6 @@ def _go_test_impl(ctx):
)
test_gc_linkopts = gc_linkopts(ctx)
- if not go.mode.debug:
- if not go.mode.debug and go.mode.strip:
- # Disable symbol table and DWARF generation for test binaries.
- test_gc_linkopts.extend(["-s", "-w"])
+1 -2
View File
@@ -5,7 +5,7 @@
# Placeholder: load py_test
load("//tools:arch.bzl", "select_arch")
load("//tools:defs.bzl", "cc_flags_supplier", "cc_toolchain", "vdso_linker_option")
load("//tools:defs.bzl", "cc_flags_supplier", "cc_toolchain")
package(
default_applicable_licenses = ["//:license"],
@@ -40,7 +40,6 @@ genrule(
# Some toolchains enable stack protector by default. Disable it, the
# VDSO has no hooks to handle failures.
"-fno-stack-protector " +
vdso_linker_option +
"-shared " +
"-nostdlib " +
"-Wl,-soname=linux-vdso.so.1 " +