Skip to content

cmd/go: inferred GOAMD64 value in go env should be applied to build #73294

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

Open
bsdcode opened this issue Apr 9, 2025 · 3 comments
Open

cmd/go: inferred GOAMD64 value in go env should be applied to build #73294

bsdcode opened this issue Apr 9, 2025 · 3 comments
Labels
arch-amd64 GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@bsdcode
Copy link

bsdcode commented Apr 9, 2025

Go version

go version go1.24.1 freebsd/amd64

Output of go env in your module/workspace:

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

What did you do?

Example program:
go.mod:

module example

go 1.24.1

main.go

//go:build amd64.v3

package main

import "fmt"

func main() {
	fmt.Println("Example")
}

Observe the architecture feature GOAMD64='v3' in go env and the buildconstraint //go:build amd64.v3 in main.go. Now try to build the example program with go build.

What did you see happen?

$ go build
package example: build constraints exclude all Go files in /tmp/example

What did you expect to see?

A successfully build example program main.

The feature has to be given explicitly to satisfy the constraint:

$ GOAMD64=v3 go build
@seankhliao seankhliao changed the title go/build: unsatisfied buildconstraint on architecture feature set by go environment cmd/go: inferred GOAMD64 value in go env should be applied to build Apr 9, 2025
@randall77
Copy link
Contributor

What do echo $GOAMD64 and go env GOAMD64 print?

@seankhliao
Copy link
Member

and go env -changed

@bsdcode
Copy link
Author

bsdcode commented Apr 9, 2025

$ echo $GOAMD64

$ go env GOAMD64
v3

$ go env -changed
GOAMD64='v3'

@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go arch-amd64 labels Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-amd64 GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants