From f19f22b43edf498444817a0052b71d6084e68db9 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 27 Jan 2021 18:16:28 -0800 Subject: [PATCH] enable cross-compile CC config for non-amd64 Currently target CC can only be set if the host platform is linux/amd64 . If target is already set in the environment it is always safe to use it and enable cgo. Signed-off-by: Tonis Tiigi --- hack/lib/golang.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index bef1d837703..48bd9e52f4c 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -416,6 +416,13 @@ kube::golang::set_platform_envs() { ;; esac fi + + # if CC is defined for platform then always enable it + ccenv=$(echo "$platform" | awk -F/ '{print "KUBE_" toupper($1) "_" toupper($2) "_CC"}') + if [ -n "${!ccenv-}" ]; then + export CGO_ENABLED=1 + export CC="${!ccenv}" + fi } kube::golang::unset_platform_envs() {