Skip to content

Commit

Permalink
Merge pull request #44862 from thaJeztah/23.0_backport_fix_arm
Browse files Browse the repository at this point in the history
[23.0 backport] hack: check if cross-compiling before setting ARM target name
  • Loading branch information
thaJeztah committed Jan 20, 2023
2 parents b968cb9 + 8fc49af commit 3f87416
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions hack/make/.binary
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3f87416

Please sign in to comment.