hack: check if cross-compiling before setting ARM target name

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-01-20 15:13:11 +01:00
parent 95e207933d
commit 67aa86f1e0
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7

View file

@ -16,22 +16,25 @@ source "${MAKEDIR}/.go-autogen"
(
export GOGC=${DOCKER_BUILD_GOGC:-1000}
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
if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
# must be cross-compiling!
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
fi
# -buildmode=pie is not supported on Windows arm64 and Linux mips*, ppc64be