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

chore: add Apple M1 build in cross-platform target #932

Merged
merged 4 commits into from
Apr 1, 2022

Conversation

lance
Copy link
Member

@lance lance commented Mar 31, 2022

This commit adds a make target for darwin-arm64 and changes the original darwin target to darwin-amd64.

Might fix: #377

/kind chore

Signed-off-by: Lance Ball lball@redhat.com

Release Note

Added support for Apple M1 native binary

Might fix: knative#377

Signed-off-by: Lance Ball <lball@redhat.com>
@knative-prow knative-prow bot added kind/chore size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 31, 2022
@knative-prow
Copy link

knative-prow bot commented Mar 31, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance

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

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 31, 2022
Makefile Outdated Show resolved Hide resolved
Signed-off-by: Lance Ball <lball@redhat.com>
@matejvasek
Copy link
Contributor

Note: to really support m1 we need make our images mult-arch.
This will work only if user elaborately set up amd64 docker deamon somehow.

@codecov
Copy link

codecov bot commented Mar 31, 2022

Codecov Report

Merging #932 (1e6990d) into main (06fe5c0) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #932   +/-   ##
=======================================
  Coverage   43.85%   43.85%           
=======================================
  Files          55       55           
  Lines        5163     5163           
=======================================
  Hits         2264     2264           
  Misses       2576     2576           
  Partials      323      323           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06fe5c0...1e6990d. Read the comment docs.

@lance
Copy link
Member Author

lance commented Mar 31, 2022

@matejvasek ty for the quick feedback. Do you think this is sufficient for #377? Do we need to care about any of the images? I'm thinking we don't but would like your thoughts.

@matejvasek
Copy link
Contributor

btw: will our OpenShift always run on amd64? Don't we support some power pc or sparc on server?

@lance
Copy link
Member Author

lance commented Mar 31, 2022

Note: to really support m1 we need make our images mult-arch. This will work only if user elaborately set up amd64 docker deamon somehow.

Can you elaborate? I don't really understand the issue here.

@lance
Copy link
Member Author

lance commented Mar 31, 2022

btw: will our OpenShift always run on amd64? Don't we support some power pc or sparc on server?

That's sounding familiar, but I'm not exactly sure.

@matejvasek
Copy link
Contributor

I think that for instance func build or func run won't work with podman machine (unless user forces amd64 emulation incurring huge overhead). Not sure about Docker Desktop.

@matejvasek
Copy link
Contributor

@lance you had to run docker on your Linux machine and connect to it to make it work on m1, right?

Makefile Show resolved Hide resolved
@lance
Copy link
Member Author

lance commented Mar 31, 2022

I think that for instance func build or func run won't work with podman machine (unless user forces amd64 emulation incurring huge overhead). Not sure about Docker Desktop.

Yes, I have had success on my new Mac with Docker Desktop.

@lance you had to run docker on your Linux machine and connect to it to make it work on m1, right?

Yep - or use a podman daemon on a remote linux machine.

@matejvasek
Copy link
Contributor

I think that for instance func build or func run won't work with podman machine (unless user forces amd64 emulation incurring huge overhead). Not sure about Docker Desktop.

But maybe qemu could save this somehow?

@matejvasek
Copy link
Contributor

I think that for instance func build or func run won't work with podman machine (unless user forces amd64 emulation incurring huge overhead). Not sure about Docker Desktop.

But maybe qemu could save this somehow?

But we would have to update the dock how to setup qemu.

@matejvasek
Copy link
Contributor

Shouldn't we also update Release Github Actions in this PR?

@matejvasek
Copy link
Contributor

Not all images are available for ARM64 architecture. You can add --platform linux/amd64 to run an Intel image under emulation. In particular, the mysql image is not available for ARM64. You can work around this issue by using a mariadb image.

However, attempts to run Intel-based containers on Apple silicon machines under emulation can crash as qemu sometimes fails to run the container. In addition, filesystem change notification APIs (inotify) do not work under qemu emulation. Even when the containers do run correctly under emulation, they will be slower and use more memory than the native equivalent.

