From 36d803d754846493c19c1da83a426e60842df3fb Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 20 Oct 2026 15:31:29 +0200 Subject: [PATCH] hack: disable unused gRPC tracing in dockerd Set the `grpcnotrace` tag to exclude the legacy `golang.org/x/net/trace` dependency, allowing the linker to eliminate unused tracing code. This reduces the binary size by approximately 232 KiB. See https://github.com/grpc/grpc-go/blob/v1.83.2/trace_notrace.go#L23-L25 Signed-off-by: Sebastiaan van Stijn --- hack/make.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hack/make.sh b/hack/make.sh index 0b8094edd2..c4c8110c88 100755 --- a/hack/make.sh +++ b/hack/make.sh @@ -88,7 +88,11 @@ if [ -z "$DOCKER_DEBUG" ]; then LDFLAGS='-w' fi -BUILDFLAGS=(${BUILDFLAGS} -tags "netgo osusergo static_build nri_no_wasm $DOCKER_BUILDTAGS") +# grpcnotrace avoids importing golang.org/x/net/trace, which in turn enables +# dead code elimination, which can reduce binary size when tracing is not needed. +# +# see https://github.com/grpc/grpc-go/blob/v1.83.2/trace_notrace.go#L23-L25 +BUILDFLAGS=(${BUILDFLAGS} -tags "grpcnotrace netgo osusergo static_build nri_no_wasm $DOCKER_BUILDTAGS") LDFLAGS_STATIC="-extldflags -static" if [ "$(uname -s)" = 'FreeBSD' ]; then