Skip to content

Commit

Permalink
Support cross compilation only on amd64.
Browse files Browse the repository at this point in the history
  • Loading branch information
bnrjee authored and root committed Oct 21, 2020
1 parent 6b67286 commit 462326a
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions hack/lib/golang.sh
Expand Up @@ -392,36 +392,30 @@ kube::golang::set_platform_envs() {

export GOOS=${platform%/*}
export GOARCH=${platform##*/}
# Apply standard values for CGO_ENABLED and CC unless KUBE_BUILD_PLATFORMS is set.
if [ -z "${KUBE_BUILD_PLATFORMS:-}" ] ; then
export CGO_ENABLED=0
export CC=gcc
return

# 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
# If you want to include support for more server platforms than these, add arch-specific gcc names here
case "${platform}" in
"linux/arm")
export CGO_ENABLED=1
export CC=${KUBE_LINUX_ARM_CC:-arm-linux-gnueabihf-gcc}
;;
"linux/arm64")
export CGO_ENABLED=1
export CC=${KUBE_LINUX_ARM64_CC:-aarch64-linux-gnu-gcc}
;;
"linux/ppc64le")
export CGO_ENABLED=1
export CC=${KUBE_LINUX_PPC64LE_CC:-powerpc64le-linux-gnu-gcc}
;;
"linux/s390x")
export CGO_ENABLED=1
export CC=${KUBE_LINUX_S390X_CC:-s390x-linux-gnu-gcc}
;;
esac
fi
# Dynamic CGO linking for other server architectures 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=${LINUX_AMD64_CC:-gcc}
;;
"linux/arm")
export CGO_ENABLED=1
export CC=${LINUX_ARM_CC:-arm-linux-gnueabihf-gcc}
;;
"linux/arm64")
export CGO_ENABLED=1
export CC=${LINUX_ARM64_CC:-aarch64-linux-gnu-gcc}
;;
"linux/ppc64le")
export CGO_ENABLED=1
export CC=${LINUX_PPC64LE_CC:-powerpc64le-linux-gnu-gcc}
;;
"linux/s390x")
export CGO_ENABLED=1
export CC=${LINUX_S390X_CC:-s390x-linux-gnu-gcc}
;;
esac
}

kube::golang::unset_platform_envs() {
Expand Down

0 comments on commit 462326a

Please sign in to comment.