Replies: 9 comments 5 replies
-
Unfortunately this is a known issue, golang is not really stable when compiing under qemu user emulation. Cross-compiling (with GOOS/GOARCH) is much faster and more predictable, but does require tool support. Have you tried With the native (not emulated) go compiler for arm64, that is. |
Beta Was this translation helpful? Give feedback.
-
👍 That's the impression I got from reading the issues.
Yes, that is kind of the point. It is quite tedious to do this for multiple repositories, scripts, tools settings. It happens quite fast to get something wrong, like the base image is already stored, but in the wrong architecture, or building a binary using go cross-compilation that is different than the base image. Examples with GOOS/GOARCH: Without explicitly telling podman which architecture to use:
the user needs to get When explicitly defining it:
still breaks, even if the go binary already "would" be amd64 and the following
works, but now we have an amd64 binary based in arm64 base image. I get that this is not easy to fix (and probably also not on podman to fix it), but the current behaviour is pretty bad from an UX perspective and quite hard to explain to devs. We probably should have some documentation around this. |
Beta Was this translation helpful? Give feedback.
-
You probably want an arm64 builder image, and an amd64 result image. The go image is comparatively huge, so you don't want to ship that anyway...
And you can still use binfmt_misc, to execute unit tests etc with qemu-user EDIT: swapped architectures, I am used to building from Intel and to ARM |
Beta Was this translation helpful? Give feedback.
-
The crash is surprising, but it had probably cached the image from the last run `(docker didn't "know" about arch)
So if you do have some old images lingering, they need to be cleared up - or even use explicit arch digests instead. https://hub.docker.com/_/golang/tags?page=1&name=1.19-bullseye |
Beta Was this translation helpful? Give feedback.
-
Yes, that is what I meant with that example. The user has to catch the warning and "get" what is happening, then fix it by removing the existing image or use explicit tags.
Yeah, we use a multi-stage build anyways. That one was just for simplicity in the reproducer. So to summarise, yes it works, if the dev uses the right combination of GOOS/GOARCH combined with either explicit architecture tags in the FROM images or having the correct images lying around. I still think that is pretty bad UX for someone that just want to run a simple go build or just uses a build/test script/Makefile on mostly any OSS repository to do a PR. |
Beta Was this translation helpful? Give feedback.
-
Moved to a discussion as this does not look like a podman bug, instead something in qemu-user-static. |
Beta Was this translation helpful? Give feedback.
-
The brute force method is to give up on containers and use separate VMs (i.e. go from qemu-user to qemu-system), but Podman machine doesn't support that anymore... |
Beta Was this translation helpful? Give feedback.
-
I'm confused about the conclusions here. I'm trying to build a container images from my MacBook M2 (arm64) that runs a Golang application that will run on OpenShift (amd64) architecture. It seems we cannot use |
Beta Was this translation helpful? Give feedback.
-
For those looking how to do this you can use your native architecture and pass the |
Beta Was this translation helpful? Give feedback.
-
Issue Description
Building an amd64 image using podman on an ARM machine (Mac M1 Pro in my case), quite often results in segmentation fault (core dumped) at various places. This happens more often with more complex golang dependencies like kubernetes.
More details and reproducer here: https://github.com/ReToCode/golang-qemu-podman-reproducer
Steps to reproduce the issue
See https://github.com/ReToCode/golang-qemu-podman-reproducer
Describe the results you received
See github repo.
Describe the results you expected
Both builds should work equally.
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
MacBook Pro, M1 Pro
Additional information
I checked various issues here and in the golang repository (like golang/go#36981), but none of them really seem to match (or help) this exactly. Also I'm not super sure, if this is really a podman issue or an issue with building golang on QEMU.
If you need any additional info, you can also reach out to me on RH slack.
Beta Was this translation helpful? Give feedback.
All reactions