Skip to content

The 'GOARCH'/'GOHOSTARCH' changed from 'amd64' to '386' in golang:1.21-alpine3.18 #481

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

Closed
GaoJianAllen opened this issue Aug 9, 2023 · 3 comments

Comments

@GaoJianAllen
Copy link

I am very happy to see go1.21 released yesterday!
I can't wait to upgrade my base image which is golang:1.21-alpine3.18.
However, something wrong, my CICD broken.

I checked my code and found the GOARCH changed from 'amd64' to '386'.
I read golang release notes and I can't find the reason for the change.

➜ ~ docker run -it golang:1.21-alpine3.18
/go # go env GOHOSTARCH
386
/go # go env GOARCH
386
/go #

@GaoJianAllen GaoJianAllen changed the title The 'GOARCH'/'GOHOSTARCH' changed from 'amd64' to '386' The 'GOARCH'/'GOHOSTARCH' changed from 'amd64' to '386' in golang:1.21-alpine3.18 Aug 9, 2023
@GaoJianAllen
Copy link
Author

GaoJianAllen commented Aug 9, 2023

go1.20 works well:

export GOAMD64='v1' GOARCH='amd64' GOOS='linux'; \

But go1.21 changed:

url='https://dl.google.com/go/go1.21.0.linux-amd64.tar.gz'; \

@racingmars
Copy link

This is also the case for the golang:1.21.0, golang:1.21.0-bullseye, and goland:1.21.0-bookworm (e.g. all the Debian-based) images.

This broke our product build when we upgraded to using the 1.21.0 image to build; it produces an i386 binary instead of an x86_64 binary. We can work around it by setting GOARCH=x86_64 variable in our build to cross-compile, but I wonder if this change was accidental.

@yosifkit
Copy link
Member

yosifkit commented Aug 9, 2023

This is because Docker helpfully pulled the first architecture available that your system could run, the i386 image, because the amd64 image was not available yet. So, this is a duplicate of #480 and #482.

The change in the Dockerfile is irrelevant; Go upstream now provides compiled binaries that work on Alpine, so we don't have to compile it (#474).

The images are available now:

$ docker pull --platform=linux/amd64 golang:1.21-alpine
1.21-alpine: Pulling from library/golang
7264a8db6415: Pull complete
c4d48a809fc2: Pull complete
4f1c88b9dad5: Pull complete
ad3a456e5733: Pull complete
Digest: sha256:445f34008a77b0b98bf1821bf7ef5e37bb63cc42d22ee7c21cc17041070d134f
Status: Downloaded newer image for golang:1.21-alpine
docker.io/library/golang:1.21-alpine
$ docker run -it --rm golang:1.21-alpine
/go # env
HOSTNAME=daef19d37a59
SHLVL=1
HOME=/root
TERM=xterm
PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GOPATH=/go
PWD=/go
GOLANG_VERSION=1.21.0
/go # go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3518816536=/tmp/go-build -gno-record-gcc-switches'

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

3 participants