mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Merge pull request #108371 from thockin/makefile-dbg-flag
Makefile: add a DBG variable
This commit is contained in:
commit
4dda76588f
@ -73,6 +73,8 @@ define ALL_HELP_INFO
|
|||||||
# GOFLAGS: Extra flags to pass to 'go' when building.
|
# GOFLAGS: Extra flags to pass to 'go' when building.
|
||||||
# GOLDFLAGS: Extra linking flags passed to 'go' when building.
|
# GOLDFLAGS: Extra linking flags passed to 'go' when building.
|
||||||
# GOGCFLAGS: Additional go compile flags passed to 'go' when building.
|
# GOGCFLAGS: Additional go compile flags passed to 'go' when building.
|
||||||
|
# DBG: If set to "1", build with optimizations disabled for easier
|
||||||
|
# debugging. Any other value is ignored.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# make
|
# make
|
||||||
|
@ -714,12 +714,12 @@ kube::golang::build_binaries_for_platform() {
|
|||||||
local -a build_args
|
local -a build_args
|
||||||
if [[ "${#statics[@]}" != 0 ]]; then
|
if [[ "${#statics[@]}" != 0 ]]; then
|
||||||
build_args=(
|
build_args=(
|
||||||
-installsuffix static
|
-installsuffix=static
|
||||||
${goflags:+"${goflags[@]}"}
|
${goflags:+"${goflags[@]}"}
|
||||||
-gcflags "${gogcflags:-}"
|
-gcflags="${gogcflags}"
|
||||||
-asmflags "${goasmflags:-}"
|
-asmflags="${goasmflags}"
|
||||||
-ldflags "${goldflags:-}"
|
-ldflags="${goldflags}"
|
||||||
-tags "${gotags:-}"
|
-tags="${gotags:-}"
|
||||||
)
|
)
|
||||||
CGO_ENABLED=0 kube::golang::build_some_binaries "${statics[@]}"
|
CGO_ENABLED=0 kube::golang::build_some_binaries "${statics[@]}"
|
||||||
fi
|
fi
|
||||||
@ -727,10 +727,10 @@ kube::golang::build_binaries_for_platform() {
|
|||||||
if [[ "${#nonstatics[@]}" != 0 ]]; then
|
if [[ "${#nonstatics[@]}" != 0 ]]; then
|
||||||
build_args=(
|
build_args=(
|
||||||
${goflags:+"${goflags[@]}"}
|
${goflags:+"${goflags[@]}"}
|
||||||
-gcflags "${gogcflags:-}"
|
-gcflags="${gogcflags}"
|
||||||
-asmflags "${goasmflags:-}"
|
-asmflags="${goasmflags}"
|
||||||
-ldflags "${goldflags:-}"
|
-ldflags="${goldflags}"
|
||||||
-tags "${gotags:-}"
|
-tags="${gotags:-}"
|
||||||
)
|
)
|
||||||
kube::golang::build_some_binaries "${nonstatics[@]}"
|
kube::golang::build_some_binaries "${nonstatics[@]}"
|
||||||
fi
|
fi
|
||||||
@ -743,10 +743,10 @@ kube::golang::build_binaries_for_platform() {
|
|||||||
mkdir -p "$(dirname "${outfile}")"
|
mkdir -p "$(dirname "${outfile}")"
|
||||||
go test -c \
|
go test -c \
|
||||||
${goflags:+"${goflags[@]}"} \
|
${goflags:+"${goflags[@]}"} \
|
||||||
-gcflags "${gogcflags:-}" \
|
-gcflags="${gogcflags}" \
|
||||||
-asmflags "${goasmflags:-}" \
|
-asmflags="${goasmflags}" \
|
||||||
-ldflags "${goldflags:-}" \
|
-ldflags="${goldflags}" \
|
||||||
-tags "${gotags:-}" \
|
-tags="${gotags:-}" \
|
||||||
-o "${outfile}" \
|
-o "${outfile}" \
|
||||||
"${testpkg}"
|
"${testpkg}"
|
||||||
done
|
done
|
||||||
@ -798,17 +798,31 @@ kube::golang::build_binaries() {
|
|||||||
local host_platform
|
local host_platform
|
||||||
host_platform=$(kube::golang::host_platform)
|
host_platform=$(kube::golang::host_platform)
|
||||||
|
|
||||||
|
# These are "local" but are visible to and relied on by functions this
|
||||||
|
# function calls. They are effectively part of the calling API to
|
||||||
|
# build_binaries_for_platform.
|
||||||
local goflags goldflags goasmflags gogcflags gotags
|
local goflags goldflags goasmflags gogcflags gotags
|
||||||
# If GOLDFLAGS is unset, then set it to the a default of "-s -w".
|
|
||||||
# Disable SC2153 for this, as it will throw a warning that the local
|
|
||||||
# variable goldflags will exist, and it suggest changing it to this.
|
|
||||||
# shellcheck disable=SC2153
|
|
||||||
goldflags="${GOLDFLAGS=-s -w} $(kube::version::ldflags)"
|
|
||||||
goasmflags="-trimpath=${KUBE_ROOT}"
|
|
||||||
gogcflags="${GOGCFLAGS:-} -trimpath=${KUBE_ROOT}"
|
|
||||||
|
|
||||||
# extract tags if any specified in GOFLAGS
|
# This is $(pwd) because we use run-in-gopath to build. Once that is
|
||||||
# shellcheck disable=SC2001
|
# excised, this can become ${KUBE_ROOT}.
|
||||||
|
local trimroot # two lines to appease shellcheck SC2155
|
||||||
|
trimroot=$(pwd)
|
||||||
|
|
||||||
|
goasmflags="all=-trimpath=${trimroot}"
|
||||||
|
|
||||||
|
gogcflags="all=-trimpath=${trimroot} ${GOGCFLAGS:-}"
|
||||||
|
if [[ "${DBG:-}" == 1 ]]; then
|
||||||
|
# Debugging - disable optimizations and inlining.
|
||||||
|
gogcflags="${gogcflags} -N -l"
|
||||||
|
fi
|
||||||
|
|
||||||
|
goldflags="all=$(kube::version::ldflags) ${GOLDFLAGS:-}"
|
||||||
|
if [[ "${DBG:-}" != 1 ]]; then
|
||||||
|
# Not debugging - disable symbols and DWARF.
|
||||||
|
goldflags="${goldflags} -s -w"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract tags if any specified in GOFLAGS
|
||||||
gotags="selinux,notest,$(echo "${GOFLAGS:-}" | sed -ne 's|.*-tags=\([^-]*\).*|\1|p')"
|
gotags="selinux,notest,$(echo "${GOFLAGS:-}" | sed -ne 's|.*-tags=\([^-]*\).*|\1|p')"
|
||||||
|
|
||||||
local -a targets=()
|
local -a targets=()
|
||||||
|
Loading…
Reference in New Issue
Block a user