Skip to content

Commit

Permalink
Add "DEBUG_BUILD" flag (#651)
Browse files Browse the repository at this point in the history
A recent PR [1] added debug symbols by default, which wasn't intended.
This increases the k8s binary size from ~74M to ~99M.

We're introducing an env variable flag for this:

  export DEBUG_BUILD=y

[1] #618
  • Loading branch information
petrutlucian94 authored Sep 5, 2024
1 parent b90ee72 commit f349b40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/k8s/hack/dynamic-go-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ DIR="$(realpath `dirname "${0}"`)"

. "${DIR}/dynamic-dqlite.sh"

go build \
DEBUG_BUILD=${DEBUG_BUILD:-"n"}
if [[ "$DEBUG_BUILD" == "y" ]]; then
go build \
-gcflags=all="-N -l" \
-tags dqlite,libsqlite3 \
"${@}"
else
go build \
-tags dqlite,libsqlite3 \
-ldflags '-s -w' \
"${@}"
fi
18 changes: 13 additions & 5 deletions src/k8s/hack/static-go-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ DIR="$(realpath `dirname "${0}"`)"

. "${DIR}/static-dqlite.sh"

go build \
-gcflags=all="-N -l" \
-tags dqlite,libsqlite3 \
-ldflags '--linkmode "external" -extldflags "-static"' \
"${@}"
DEBUG_BUILD=${DEBUG_BUILD:-"n"}
if [[ "$DEBUG_BUILD" == "y" ]]; then
go build \
-gcflags=all="-N -l" \
-tags dqlite,libsqlite3 \
-ldflags '--linkmode "external" -extldflags "-static"' \
"${@}"
else
go build \
-tags dqlite,libsqlite3 \
-ldflags '-s -w --linkmode "external" -extldflags "-static"' \
"${@}"
fi

0 comments on commit f349b40

Please sign in to comment.