mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
Merge pull request #64219 from ixdy/hack-lib-golang-cgo-overrides
Automatic merge from submit-queue (batch tested with PRs 64338, 64219, 64486, 64495, 64347). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add KUBE_CGO_OVERRIDES env var to force enabling CGO **What this PR does / why we need it**: as detailed in https://github.com/kubernetes/release/issues/469 (and elsewhere), there is a desire to have `kubectl` built with CGO enabled on mac OS. There currently isn't a great way to do this in our official cross builds, but we should allow mac users to build their own kubectl with CGO enabled if they desire, e.g. through homebrew. This change enables that; you can now do `KUBE_CGO_OVERRIDES=kubectl make WHAT=cmd/kubectl` and get a cgo-enabled `kubectl`. The default build outputs remain unchanged. **Release note**: ```release-note kubectl built for darwin from darwin now enables cgo to use the system-native C libraries for DNS resolution. Cross-compiled kubectl (e.g. from an official kubernetes release) still uses the go-native netgo DNS implementation. ``` /assign @BenTheElder @cblecker cc @bks7 @bitglue
This commit is contained in:
commit
835268e6e7
@ -213,12 +213,27 @@ readonly KUBE_STATIC_LIBRARIES=(
|
||||
kubectl
|
||||
)
|
||||
|
||||
# KUBE_CGO_OVERRIDES is a space-separated list of binaries which should be built
|
||||
# with CGO enabled, assuming CGO is supported on the target platform.
|
||||
# This overrides any entry in KUBE_STATIC_LIBRARIES.
|
||||
IFS=" " read -ra KUBE_CGO_OVERRIDES <<< "${KUBE_CGO_OVERRIDES:-}"
|
||||
readonly KUBE_CGO_OVERRIDES
|
||||
# KUBE_STATIC_OVERRIDES is a space-separated list of binaries which should be
|
||||
# built with CGO disabled. This is in addition to the list in
|
||||
# KUBE_STATIC_LIBRARIES.
|
||||
IFS=" " read -ra KUBE_STATIC_OVERRIDES <<< "${KUBE_STATIC_OVERRIDES:-}"
|
||||
readonly KUBE_STATIC_OVERRIDES
|
||||
|
||||
kube::golang::is_statically_linked_library() {
|
||||
local e
|
||||
# Explicitly enable cgo when building kubectl for darwin from darwin.
|
||||
[[ "$(go env GOHOSTOS)" == "darwin" && "$(go env GOOS)" == "darwin" &&
|
||||
"$1" == *"/kubectl" ]] && return 1
|
||||
if [[ -n "${KUBE_CGO_OVERRIDES:+x}" ]]; then
|
||||
for e in "${KUBE_CGO_OVERRIDES[@]}"; do [[ "$1" == *"/$e" ]] && return 1; done;
|
||||
fi
|
||||
for e in "${KUBE_STATIC_LIBRARIES[@]}"; do [[ "$1" == *"/$e" ]] && return 0; done;
|
||||
# Allow individual overrides--e.g., so that you can get a static build of
|
||||
# kubectl for inclusion in a container.
|
||||
if [ -n "${KUBE_STATIC_OVERRIDES:+x}" ]; then
|
||||
if [[ -n "${KUBE_STATIC_OVERRIDES:+x}" ]]; then
|
||||
for e in "${KUBE_STATIC_OVERRIDES[@]}"; do [[ "$1" == *"/$e" ]] && return 0; done;
|
||||
fi
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user