Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download native macOS arm64 binary on M1 #303

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion platforms/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ var platforms = map[string]string{"darwin": "macos", "linux": "ubuntu1404", "win
// GetPlatform returns a Bazel CI-compatible platform identifier for the current operating system.
// TODO(fweikert): raise an error for unsupported platforms
func GetPlatform() string {
return platforms[runtime.GOOS]
platform := platforms[runtime.GOOS]
arch := runtime.GOARCH
if arch == "arm64" {
platform = platform + "_arm64"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have ubuntu1404_arm64 support yet, so this may break Linux ARM64 support. But I'm not sure what happens right now when you run Bazelisk on Linux ARM64, does it fallback to fetch the x64 binary and somehow works through emulation? /cc @fweikert

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - I think we have added too many things over time. We should refactor the entire platform support (with arm64 in mind).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I tested on a Linux ARM64 machine, downloading a Bazel binary at a certain commit never worked. So this change isn't make anything worse.

}
return platform
}

// DetermineExecutableFilenameSuffix returns the extension for binaries on the current operating system.
Expand Down
16 changes: 9 additions & 7 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
set -euxo pipefail

rm -rf "$HOME/Library/Caches/bazelisk"
env -u USE_BAZEL_VERSION ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="latest" ./bin/bazelisk-darwin-amd64 version

arch=$(uname -m)
env -u USE_BAZEL_VERSION ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="latest" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="0.28.0" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_green" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_downstream_green" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_rc" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="bazelbuild/latest" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_green" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="last_downstream_green" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="last_rc" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="bazelbuild/latest" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="bazelbuild/0.27.0" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="philwo/latest" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="philwo/latest" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="philwo/0.25.0" ./bin/bazelisk-darwin-amd64 version