darwin: use x86 envoy build for arm64 (#2246)

* darwin: use x86 envoy build for arm64

* allow arm64 build for darwin
This commit is contained in:
Caleb Doxsey 2021-05-28 16:59:09 -06:00 committed by GitHub
parent db00821001
commit 1eea197859
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View file

@ -26,9 +26,6 @@ builds:
goos:
- linux
- darwin
ignore:
- goos: darwin
goarch: arm64
ldflags:
- -s -w

View file

@ -15,6 +15,7 @@ import (
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"sync"
@ -196,7 +197,13 @@ func (srv *Server) run(ctx context.Context, cfg *config.Config) error {
}
srv.restartEpoch++
cmd := exec.Command(srv.envoyPath, args...) // #nosec
var cmd *exec.Cmd
if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
// until m1 macs are supported by envoy, fallback to x86 and use rosetta
cmd = exec.Command("arch", append([]string{"-x86_64", srv.envoyPath}, args...)...) // #nosec
} else {
cmd = exec.Command(srv.envoyPath, args...) // #nosec
}
cmd.Dir = srv.wd
stderr, err := cmd.StderrPipe()

View file

@ -8,6 +8,11 @@ _envoy_version=1.17.3
_dir="${DIR:-"$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../bin"}"
_target="${TARGET:-"$(go env GOOS)-$(go env GOARCH)"}"
# until m1 macs are supported, fallback to x86 and use rosetta
if [ "$_target" == "darwin-arm64" ]; then
_target="darwin-amd64"
fi
is_command() {
command -v "$1" >/dev/null
}