From 4fbbc697f6df1a75ae39ffeb45108b5749159413 Mon Sep 17 00:00:00 2001 From: Sunnatillo Date: Mon, 13 Oct 2025 11:15:53 +0300 Subject: [PATCH] Disable DWARF and symbol table to decrease binary/image size This commit introduces DBG variable which is used to control including DWARF and symbol table for images/binaries Signed-off-by: Sunnatillo --- Makefile | 5 +++++ hack/version.sh | 7 ++++++- scripts/ci-build.sh | 3 +++ scripts/ci-e2e.sh | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cf5bdd9cb80f..957392ca8479 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,11 @@ OBSERVABILITY_DIR := hack/observability export PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH) +# DBG=1 for building binaries which includes DWARF and symbol table for delve +# degubbing. When DBG is unspecified it defaults to "-s -w" which strips debug +# information. +export DBG ?= 0 + # # Ginkgo configuration. # diff --git a/hack/version.sh b/hack/version.sh index 4c40b23e1858..c0a24d9d46c8 100755 --- a/hack/version.sh +++ b/hack/version.sh @@ -102,7 +102,12 @@ version::ldflags() { add_ldflag "gitReleaseCommit" "${GIT_RELEASE_COMMIT}" # The -ldflags parameter takes a single string, so join the output. - echo "${ldflags[*]-}" + # When DBG is set to 1 include DWARF and symbol table for delve degubbing + if [[ "${DBG:-}" == 1 ]]; then + echo "${ldflags[*]-}" + else + echo "${ldflags[*]-}" " -s -w" + fi } version::ldflags diff --git a/scripts/ci-build.sh b/scripts/ci-build.sh index 86c08dc99ac6..f87786e2f710 100755 --- a/scripts/ci-build.sh +++ b/scripts/ci-build.sh @@ -18,6 +18,9 @@ set -o errexit set -o nounset set -o pipefail +# Include debugging tools for build test +export DBG=1 + REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. # Core Cluster API and Docker provider diff --git a/scripts/ci-e2e.sh b/scripts/ci-e2e.sh index ca40d90b90c1..7b7ee3de8875 100755 --- a/scripts/ci-e2e.sh +++ b/scripts/ci-e2e.sh @@ -32,6 +32,9 @@ source "${REPO_ROOT}/hack/ensure-kind.sh" # Make sure the tools binaries are on the path. export PATH="${REPO_ROOT}/hack/tools/bin:${PATH}" +# Include debugging tools for container images for e2e tests +export DBG=1 + # Builds CAPI (and CAPD) images. capi:buildDockerImages