cmd/go, cmd/cgo: repeatable builds with Clang 3.8 #15405
Please answer these questions before submitting your issue. Thanks!
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/etiennebruines/workspaces/go" GORACE="" GOROOT="/home/etiennebruines/workspaces/go-master" GOTOOLDIR="/home/etiennebruines/workspaces/go-master/pkg/tool/linux_amd64" CC="clang" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build179019630=/tmp/go-build -gno-record-gcc-switches" CXX="g++" CGO_ENABLED="1" (Tested different versions of `clang` (with different results!), more info down below. )
It sounds like we just need to wait for clang and gcc to fix their reproducible build support.
Support for -fdebug-prefix-map was added Oct 2015. Clang 3.7.0 was released Sep 2015, Clang 3.7.1 was released Jan 2016, and Clang 3.8 was released Mar 2016. My guess is the change may have missed the Clang 3.7 point release but was likely in Clang 3.8. Without detecting support for the flag, the test is skipped. This is why we don't see failures before Clang 3.8.
The linux-amd64-clang gomote image is using Clang 3.5, so we don't test this case on the builder.
Support for -fdebug-prefix-map is more widespread, but some versions don't quite work. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69821 shows that while -fdebug-prefix-map did the right thing to the debug symbols, gcc then included that option in the DW_AT_producer field of the dwarf. If the goal of -fdebug-prefix-map=old=new is to eliminate the string "old" from the binary, writing down that option into the binary defeats the purpose. The bug entry says the target milestone is gcc 6 and the discussion there sounds like the decision was not to backport to gcc 5. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=819176, the Debian entry for this bug, suggests it is fixed in Debian's gcc 5.4.0. It is unclear whether that means the fix is only in Debian's copy or is upstream. It's unclear to me when DW_AT_producer first started recording the whole command line.
Obviously the tests do pass on our gcc builders, and I confirmed that (unlike the clang builder) the gcc on the builder does support the flag, so the test should be running. Perhaps gcc 4.3 had a related problem.
This is working for me:
The builders are on clang 3.9 and it's working there too. Going to assume this is now fixed and that the problem before was that either the specific clang 3.8 being used didn't have -fdebug-prefix-map or did not implement it correctly.