mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Statically link benchmark test binaries.
After update to Go 1.20 in 5572ab2f7d ("Bump go version to 1.20"), the
benchmark jobs have been failing on BuildKite. This seems to be happening
because benchmark test binaries are built in Docker containers but are run on
the host. On some hosts, the glibc isn't compatible with glibc in our docker
container. So dynamically linked binaries may fail. Linking them statically
resolves this glibc compatibility issue.
As a result, this change also adds support for static test binaries to
tools/bazeldefs/go.bzl.
PiperOrigin-RevId: 510455271
This commit is contained in:
@@ -5,11 +5,15 @@ load("//tools:defs.bzl", "go_test")
|
||||
def benchmark_test(name, tags = [], **kwargs):
|
||||
go_test(
|
||||
name,
|
||||
tags = [
|
||||
tags = tags + [
|
||||
# Requires docker and runsc to be configured before the test runs.
|
||||
"local",
|
||||
"manual",
|
||||
"gvisor_benchmark",
|
||||
],
|
||||
# Benchmark test binaries are built inside a bazel docker container in
|
||||
# OSS but are executed directly on the host. Use static binaries to
|
||||
# avoid hitting glibc incompatibility.
|
||||
static = True,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@@ -43,7 +43,7 @@ def go_proto_library(name, **kwargs):
|
||||
def go_grpc_and_proto_libraries(name, **kwargs):
|
||||
_go_proto_or_grpc_library(_go_grpc_library, name, **kwargs)
|
||||
|
||||
def go_binary(name, static = False, pure = False, x_defs = None, system_malloc = False, **kwargs):
|
||||
def go_binary(name, static = False, pure = False, x_defs = None, **kwargs):
|
||||
"""Build a go binary.
|
||||
|
||||
Args:
|
||||
@@ -79,17 +79,20 @@ def go_library(name, arch_deps = [], **kwargs):
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def go_test(name, pure = False, library = None, **kwargs):
|
||||
def go_test(name, static = False, pure = False, library = None, **kwargs):
|
||||
"""Build a go test.
|
||||
|
||||
Args:
|
||||
name: name of the output binary.
|
||||
static: build a static binary.
|
||||
pure: should it be built without cgo.
|
||||
library: the library to embed.
|
||||
**kwargs: rest of the arguments to pass to _go_test.
|
||||
"""
|
||||
if pure:
|
||||
kwargs["pure"] = "on"
|
||||
if static:
|
||||
kwargs["static"] = "on"
|
||||
if library:
|
||||
kwargs["embed"] = [library]
|
||||
_go_test(
|
||||
|
||||
Reference in New Issue
Block a user