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

add support for darwin/arm64 (Apple Silicon) #693

Merged
merged 2 commits into from
Feb 17, 2021

Conversation

joelanford
Copy link
Member

This PR adds support for Apple Silicon by adding darwin/arm64 to the build matrix.

The install scripts are a bit more complicated now because uname -m on Apple Silicon returns arm64, so the sed -e 's/arm.*$/arm/' substitution resulted in darwin_arm, rather than darwin_arm64.

I fixed that as best I could with a case statement, but perhaps there's a simpler approach. I looked into a pure sed solution, but it doesn't seem like sed supports the necessary lookahead features that would enable search/replace for arm + anything other than 64.

Fixes #686

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 17, 2021
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 17, 2021
@@ -22,9 +22,11 @@ Krew self-hosts).
```sh
(
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH=`case "${OS}" in "darwin") uname -m | sed -e 's/x86_64/amd64/' ;; *) uname -m | sed -e 's/x86_64/amd64/' -e 's/arm.*$/arm/' -e 's/aarch64$/arm64/' ;; esac` &&
Copy link
Member

Choose a reason for hiding this comment

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

this part is a little suspicious: why did you need case "${OS}" in "darwin") ?

it seems that uname -m already returns arm64 in Apple Silicon chip, so it would work as is?

if you did this because of -e 's/arm.*$/arm/', that's understandable as it could return values like armv7l, armv8 in other platforms such as Linux. in that case, we can rewrite the regexp pattern in a way that does not replace amd64 (coming from M1).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is the part that I mentioned in the PR description.

The install scripts are a bit more complicated now because uname -m on Apple Silicon returns arm64, so the sed -e 's/arm.*$/arm/' substitution resulted in darwin_arm, rather than darwin_arm64.

I fixed that as best I could with a case statement, but perhaps there's a simpler approach. I looked into a pure sed solution, but it doesn't seem like sed supports the necessary lookahead features that would enable search/replace for arm + anything other than 64.

Any better ideas?

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed a new update with a better sed-only replacement that seems to work. WDYT?

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
@ahmetb
Copy link
Member

ahmetb commented Feb 17, 2021

Looks good. Thanks.
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 17, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmetb, joelanford

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 17, 2021
@k8s-ci-robot k8s-ci-robot merged commit ec169f8 into kubernetes-sigs:master Feb 17, 2021
@joelanford joelanford deleted the darwin-arm64 branch February 17, 2021 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to install on Apple Silicon
3 participants