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

gcc segmentation fault when building with CGO_ENABLED=1 and GOEXPERIMENT=boringcrypto #547

Closed
matheuscscp opened this issue Jan 29, 2025 · 4 comments

Comments

@matheuscscp
Copy link

Hi, I have a Go program that builds fine on both linux/amd64 and linux/arm64 when using golang:1.23.4-bookworm as base, but when bumping to golang:1.23.5-bookworm I'm getting this error:

#35 [linux/arm64 builder 11/12] RUN go build -ldflags "-linkmode=external -extldflags=-static -w" -o /controller -trimpath main.go
#35 232.4 # crypto/internal/boring
#35 232.4 gcc: internal compiler error: Segmentation fault signal terminated program cc1
#35 232.4 Please submit a full bug report, with preprocessed source (by using -freport-bug).
#35 232.4 See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
#35 ERROR: process "/bin/sh -c go build -ldflags \"-linkmode=external -extldflags=-static -w\" -o /controller -trimpath main.go" did not complete successfully: exit code: 1

And this happens only in linux/arm64. For linux/amd64 it builds fine.

This is the relevant part of the Dockerfile:

ENV CGO_ENABLED=1
ENV GOEXPERIMENT=boringcrypto

RUN go build -ldflags "-linkmode=external -extldflags=-static -w" -o /controller -trimpath main.go

Any ideas? 🙏

@LaurentGoderre
Copy link
Member

Could it be related to golang/go#65321 (comment)

@matheuscscp
Copy link
Author

I think it's actually tonistiigi/binfmt#215

@yosifkit
Copy link
Member

If it is a qemu user-mode issue, then there is nothing we can do from the image.

I recommend building on the target architecture, for example GitHub's arm64 runners, AWS graviton, or similar. And if you don't have access to an arm64v8 host, then even a full qemu system emulation VM is less likely to run into these user-mode issues.

@tianon
Copy link
Member

tianon commented Jan 29, 2025

You could also try cross-compilation, which normally works pretty well. The complication here is the cgo involved, but Debian has cross-compilers available, so even that's pretty solvable. See https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ for more about that.

@tianon tianon closed this as completed Feb 15, 2025
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

No branches or pull requests

4 participants