Skip to content

fix apple silicon local scanner build #1038

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

Merged
merged 5 commits into from
Jan 3, 2023

Conversation

dcaravel
Copy link
Contributor

@dcaravel dcaravel commented Dec 21, 2022

Fixes build (make image) errors on Apple Silicon Macs.

The hardcoded BUILD_IMAGE for arm64 in Makefile has go version 1.17.2 which fails to build the latest scanner binary (most errors related to introduction of generics). A newer version of the apollo-ci-scanner-build-X-arm64 image does not exist in the sandbox repo - it's unclear how the sandbox repo is updated

Removing the hardcode and letting make build use the amd64 build image succeeds when combined with fixing a bug in the IMAGE_BUILD_FLAGS environment flags. This is a temporary fix as it relies on qemu emulation during build which has known issues:

Some images do not support the ARM64 architecture. You can add --platform linux/amd64 to run (or build) an Intel image using emulation.

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.

The locally built scanner and scanner-db images are built for the arm64 architecture - as a result the qemu known issues should have no/minimal impact on scanner/scanner-db at runtime.

@ghost
Copy link

ghost commented Dec 21, 2022

Images are ready for the commit at 0e66650.

To use the images, use the tag 2.27.x-17-g0e66650498.

Copy link
Contributor

@vladbologa vladbologa left a comment

Choose a reason for hiding this comment

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

Unfortunately the builder images for arm64 are not built automatically by CI. So far they were built and uploaded manually to sandbox by @connorgorman.

I have a temporary workaround for this issue here #1040, if you'd still prefer to use the native builder image.

We will soon have to build arm64 images for Go v1.19. I have built them before btw, I just don't know how to upload them to sandbox.

Co-authored-by: Vlad Bologa <vbologa@redhat.com>
@dcaravel dcaravel merged commit 0ff7bb3 into master Jan 3, 2023
@dcaravel dcaravel deleted the dcaravel/image-build-apple-m1-fix branch January 3, 2023 19:42
@@ -44,7 +45,7 @@ endif

LOCAL_VOLUME_ARGS := -v$(CURDIR):/src:delegated -v $(GOPATH):/go:delegated
GOPATH_WD_OVERRIDES := -w /src -e GOPATH=/go
IMAGE_BUILD_FLAGS := -e CGO_ENABLED=0,GOOS=linux,GOARCH=${GOARCH}
Copy link
Collaborator

Choose a reason for hiding this comment

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

In case you were wondering why this was never caught: Scanner was (and still is) traditionally built in a amd64 linux container, so GOOS and GOARCH were set correctly anyway. Also, I think CGO_ENABLED defaults to 0 anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants