From 8c12a6648b368cc2acaea0339d6c57c920ed265c Mon Sep 17 00:00:00 2001 From: Kevin Alvarez Date: Mon, 16 Jan 2023 11:39:34 +0100 Subject: [PATCH] hack: name for target ARM architecture not specified Build currently doesn't set the right name for target ARM architecture through switches in CGO_CFLAGS and CGO_CXXFLAGS when doing cross-compilation. This was previously fixed in https://github.com/moby/moby/pull/43474 Also removes the toolchain configuration. Following changes for cross-compilation in https://github.com/moby/moby/pull/44546, we forgot to remove the toolchain configuration that is not used anymore as xx already sets correct cc/cxx envs already. Signed-off-by: CrazyMax (cherry picked from commit 945704208a8f4e3aa16c644a9d96c5735cc6f31d) --- hack/make/.binary | 69 +++++++++++------------------------------------ 1 file changed, 16 insertions(+), 53 deletions(-) diff --git a/hack/make/.binary b/hack/make/.binary index 5f3082b53ca7e..64fbadcd79927 100644 --- a/hack/make/.binary +++ b/hack/make/.binary @@ -16,59 +16,22 @@ source "${MAKEDIR}/.go-autogen" ( export GOGC=${DOCKER_BUILD_GOGC:-1000} - # for non-sandboxed invocation - if ! command -v xx-go > /dev/null 2>&1; then - if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then - # must be cross-compiling! - case "$(go env GOOS)/$(go env GOARCH)" in - windows/amd64) - export CC="${CC:-x86_64-w64-mingw32-gcc}" - export CGO_ENABLED=1 - ;; - linux/arm) - case "${GOARM}" in - 5) - export CC="${CC:-arm-linux-gnueabi-gcc}" - export CGO_ENABLED=1 - export CGO_CFLAGS="-march=armv5t" - export CGO_CXXFLAGS="-march=armv5t" - ;; - 6) - export CC="${CC:-arm-linux-gnueabi-gcc}" - export CGO_ENABLED=1 - export CGO_CFLAGS="-march=armv6" - export CGO_CXXFLAGS="-march=armv6" - ;; - 7) - export CC="${CC:-arm-linux-gnueabihf-gcc}" - export CGO_ENABLED=1 - export CGO_CFLAGS="-march=armv7-a" - export CGO_CXXFLAGS="-march=armv7-a" - ;; - *) - export CC="${CC:-arm-linux-gnueabihf-gcc}" - export CGO_ENABLED=1 - ;; - esac - ;; - linux/arm64) - export CC="${CC:-aarch64-linux-gnu-gcc}" - export CGO_ENABLED=1 - ;; - linux/amd64) - export CC="${CC:-x86_64-linux-gnu-gcc}" - export CGO_ENABLED=1 - ;; - linux/ppc64le) - export CC="${CC:-powerpc64le-linux-gnu-gcc}" - export CGO_ENABLED=1 - ;; - linux/s390x) - export CC="${CC:-s390x-linux-gnu-gcc}" - export CGO_ENABLED=1 - ;; - esac - fi + if [ "$(go env GOOS)/$(go env GOARCH)" = "linux/arm" ]; then + # specify name of the target ARM architecture + case "$(go env GOARM)" in + 5) + export CGO_CFLAGS="-march=armv5t" + export CGO_CXXFLAGS="-march=armv5t" + ;; + 6) + export CGO_CFLAGS="-march=armv6" + export CGO_CXXFLAGS="-march=armv6" + ;; + 7) + export CGO_CFLAGS="-march=armv7-a" + export CGO_CXXFLAGS="-march=armv7-a" + ;; + esac fi # -buildmode=pie is not supported on Windows arm64 and Linux mips*, ppc64be