if you've been using qemu emulation to do your whole build in a different architecture like this
docker buildx build --platform=linux/amd64 -t whatever .
and you've been getting a segmentation fault at some point like this,
> [builder 4/4] RUN CGO_ENABLED=0 go build -ldflags '-w -extldflags "-static"' -o whatever ./cmd/whatever
#15 0.892 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#15 0.896 Segmentation fault
and your compiler supports cross-compilation (like the go compiler), you might be able to get around the issue with a multi-stage build. remove the explicit platform from the build command, cross-compile in the build stage on your default architecture, then copy the binary into the final stage on your target architecture
for example
FROM golang:alpine as builder
WORKDIR /build
ADD . .
# cross-compile here
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-w -extldflags "-static"' -o whatever ./cmd/whatever
# note this --platform= bit
FROM --platform=linux/amd64 alpine:latest
# do whatever
WORKDIR /opt/runtime
COPY --from=builder /build/whatever /opt/runtime/whatever
CMD /opt/runtime/whatever