cmd/go: go build rebuilds standard library if PWD contained a symlink at toolchain build time #20630
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
What version of Go are you using (
go version
)?go version devel +504b8d15d6 Fri Jun 9 15:16:35 2017 +0000 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GORACE=""
GOROOT="/tmp/go-build/go"
GOTOOLDIR="/tmp/go-build-symlinked/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build462810260=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
(note that GOROOT and GOTOOLDIR don't match)
What did you do?
cd /tmp
mkdir go-build
ln -s go-build go-build-symlinked
cd go-build-symlinked
git clone https://github.com/golang/go
cd /tmp/go-build-symlinked/go/src
./make.bash
echo 'package main\nimport "fmt"\nfunc main() {fmt.Println("hello world")}' >| /tmp/hello.go
/tmp/go-build-symlinked/go/bin/go build -v /tmp/hello.go
What did you expect to see?
command-line-arguments
(meaning that only hello.go gets rebuilt)
What did you see instead?
runtime/internal/sys
runtime/internal/atomic
runtime
errors
internal/race
sync/atomic
internal/cpu
unicode/utf8
math
sync
io
syscall
strconv
reflect
time
internal/poll
os
fmt
command-line-arguments
indicating that all stdlib packages were rebuilt, resulting in a much slower build.
I bisected this to the following change:
b8c7fdd
https://go-review.googlesource.com/42533
This issue probably won't affect many people, you need to build the toolchain yourself and the build path must contain a symlink somewhere. But when it does happen the symptoms are rather confusing: very slow builds for no apparent reason.
I personally encountered this because I build the toolchain in a workspace that is symlinked into my homedir from another filesystem.
The text was updated successfully, but these errors were encountered: