Go version

go1.22.7 WASM build not reproducible

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='wasm'
GOBIN=''
GOCACHE='/Users/<name>/Library/Caches/go-build'
GOENV='/Users/<name>/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/<name>/go/pkg/mod'
GONOPROXY='github.com/smartcontractkit/chainlink-dev'
GONOSUMDB='github.com/smartcontractkit/chainlink-dev'
GOOS='wasip1'
GOPATH='/Users/<name>/go'
GOPRIVATE='github.com/smartcontractkit/chainlink-dev'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/<name>/sdk/go1.22.7'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/<name>/sdk/go1.22.7/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.7'
GCCGO='gccgo'
GOWASM=''
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/Users/<name>/go/src/github.com/smartcontractkit/chainlink-common/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/nx/ky9rn7kd0v56h5kz679cfqy00000gn/T/go-build4181679374=/tmp/go-build -gno-record-gcc-switches'

What did you do?

This shell scrip was used to create a WASM binary that a test relies on.

I attempted to ensure that all the environment variables are identical so that the build is reproducible, but the WASM binaries differ. This discrepancy causes CI to fail because it detects the file as not being generated in the PR.

We need the build to be reproducible so we can use the hash as an identifier for the WASM binaries. I noticed that GOGCCFLAGS differs between my machine and the CI machine, but since CGO_ENABLED=0 and it’s WASM, I expected that to be irrelevant. I also tried setting the variable directly, but go env didn’t show it respecting the flags.

I’ve attached the output from go env on both my machine and the CI machine, as captured by the shell script.

Note: I’ve redacted my name from my go env.

env.mine.txt env.pr.txt

What did you see happen?

When make generate is run in the PR, causing go generate to run the shell script, the produced binary is different than the one generated on my local machine. I've also had others attempt to generate the WASM, but theirs was different again.

What did you expect to see?

A reproducible build.

Comment From: gabyhelp

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: seankhliao

consider flags like -trimpath.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions