From fd01467c0c3211f7014e7bf3c6fa62ef87d65240 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Sun, 7 Feb 2021 21:08:00 -0800 Subject: [PATCH] avoid hardcoding amd64 specifics on cross compiling Signed-off-by: Tonis Tiigi --- hack/lib/golang.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index 48bd9e52f4c..6615d05e2d8 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -393,11 +393,15 @@ kube::golang::set_platform_envs() { export GOOS=${platform%/*} export GOARCH=${platform##*/} - # Do not set CC when building natively on a platform, only if cross-compiling from linux/amd64 - if [[ $(kube::golang::host_platform) == "linux/amd64" ]]; then - # Dynamic CGO linking for other server architectures than linux/amd64 goes here + # Do not set CC when building natively on a platform, only if cross-compiling + if [[ $(kube::golang::host_platform) != "$platform" ]]; then + # Dynamic CGO linking for other server architectures than host architecture goes here # If you want to include support for more server platforms than these, add arch-specific gcc names here case "${platform}" in + "linux/amd64") + export CGO_ENABLED=1 + export CC=${KUBE_LINUX_AMD64_CC:-x86_64-linux-gnu-gcc} + ;; "linux/arm") export CGO_ENABLED=1 export CC=${KUBE_LINUX_ARM_CC:-arm-linux-gnueabihf-gcc}