In summary, running Intel-based containers on Arm-based machines should be regarded as “best effort” only. We recommend running arm64 containers on Apple silicon machines whenever possible, and encouraging container authors to produce arm64, or multi-arch, versions of their containers. We expect this issue to become less common over time, as more and more images are rebuilt supporting multiple architectures.

@matejvasek
Copy link
Contributor

Yes, I have had success on my new Mac with Docker Desktop.

So it works OOB?

@matejvasek
Copy link
Contributor

Not need to set up qemu & --platform linux/amd64 ?

Signed-off-by: Lance Ball <lball@redhat.com>
@matejvasek
Copy link
Contributor

@lance
Copy link
Member Author

lance commented Mar 31, 2022

Yes, I have had success on my new Mac with Docker Desktop.

So it works OOB?

Yes!

~/demo/viewer is 📦 v0.1.0 via  v16.14.0 took 1m6s
❯ func version --verbose
tip-06fe5c04-20220331T205736Z

~/demo/viewer is 📦 v0.1.0 via  v16.14.0
❯ func build
   🙌 Function image built: docker.io/lanceball/viewer:latest

~/demo/viewer is 📦 v0.1.0 via  v16.14.0 took 1m6s
❯ func run
Function started on port 8080
^C%

@matejvasek
Copy link
Contributor

Yes, I have had success on my new Mac with Docker Desktop.

So it works OOB?

Yes!

~/demo/viewer is 📦 v0.1.0 via  v16.14.0 took 1m6s
❯ func version --verbose
tip-06fe5c04-20220331T205736Z

~/demo/viewer is 📦 v0.1.0 via  v16.14.0
❯ func build
   🙌 Function image built: docker.io/lanceball/viewer:latest

~/demo/viewer is 📦 v0.1.0 via  v16.14.0 took 1m6s
❯ func run
Function started on port 8080
^C%

Interesting... do you have qemu installed?

@matejvasek
Copy link
Contributor

Also is it as fast as build on amd64?

@lance
Copy link
Member Author

lance commented Mar 31, 2022

Also is it as fast as build on amd64?

No it's painfully slow.

And to document some of our conversation that wasn't included here, it seems that Docker Desktop does use QEMU under the covers. When running a build, we can see it in action.

❯ ps -A | grep qemu
24626 ??        27:05.58 /Applications/Docker.app/Contents/MacOS/qemu-system-aarch64 -accel hvf -cpu host -machine virt,highmem=off -m 8092 -smp 5 -kernel /Applications/Docker.app/Contents/Resources/linuxkit/kernel -append page_poison=1 vsyscall=emulate panic=1 nospec_store_bypass_disable noibrs noibpb no_stf_barrier mitigations=off linuxkit.unified_cgroup_hierarchy=1   vpnkit.connect=tcp+bootstrap+client://192.168.65.2:61910/eb6f772a63113d6534a4c4c62dd8a6cd757390c2059bc83fe6790de2f5bb6726 vpnkit.disable=osxfs-data console=ttyAMA0 -initrd /Applications/Docker.app/Contents/Resources/linuxkit/initrd.img -serial pipe:/var/folders/9n/ypd708qn3h31j_3jy5zm78jr0000gn/T/qemu-console2824445817/fifo -drive if=none,file=/Users/lball/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw,format=raw,id=hd0 -device virtio-blk-pci,drive=hd0,serial=dummyserial -netdev socket,id=net1,fd=3 -device virtio-net-device,netdev=net1,mac=02:50:00:00:00:01 -vga none -nographic -monitor none
39399 ttys008    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox qemu

@matejvasek
Copy link
Contributor

Also is it as fast as build on amd64?

No it's painfully slow.

And to document some of our conversation that wasn't included here, it seems that Docker Desktop does use QEMU under the covers. When running a build, we can see it in action.

