Race detector plus Cgo via binutils extld on arm64?

134 views
Skip to first unread message

neilschel...@gmail.com

unread,
Nov 19, 2021, 11:58:56 AM11/19/21
to golang-nuts
Hi Folks,

Can anyone comment on whether arm64 race detection plus Cgo (via gcc and binutils) is known to work or not?

I'm running in to a bunch of mechanical problems getting a binary linked, let alone running.  Unfortunately, we have unavoidable Cgo dependencies on a h/w support library.  I've gotten to the point where the final link is dying with some DWARF warnings and with some relocation errors relating to tsan symbols.

I don't want to pour too much more time into it if it is known to be a non-starter....

Regards,
Neil

Ian Lance Taylor

unread,
Nov 19, 2021, 3:13:26 PM11/19/21
to neilschel...@gmail.com, golang-nuts
As of Go 1.16 the Go race detector is supposed to work on linux-arm64
and darwin-arm64. This should work with cgo as well.

To be clear, this means building Go code (that can use cgo) with "go
build -race". Combining the Go race detector with the C race detector
(the C compiler -fsanitize=thread option) does not work.

Please feel free to report bugs at https://golang.org/issue with a
description of how we can reproduce the problem. Thanks.

Ian

Neil Schellenberger

unread,
Nov 23, 2021, 2:35:29 AM11/23/21
to Ian Lance Taylor, golang-nuts
Thank you very much, Ian, for your insight.

Unfortunately, after several more hours of fiddling, I still can't convince it to work.  I assume it's something to do with our (admittedly somewhat complicated) build environment/toolchain rather than a core Go problem, but I can't figure out what/how.  (Yocto SDK foisted on us by the hardware vendor....)

I raised https://github.com/golang/go/issues/49749 in the hope that someone smarter than me can provide me with the requisite smack upside the head....

I still get various undefined tsan symbols.  Presumably those are supposed to be resolved by the arm64 runtime?  (If it makes any difference, we're cross-compiling on amd64 for arm64 by setting GOARCH, CC, CGO_CFLAGS et al.  Unfortunately, it's not entirely trivial to build and run a native toolchain and Go distro on the hardware in question.)

I've made a rudimentary stab at hunting through the tmp build space to figure it out using `go build -race -work -a`, but it's slow going for a beginner....  FWIW I don't see any obvious signs of any tsan symbol defs in there.  (But of course, that may be entirely expected if the runtime module is handled specially/magically....  And, also, I may simply have missed them.  Or be barking up entirely the wrong tree.  In the wrong forest.)

Regards,
Neil

Neil Schellenberger

unread,
Nov 23, 2021, 12:38:04 PM11/23/21
to golang-nuts
I'd swear I checked for existing issues but somehow I missed https://github.com/golang/go/issues/49102.

That was the culprit.  Sorry for the noise.

I suspect I missed it because it's marked closed.  Hopefully something more overt will be done to spare future poor souls the grief?

.
Reply all
Reply to author
Forward
0 new messages