Description
What version of Go are you using (go version
)?
$ go version go version go1.21.0 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ /usr/lib/go/bin/go envGO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/g4s8/.cache/go-build'
GOENV='/home/g4s8/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/g4s8/go/pkg/mod'
GOOS='linux'
GOPATH='/home/g4s8/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
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 -pthread -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4273986275=/tmp/go-build -gno-record-gcc-switches'
What did you do?
I'm trying to build go 1.21.0 from sources for Void Linux go
package: https://github.com/void-linux/void-packages
The steps to build it (inside go
repo directory):
unset GCC CC CXX LD CFLAGS
unset CGO_CXXFLAGS CGO_ENABLED
export GOROOT_FINAL=/usr/lib/go
export GOROOT=$PWD
export GOARCH=amd64
cd src
bash make.bash -v
sudo rm -f /usr/bin/go
sudo rm -fr /usr/lib/go/
sudo cp ../bin/* -t /usr/bin
sudo cp -r .. /usr/lib/go
What did you expect to see?
When running /usr/bin/go version
(or any other go
command, like go build
, etc) to see
go version go1.21.0 linux/amd64
What did you see instead?
When running go
command or /usr/bin/go
:
$ go version
go: cannot find GOROOT directory: 'go' binary is trimmed and GOROOT is not set
$ go build
go: cannot find GOROOT directory: 'go' binary is trimmed and GOROOT is not set
If I run /usr/lib/go/bin/go
, then all commands works fine:
$ /usr/lib/go/bin/go version
go version go1.21.0 linux/amd64
If I run exactly the same build commands for go version 1.20.7, it's working fine:
$ go version
go version go1.20.7 linux/amd64
or
$ /usr/bin/go version
go version go1.20.7 linux/amd64
Activity
[-]GOROOT_FINAL environment doesn't work for go1.21.0[/-][+]cmd/go: `GOROOT_FINAL` doesn't work for go1.21.0[/+]mknyszek commentedon Aug 10, 2023
CC @bcmills @matloob via https://dev.golang.org/owners
[-]cmd/go: `GOROOT_FINAL` doesn't work for go1.21.0[/-][+]cmd/dist: `GOROOT_FINAL` doesn't work for go1.21.0[/+]bcmills commentedon Aug 10, 2023
This is almost certainly a consequence of https://go.dev/cl/463740 (for #24904).
When built with
-trimpath
, thego
command usesos.Executable
to find itsGOROOT
, expecting that it is installed at$GOROOT/bin/go
, and lots of Go programs (especially tests) expect to be able to find thego
command at that location (from a configuration that gives only aGOROOT
path).@g4s8, is there a reason your script is using
cp
to make copies of the binaries inGOROOT/bin
, instead of usingln
to make/usr/bin/go
a symbolic link? It seems like that would be a simpler solution, and would allow the Go toolchain installed on Void Linux to use the same reproducible binaries that are distributed through the Go project.[-]cmd/dist: `GOROOT_FINAL` doesn't work for go1.21.0[/-][+]cmd/dist: tools built with `GOROOT_FINAL` cannot locate it when copied to another location[/+]bcmills commentedon Aug 10, 2023
I wonder if we should change
cmd/dist
to omit the-trimpath
flag whenGOROOT_FINAL
is set.(But I would still recommend not setting it, and using symlinks instead. 🤷♂️)
40 remaining items