❯ ps -A | grep qemu
24626 ??        27:05.58 /Applications/Docker.app/Contents/MacOS/qemu-system-aarch64 -accel hvf -cpu host -machine virt,highmem=off -m 8092 -smp 5 -kernel /Applications/Docker.app/Contents/Resources/linuxkit/kernel -append page_poison=1 vsyscall=emulate panic=1 nospec_store_bypass_disable noibrs noibpb no_stf_barrier mitigations=off linuxkit.unified_cgroup_hierarchy=1   vpnkit.connect=tcp+bootstrap+client://192.168.65.2:61910/eb6f772a63113d6534a4c4c62dd8a6cd757390c2059bc83fe6790de2f5bb6726 vpnkit.disable=osxfs-data console=ttyAMA0 -initrd /Applications/Docker.app/Contents/Resources/linuxkit/initrd.img -serial pipe:/var/folders/9n/ypd708qn3h31j_3jy5zm78jr0000gn/T/qemu-console2824445817/fifo -drive if=none,file=/Users/lball/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw,format=raw,id=hd0 -device virtio-blk-pci,drive=hd0,serial=dummyserial -netdev socket,id=net1,fd=3 -device virtio-net-device,netdev=net1,mac=02:50:00:00:00:01 -vga none -nographic -monitor none
39399 ttys008    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox qemu

I think that one qemu process is ok it's aarch64, is there any other process that is amd64?

@matejvasek
Copy link
Contributor

Also is it as fast as build on amd64?

No it's painfully slow.
And to document some of our conversation that wasn't included here, it seems that Docker Desktop does use QEMU under the covers. When running a build, we can see it in action.

❯ ps -A | grep qemu
24626 ??        27:05.58 /Applications/Docker.app/Contents/MacOS/qemu-system-aarch64 -accel hvf -cpu host -machine virt,highmem=off -m 8092 -smp 5 -kernel /Applications/Docker.app/Contents/Resources/linuxkit/kernel -append page_poison=1 vsyscall=emulate panic=1 nospec_store_bypass_disable noibrs noibpb no_stf_barrier mitigations=off linuxkit.unified_cgroup_hierarchy=1   vpnkit.connect=tcp+bootstrap+client://192.168.65.2:61910/eb6f772a63113d6534a4c4c62dd8a6cd757390c2059bc83fe6790de2f5bb6726 vpnkit.disable=osxfs-data console=ttyAMA0 -initrd /Applications/Docker.app/Contents/Resources/linuxkit/initrd.img -serial pipe:/var/folders/9n/ypd708qn3h31j_3jy5zm78jr0000gn/T/qemu-console2824445817/fifo -drive if=none,file=/Users/lball/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw,format=raw,id=hd0 -device virtio-blk-pci,drive=hd0,serial=dummyserial -netdev socket,id=net1,fd=3 -device virtio-net-device,netdev=net1,mac=02:50:00:00:00:01 -vga none -nographic -monitor none
39399 ttys008    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox qemu

I think that one qemu process is ok it's aarch64, is there any other process that is amd64?

Actually that amd64 emulation would probably run withing the aarch64 qemu. So we cannot see it.

Copy link
Member

@lkingland lkingland left a comment

Choose a reason for hiding this comment

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

Just a couple of duplicate lines to remove in the (admitedly cryptic) make-fu

Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Signed-off-by: Lance Ball <lball@redhat.com>
@matejvasek
Copy link
Contributor

/lgtm
/hold

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 1, 2022
@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2022
@lance
Copy link
Member Author

lance commented Apr 1, 2022

/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 1, 2022
@knative-prow knative-prow bot merged commit 00d5a82 into knative:main Apr 1, 2022
salaboy pushed a commit to salaboy/kn-plugin-func that referenced this pull request Apr 14, 2022
* chore: add Apple M1 build in cross-platform target

Might fix: knative#377

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: review feedback/better names

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: adjust release workflow

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: remove duplicate

Signed-off-by: Lance Ball <lball@redhat.com>
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. kind/chore lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support aarch64 macOS
3 participants