Skip to content

Commit

Permalink
Merge pull request #17422 from ArkaSaha30/configure_cgo_3.4
Browse files Browse the repository at this point in the history
[3.4] Make CGO_ENABLED configurable
  • Loading branch information
ahrtr authored Feb 14, 2024
2 parents 380175a + 387ca62 commit 6affeed
Showing 1 changed file with 5 additions and 3 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

0 comments on commit 6affeed

Please sign in to comment.