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 <crazy-max@users.noreply.github.com>
This commit is contained in:
Kevin Alvarez 2023-01-16 11:39:34 +01:00 committed by CrazyMax
parent 94639eb66f
commit 945704208a
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7

View file

@ -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