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

x/tools/go/packages: loading should report error when use custom GOROOT #69606

Closed
xieyuschen opened this issue Sep 24, 2024 · 3 comments
Closed
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@xieyuschen
Copy link
Contributor

xieyuschen commented Sep 24, 2024

Go version

(gotip) go version devel go1.24-7c72dc7 Mon Sep 23 05:36:30 2024 +0000 darwin/arm64

Output of go env in your module/workspace:

➜  tools git:(packages-should-report-error) gotip env
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/yuchen.xie/Library/Caches/go-build'
GOENV='/Users/yuchen.xie/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/yuchen.xie/sdk/gotip/pkg/mod'
GOOS='darwin'
GOPATH='/Users/yuchen.xie/sdk/gotip:/Users/yuchen.xie/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/yuchen.xie/sdk/gotip'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/yuchen.xie/sdk/gotip/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='devel go1.24-7c72dc7 Mon Sep 23 05:36:30 2024 +0000'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/yuchen.xie/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/yuchen.xie/workspace/ssa/tools/go.mod'
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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/28/7sypdf0519xfl4ylhq_90s0m0000gp/T/go-build1223724684=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Checkout to the first patch of CL 615396 and run gotip test ./go/packages -run ^TestIssue$.

What did you see happen?

The packages.Load doesn't report error while it doesn't load any packages.

--- FAIL: TestIssue (0.03s)
    stdlib_test.go:66: /Users/yuchen.xie/workspace/ssa/tools/go/packages/testdata
    stdlib_test.go:83: Expected to load 3 package under /Users/yuchen.xie/workspace/ssa/tools/go/packages/testdata but got 0
FAIL
FAIL    golang.org/x/tools/go/packages  0.293s
FAIL

What did you expect to see?

Actually, when packages.Load runs go list underlying, it reports go: no such tool "compile". I think it's better to report this error instead of returning nil.

GOROOT=/Users/yuchen.xie/workspace/ssa/tools/go/packages/testdata GOPATH=/Users/yuchen.xie/sdk/gotip:/Users/yuchen.xie/go GO111MODULE=on GOPROXY=https://proxy.golang.org,direct PWD=/Users/yuchen.xie/workspace/ssa/tools/go/packages go list -e -json=Name,ImportPath,Error,Dir,GoFiles,IgnoredGoFiles,IgnoredOtherFiles,CFiles,CgoFiles,CXXFiles,MFiles,HFiles,FFiles,SFiles,SwigFiles,SwigCXXFiles,SysoFiles,CompiledGoFiles,DepOnly,Imports,ImportMap,Export,Module -compiled=true -test=false -export=true -deps=true -find=false -pgo=off -- std

Stderr is:

go: no such tool "compile"
go: no such tool "compile"

By the way, this relates the CL 615016 when we want to migrate go/ssa/interp away from loader. We need call packages.Load to load some "mocked" standard libraries instead of the typical compiler's src libs under(go/ssa/interp/testdata/src) for interp to interpret the ssa main package. CC: @adonovan @timothy-king

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 24, 2024
@gopherbot gopherbot added this to the Unreleased milestone Sep 24, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/615396 mentions this issue: go/packages: report no tool 'compile' error when loading packages

@timothy-king
Copy link
Contributor

cc @matloob

@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants