golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.92k stars 17.52k forks source link

runtime: multi-arch build via qemu fails to exec go binary #68976

Open bjohnso5 opened 4 weeks ago

bjohnso5 commented 4 weeks ago

Go version

go version 1.23.0 linux/arm64

Output of go env in your module/workspace:

I'm unable to provide the output of `go env` as it fails with the same telemetry fork/exec error.

What did you do?

Our automated image build process fails to perform any step that invokes the go binary with the following error:

can't start telemetry child process: fork/exec /usr/local/go/bin/go: invalid argument

The Dockerfile is here, and is being built via a script that invokes docker buildx with multiple platforms, like:

docker buildx build --platform=linux/amd64,linux/arm64 --file 1.23/Dockerfile

It seems that there is something inherent in the qemu arm64 environment that renders go unable to fork itself to complete the telemetry setup. I'm fairly confident it's something specific to the 1.23 release as 1.22.6 builds successfully using the same setup today.

What did you see happen?

Failures to invoke any go command

What did you expect to see?

A successful install and configuration of go 1.23.0 in a multi-arch docker build.

samstride commented 5 days ago

@prattmic , I tried this:

# Debian 12 with go 1.23.1
FROM golang:1.23.1

RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest && \
    go install github.com/securego/gosec/v2/cmd/gosec@latest && \
    go install golang.org/x/vuln/cmd/govulncheck@latest

The pipeline step with tonistiigi/binfmt:qemu-v8.1.5 looks like this:

build-golang:
  stage: build
  image: docker:latest
  services:
    - name: docker:dind
  script:
    - docker run --privileged --rm tonistiigi/binfmt:qemu-v8.1.5 --install all
    - docker context create multiarch-build
    - docker buildx create multiarch-build --name multiarch --driver docker-container --bootstrap --use
    - docker buildx build --push --platform linux/amd64,linux/arm64 -f Dockerfile.golang -t some-tag .

And I get this error during the multi-arch build:

error obtaining buildID for go tool compile: fork/exec /usr/local/go/pkg/tool/linux_arm64/compile: invalid argument