在交叉编译时, cmd/dist: `{CC,CXX}_FOR_TARGET` 被错误嵌入到输出中
作者: GraysonTinker创建于 2026年9月28日更新于 2026年9月28日
Go version go version go1.26.7 linux/arm64 ### Output of go env in your module/workspace: shell AR='ar' CC='/nix/store/0hvd25jcaxcq45gkrgwqmd4gfqixg99h-aarch64-unknown-linux-gnu-gcc-wrapper-15.3.0/bin/aarch64-unknown-linux-gnu-cc' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_ENABLED='1' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' CXX='/nix/store/0hvd25jcaxcq45gkrgwqmd4gfqixg99h-aarch64-unknown-linux-gnu-gcc-wrapper-15.3.0/bin/aarch64-unknown-linux-gnu-c++' GCCGO='gccgo' GO111MODULE='' GOARCH='arm64' GOARM64='v8.0' GOAUTH='netrc' GOBIN='' GOCACHE='/home/graysontinker/.cache/go-build' GOCACHEPROG='' GODEBUG='' GOENV='/home/graysontinker/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFIPS140='off' GOFLAGS='' GOGCCFLAGS='-fPIC -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2578406192=/tmp/go-build -gno-record-gcc-switches' GOHOSTARCH='arm64' GOHOSTOS='linux' GOINSECURE='' GOMOD='/dev/null' GOMODCACHE='/home/graysontinker/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/graysontinker/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/nix/store/54yyhgzwghim2l37xy2qn9ihh4zwi2ps-go-aarch64-unknown-linux-gnu-1.26.7/share/go' GOSUMDB='sum.golang.org' GOTELEMETRY='local' GOTELEMETRYDIR='/home/graysontinker/.config/go/telemetry' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/nix/store/54yyhgzwghim2l37xy2qn9ihh4zwi2ps-go-aarch64-unknown-linux-gnu-1.26.7/share/go/pkg/tool/linux_arm64' GOVCS='' GOVERSION='go1.26.7' GOWORK='' PKG_CONFIG='pkg-config' ### What did you do? Cross-compile Go with this Nix derivation. This is mostly provided so you can see how the environment variables are being set. Then, attempt to compile a CGo program with the cross-compiled toolchain. ### What did you see happen? cgo: exec /nix/store/0hvd25jcaxcq45gkrgwqmd4gfqixg99h-aarch64-unknown-linux-gnu-gcc-wrapper-15.3.0/bin/aarch64-unknown-linux-gnu-cc: fork/exec /nix/store/0hvd25jcaxcq45gkrgwqmd4gfqixg99h-aarch64-unknown-linux-gnu-gcc-wrapper-15.3.0/bin/aarch64-unknown-linux-gnu-cc: exec format error ### What did you expect to see? The embedded C compiler location should remain the default unless overridden by a CC_FOR_$GOOS_$GOARCH environment variable. This seemingly occurs because the output build.go:compilerEnv is used for both building the binary (possibly correctly?) …
内容来源: golang/go