Skip to content

go/build: default Context.ToolTags doesn't contain GOAMD64 setting from user config file #72791

Closed as not planned
@lersek

Description

@lersek

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

$ go version
go version devel go1.25-73fea035bf1e Tue Mar 11 07:51:38 2025 -0700 linux/amd64

Does this issue reproduce with the latest release?

The reproducer is even more recent than the latest release (commit 73fea03 is the current HEAD of the master branch).

I originally encountered the symptom with my distro's go (go version go1.22.9 (Red Hat 1.22.9-2.el9_5) linux/amd64), but the problem reproduces with current upstream, too. The bug is being reported with go bug from upstream (at commit 73fea03).

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v2'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/lacos/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/lacos/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1652133164=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/lacos/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/lacos/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/lacos/src/upstream/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/lacos/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/lacos/src/upstream/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.25-73fea035bf1e Tue Mar 11 07:51:38 2025 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'
GOROOT/bin/go version: go version devel go1.25-73fea035bf1e Tue Mar 11 07:51:38 2025 -0700 linux/amd64
GOROOT/bin/go tool compile -V: compile version devel go1.25-73fea035bf1e Tue Mar 11 07:51:38 2025 -0700
uname -sr: Linux 5.14.0-503.26.1.el9_5.x86_64
/lib64/libc.so.6: GNU C Library (GNU libc) stable release version 2.34.

What did you do?

$ go env -w GOAMD64=v2
$ go env | grep -w GOAMD64
$ go run tooltags.go

where tooltags.go is

package main

import (
        "fmt"
        "go/build"
)

func main() {
        fmt.Println(build.Default.ToolTags)
}

What did you expect to see?

GOAMD64='v2'
[goexperiment.regabiwrappers goexperiment.regabiargs goexperiment.aliastypeparams goexperiment.swissmap goexperiment.spinbitmutex goexperiment.synchashtriemap amd64.v1 amd64.v2]

What did you see instead?

GOAMD64='v2'
[goexperiment.regabiwrappers goexperiment.regabiargs goexperiment.aliastypeparams goexperiment.swissmap goexperiment.spinbitmutex goexperiment.synchashtriemap amd64.v1]

The amd64.v2 tool tag is missing from build.Default.ToolTags.

Note that if I pass GOAMD64=v2 as an environment variable (i.e., not through my environment file /home/lacos/.config/go/env), then the result is as expected.

This issue breaks ABI level checks such as

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions