Skip to content

x/benchmarks/sweet: go-build failed when install cmd/compile and cmd/link #72920

Open
@Lslightly

Description

@Lslightly

Go version

go version go1.24.1 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='/usr/bin/gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='/usr/bin/g++'
GCCGO='gccgo'
GO111MODULE='auto'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/lqw/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/lqw/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build29922276=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD=''
GOMODCACHE='/home/lqw/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/lqw/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/home/lqw/golangs/go1.24.1'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/lqw/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/lqw/golangs/go1.24.1/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

First, my go environment is complex. I installed go1.22.0, go1.20.10 and go1.24.1. The GOPATH is always /home/lqw/go when using different go version.

  1. go build ./cmd/sweet under sweet directory.
  2. ./sweet get to get assests in zip format.
    1. Actually I got the zip file through gsutil cp gs://go-sweet-assets/assets-v0.3.0.zip $HOME/.cache/go-sweet command since sweet get does not provide a progress bar. I'm impatient and I have some network issues. So I have to download the zip file manually through gsutils, which provides a progress bar and shows the file size. I think sweet get can be improved here?
  3. run the command ./sweet run -run go-build -work-dir /data/sweet-work -shell config.toml with the following configuration.
[[config]]
    name = "baseline"
    goroot = "/home/lqw/golangs/go1.22.0"

What did you see happen?

(base) ➜  sweet git:(bd1e389) ✗ ./sweet run -run go-build -work-dir /data/sweet-work -shell config.toml
[sweet] Work directory: /data/sweet-work
[sweet] Benchmarks: go-build (20 runs)
[sweet] Setting up benchmark: go-build
[shell] mkdir -p /home/lqw/mygit/research/vm/go-bench/benchmarks/sweet/results/go-build
[shell] mkdir -p /data/sweet-work/go-build/baseline/bin
[shell] mkdir -p /data/sweet-work/go-build/src
[shell] mkdir -p /data/sweet-work/go-build/baseline/tmp
[shell] mkdir -p /data/sweet-work/go-build/baseline/assets
[shell] GOROOT=/data/sweet-work/go-build/baseline/bin/goroot GOFLAGS=-pgo=off /data/sweet-work/go-build/baseline/bin/goroot/bin/go install cmd/compile cmd/link
[sweet] error: build go-build for baseline: error building cmd/compile and cmd/link: exit status 1. stderr:
cmd/link: go install cmd/link: copying /tmp/go-build251656412/b189/exe/a.out: open /home/lqw/go/pkg/mod/golang.org/[email protected]/pkg/tool/linux_amd64/link: permission denied
cmd/compile: go install cmd/compile: copying /tmp/go-build251656412/b001/exe/a.out: open /home/lqw/go/pkg/mod/golang.org/[email protected]/pkg/tool/linux_amd64/compile: permission denied
[sweet] error: failed to execute benchmarks: go-build

What did you expect to see?

no permission denied error and successfully install cmd/compile and cmd/link.

I inspect how the error is thrown. I found that after changing Do("", ...) in sweet/harnesses/go-build.go#L113-L116 to Do(cfg.GoRoot, ...), the above error did not occur.

When I call GOROOT=/home/lqw/golangs/go1.22.0 GOFLAGS=-pgo=off /home/lqw/golangs/go1.22.0/bin/go install cmd/compile cmd/link in sweet directory directly in zsh, the same error occurs. But if I call the same command in /data/sweet-work/go-build/baseline/bin/goroot directory, no error occurs.

The go version of go.mod in commit bd1e389d5239692b3cdb5b40375bbfb507567f63 of https://github.com/golang/benchmarks is go1.23.0. That might be the reason why the tool is installed in 1.23.0 toolchain mod and go-build fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions