When I first tried to do this, I got
~/restic-1999> env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 ~/go_1_14/go/bin/go build -a -race -ldflags "-s -w" -tags "debug selfupdate" -o /tmp/restic_1999_nocgo ./cmd/restic
go build: -race requires cgo; enable cgo by setting CGO_ENABLED=1
~/restic-1999> env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 ~/go_1_14/go/bin/go build -a -race -ldflags "-s -w" -tags "debug selfupdate" -o /tmp/restic_1999_nocgo ./cmd/restic
runtime: mlock of signal stack failed: 12
runtime: increase the mlock limit (ulimit -l) or
runtime: update your kernel to 5.3.15+, 5.4.2+, or 5.5+
fatal error: mlock failed
<runtime stack>
That led me to these GitHub issues: runtime: mlock of signal stack failed: 12 · Issue #37436 · golang/go · GitHub , runtime: memory corruption on Linux 5.2+ · Issue #35777 · golang/go · GitHub and this kernel issue: 205663 – AVX register corruption from signal delivery (“AVX register corruption from signal delivery”). I’m on kernel version 5.3.1 so it seems very plausible this is causing all the issues. The test program in the bugzilla triggers the corruption on my machine.
Unless you’d prefer to pursue other avenues, I’ll upgrade my kernel and re-test restic
.