Skip to content

Commit 4fbbc69

Browse files
committed
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 <[email protected]>
1 parent 3fe6f96 commit 4fbbc69

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ OBSERVABILITY_DIR := hack/observability
7373

7474
export PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH)
7575

76+
# DBG=1 for building binaries which includes DWARF and symbol table for delve
77+
# degubbing. When DBG is unspecified it defaults to "-s -w" which strips debug
78+
# information.
79+
export DBG ?= 0
80+
7681
#
7782
# Ginkgo configuration.
7883
#

hack/version.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ version::ldflags() {
102102
add_ldflag "gitReleaseCommit" "${GIT_RELEASE_COMMIT}"
103103

104104
# The -ldflags parameter takes a single string, so join the output.
105-
echo "${ldflags[*]-}"
105+
# When DBG is set to 1 include DWARF and symbol table for delve degubbing
106+
if [[ "${DBG:-}" == 1 ]]; then
107+
echo "${ldflags[*]-}"
108+
else
109+
echo "${ldflags[*]-}" " -s -w"
110+
fi
106111
}
107112

108113
version::ldflags

scripts/ci-build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
# Include debugging tools for build test
22+
export DBG=1
23+
2124
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
2225

2326
# Core Cluster API and Docker provider

scripts/ci-e2e.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ source "${REPO_ROOT}/hack/ensure-kind.sh"
3232
# Make sure the tools binaries are on the path.
3333
export PATH="${REPO_ROOT}/hack/tools/bin:${PATH}"
3434

35+
# Include debugging tools for container images for e2e tests
36+
export DBG=1
37+
3538
# Builds CAPI (and CAPD) images.
3639
capi:buildDockerImages
3740

0 commit comments

Comments
 (0)