From 18d9b3bf44713cabcb8bfdc75387bf388477c6fa Mon Sep 17 00:00:00 2001 From: Scott Dodson Date: Mon, 25 May 2026 11:01:15 -0400 Subject: [PATCH 1/2] OCPBUGS-83863: Strip debug symbols from Go binaries Add -s -w to ldflags to strip DWARF debug info and symbol tables. This typically reduces binary size by 20-30%, which reduces container image pull time during node scale-up. Also fix build-gather-sysinfo and build-performance-profile-creator targets which intended to strip but had a make-vs-shell variable expansion bug: they set a shell variable LDFLAGS then referenced $(LDFLAGS) which make expands (to empty) before the shell runs. rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED --- Makefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 4cb583f81..bd8da6446 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ TESTDATA_OTE_DIR=test/extended/testdata TESTDATA_OTE=$(shell find $(TESTDATA_OTE_DIR) -type f \( -name '*.yaml' -o -name '*.yml' \) 2>/dev/null) ASSETS=$(shell find assets -name \*.yaml) GO=GOARCH=$(GOARCH) GO111MODULE=on GOFLAGS=-mod=vendor go -GO_BUILD_RECIPE=$(GO) build -o $(OUT_DIR)/$(PACKAGE_BIN) -ldflags '-X $(PACKAGE)/version.Version=$(REV)' $(PACKAGE_MAIN) +GO_BUILD_RECIPE=$(GO) build -o $(OUT_DIR)/$(PACKAGE_BIN) -ldflags '-s -w -X $(PACKAGE)/version.Version=$(REV)' $(PACKAGE_MAIN) GOFMT_CHECK=$(shell find . -not \( \( -wholename './.*' -o -wholename '*/vendor/*' \) -prune \) -name '*.go' | sort -u | xargs gofmt -s -l) REV=$(shell git describe --long --tags --match='v*' --always --dirty) @@ -270,8 +270,7 @@ cluster-clean-pao: .PHONY: build-performance-profile-creator build-performance-profile-creator: @echo "Building Performance Profile Creator (PPC)" - LDFLAGS="-s -w -X ${PACKAGE}/cmd/performance-profile-creator/version.Version=${REV} "; \ - $(GO) build -v $(LDFLAGS) -o $(OUT_DIR)/performance-profile-creator ./cmd/performance-profile-creator + $(GO) build -v -ldflags "-s -w -X $(PACKAGE)/cmd/performance-profile-creator/version.Version=$(REV)" -o $(OUT_DIR)/performance-profile-creator ./cmd/performance-profile-creator .PHONY: arm-kernel-pagesize arm-kernelpagesize: $(BINDATA) @@ -287,8 +286,7 @@ performance-profile-creator-tests: build-performance-profile-creator .PHONY: build-gather-sysinfo build-gather-sysinfo: @echo "Building gather-sysinfo" - LDFLAGS="-s -w -X ${PACKAGE}/cmd/gather-sysinfo/version.Version=${REV} "; \ - $(GO) build -v $(LDFLAGS) -o $(OUT_DIR)/gather-sysinfo ./cmd/gather-sysinfo + $(GO) build -v -ldflags "-s -w -X $(PACKAGE)/cmd/gather-sysinfo/version.Version=$(REV)" -o $(OUT_DIR)/gather-sysinfo ./cmd/gather-sysinfo .PHONY: gather-sysinfo-tests gather-sysinfo-tests: build-gather-sysinfo From 486ad1901359bfc541aad778013ec560afbbd691 Mon Sep 17 00:00:00 2001 From: Scott Dodson Date: Tue, 9 Jun 2026 13:46:27 -0400 Subject: [PATCH 2/2] Also strip cluster-node-tuning-operator-test-ext binary Co-Authored-By: Claude Sonnet 4.6 rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bd8da6446..9acea9500 100644 --- a/Makefile +++ b/Makefile @@ -318,4 +318,4 @@ pao-clean-e2e: .PHONY: cluster-node-tuning-operator-test-ext cluster-node-tuning-operator-test-ext: $(BINDATA_OTE) @echo "Building cluster-node-tuning-operator-test-ext" - GO_COMPLIANCE_POLICY=exempt_all CGO_ENABLED=0 $(GO) build -mod=vendor -v -o $(OUT_DIR)/cluster-node-tuning-operator-test-ext ./cmd/cluster-node-tuning-operator-test-ext + GO_COMPLIANCE_POLICY=exempt_all CGO_ENABLED=0 $(GO) build -mod=vendor -v -ldflags "-s -w" -o $(OUT_DIR)/cluster-node-tuning-operator-test-ext ./cmd/cluster-node-tuning-operator-test-ext