Skip to content

Commit

Permalink
Make CGO_ENABLED configurable for etcd 3.4
Browse files Browse the repository at this point in the history
Signed-off-by: Arka Saha <arkas1@vmware.com>
  • Loading branch information
Arka Saha committed Feb 13, 2024
1 parent 380175a commit b32fc3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ if [[ -n "${FAILPOINTS:-}" ]]; then
GIT_SHA="$GIT_SHA"-FAILPOINTS
fi

CGO_ENABLED="${CGO_ENABLED:-0}"

# Set GO_LDFLAGS="-s" for building without symbols for debugging.
GO_LDFLAGS="${GO_LDFLAGS:-} -X ${REPO_PATH}/version.GitSHA=${GIT_SHA}"

Expand Down Expand Up @@ -70,12 +72,12 @@ etcd_build() {

# Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK
# shellcheck disable=SC2086
CGO_ENABLED=0 go build ${GO_BUILD_FLAGS:-} \
CGO_ENABLED=${CGO_ENABLED} go build ${GO_BUILD_FLAGS:-} \
-installsuffix cgo \
-ldflags "$GO_LDFLAGS" \
-o "${out}/etcd" ${REPO_PATH} || return
# shellcheck disable=SC2086
CGO_ENABLED=0 go build ${GO_BUILD_FLAGS:-} \
CGO_ENABLED=${CGO_ENABLED} go build ${GO_BUILD_FLAGS:-} \
-installsuffix cgo \
-ldflags "$GO_LDFLAGS" \
-o "${out}/etcdctl" ${REPO_PATH}/etcdctl || return
Expand All @@ -96,7 +98,7 @@ tools_build() {
do
echo "Building" "'${tool}'"...
# shellcheck disable=SC2086
CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} \
CGO_ENABLED=${CGO_ENABLED} go build ${GO_BUILD_FLAGS} \
-installsuffix cgo \
-ldflags "${GO_LDFLAGS}" \
-o "${out}/${tool}" "${REPO_PATH}/${tool}" || return
Expand Down
10 changes: 6 additions & 4 deletions functional/build
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

set -euo pipefail

CGO_ENABLED="${CGO_ENABLED:-0}"

if ! [[ "$0" =~ "functional/build" ]]; then
echo "must be run from repository root"
exit 255
fi

CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-agent ./functional/cmd/etcd-agent
CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-proxy ./functional/cmd/etcd-proxy
CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-runner ./functional/cmd/etcd-runner
CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-tester ./functional/cmd/etcd-tester
CGO_ENABLED=${CGO_ENABLED} go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-agent ./functional/cmd/etcd-agent
CGO_ENABLED=${CGO_ENABLED} go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-proxy ./functional/cmd/etcd-proxy
CGO_ENABLED=${CGO_ENABLED} go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-runner ./functional/cmd/etcd-runner
CGO_ENABLED=${CGO_ENABLED} go build -v -installsuffix cgo -ldflags "-s" -o ./bin/etcd-tester ./functional/cmd/etcd-tester

0 comments on commit b32fc3c

Please sign in to comment.