Skip to content
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

cmd/dist: toolchain3 fails in external linking mode due to stale targets #53865

Closed
erifan opened this issue Jul 14, 2022 · 6 comments
Closed
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. 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.
Milestone

Comments

@erifan
Copy link

erifan commented Jul 14, 2022

What version of Go are you using (go version)?

$ go version
tip

What did you do?

$ GO_LDFLAGS="-linkmode=external" ./make.bash

What did you expect to see?

Successfully build go

What did you see instead?

$ GO_LDFLAGS="-linkmode=external" ./make.bash
Building Go cmd/dist using /usr/lib/go-1.13. (go1.13.8 linux/amd64)
Building Go toolchain1 using /usr/lib/go-1.13.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
HASH[moduleIndex]
HASH[moduleIndex]: "devel go1.19-160414ca6a Tue Jun 28 21:01:39 2022 +0000"
HASH[moduleIndex]: "package devel go1.19-160414ca6a Tue Jun 28 21:01:39 2022 +0000 go index v0 /home/erifan02/go-master/src/runtime/internal/sys\n"
......
runtime/internal/sys true
go tool dist: unexpected stale targets reported by /home/erifan02/go-master/pkg/tool/linux_amd64/go_bootstrap list -gcflags="" -ldflags="-linkmode=external" for [cmd/asm cmd/cgo cmd/compile cmd/link runtime/internal/sys] (consider rerunning with GOMAXPROCS=1 GODEBUG=gocachehash=1):
STALE cmd/asm: stale dependency: internal/goarch
STALE cmd/cgo: stale dependency: internal/goarch
STALE cmd/compile: stale dependency: internal/goarch
STALE cmd/link: stale dependency: internal/goarch
STALE runtime/internal/sys: stale dependency: internal/goarch

@bcmills
Copy link
Contributor

bcmills commented Jul 14, 2022

Please fill out the complete issue template — what is the output of go env in your environment from a non-external build?

In addition, what toolchain and version are you using for the external linker? (Does this reproduce with both gcc and clang toolchains, or just one of the two, or just one specific version?)

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 14, 2022
@erifan
Copy link
Author

erifan commented Jul 15, 2022

$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/erifan02/.cache/go-build"
GOENV="/home/erifan02/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/erifan02/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/erifan02/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/erifan02/go-master"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/erifan02/go-master/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.19-160414ca6a Tue Jun 28 21:01:39 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3057986183=/tmp/go-build -gno-record-gcc-switches"

$ gcc -v

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

$ clang -v

Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I tried linux/amd64, linux/arm64, macos/arm64, gcc, clang, all of them will report this error.

@bcmills bcmills changed the title cmd/dist: fail to build go in external linking mode cmd/dist: toolchain3 fails in external linking mode on linux/amd64 due to stale targets Jul 15, 2022
@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jul 15, 2022
@bcmills bcmills added this to the Backlog milestone Jul 15, 2022
@bcmills bcmills changed the title cmd/dist: toolchain3 fails in external linking mode on linux/amd64 due to stale targets cmd/dist: toolchain3 fails in external linking mode due to stale targets Jul 15, 2022
@bcmills bcmills added the compiler/runtime Issues related to the Go compiler and/or runtime. label Oct 12, 2023
@bcmills
Copy link
Contributor

bcmills commented Oct 12, 2023

@erifan, I suspect that this may have been fixed by the work for reproducible toolchain builds in Go 1.21. Does it still reproduce for you?

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 12, 2023
@erifan
Copy link
Author

erifan commented Oct 13, 2023

@bcmills The error has changed to another one:

$ GO_LDFLAGS="-linkmode=external" ./make.bash
Building Go cmd/dist using /home/erifan02/go1.21.0. (go1.21.0 linux/amd64)
Building Go toolchain1 using /home/erifan02/go1.21.0.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
-linkmode=external requires external (cgo) linking, but cgo is not enabled
-linkmode=external requires external (cgo) linking, but cgo is not enabled
-linkmode=external requires external (cgo) linking, but cgo is not enabled
-linkmode=external requires external (cgo) linking, but cgo is not enabled
go tool dist: FAILED: /home/erifan02/go-master/pkg/tool/linux_amd64/go_bootstrap install -ldflags=all=-linkmode=external -pgo=off cmd/asm cmd/cgo cmd/compile cmd/link: exit status 1

@bcmills
Copy link
Contributor

bcmills commented Oct 13, 2023

Aha! That one seems like a reasonable failure mode to me. You have explicitly set GO_LDFLAGS to require external linking, but make.bash builds the toolchain with CGO_ENABLED=0 in order to provide reproducible binaries (see cmd/dist.toolenv), and those two goals are incompatible.

If you really want to build a cgo-enabled toolchain, you can run the default make.bash to bootstrap, and then go install cmd -ldflags=-linkmode=external to overwrite the installed installed toolchain binaries with cgo-enabled, externally-linked versions.

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Oct 13, 2023
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. 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.
Projects
None yet
Development

No branches or pull requests

3 participants