Why gollvm not support race detector?

116 views
Skip to first unread message

Yuan Ting

unread,
Aug 7, 2020, 2:32:37 AM8/7/20
to golang-nuts
Hi,
I know from README that gollvm does not support race detector. Is there any technical problem? Is it possible to use ThreadSanitizer in LLVM to implement a workaround race detector in gollvm?

Thanks.
Ting

Ian Lance Taylor

unread,
Aug 7, 2020, 12:36:54 PM8/7/20
to Yuan Ting, golang-nuts
On Thu, Aug 6, 2020 at 11:33 PM Yuan Ting <yuan...@ict.ac.cn> wrote:
>
> I know from README that gollvm does not support race detector. Is there any technical problem? Is it possible to use ThreadSanitizer in LLVM to implement a workaround race detector in gollvm?

ThreadSanitizer knows a great deal about the behavior of C library
functions. In order to use it with GoLLVM, it would be necessary to
teach it about the behavior of Go library functions. This is not
impossible--the same work was done for the Go race detector--but
somebody would have to do the work.

Ian

Ting Yuan

unread,
Aug 11, 2020, 5:01:59 AM8/11/20
to golang-nuts
Thanks for your reply,

If I'm not confused, the implementation of Go race detector is written in go/src/runtime/race.go and its TSAN implementation (in C/C++) is dynamic linked to target programs by a shared library. Could I simply add race.go to gofrontend then link the target programs by the TSAN shared library to make the race detector enabled? I know integrating the race detector to gccgo/gollvm can't be done as easily as the aforementioned method, but what problems will I encounter when I do this.

Thanks, Ting

Than McIntosh

unread,
Aug 11, 2020, 7:57:51 AM8/11/20
to Ting Yuan, golang-nuts
>>Could I simply add race.go to gofrontend then link the target programs by the TSAN shared library to make the race detector enabled?

The race detector implementation also includes a compiler component (look for flag_race in the cmd/compile source code), so that would have to be ported to gccgo as well, since gccgo uses an entirely different compiler implementation. There are probably other things as well that would have to be pulled in.

Than

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/c6d696b5-4918-4926-9068-ff3cd2ae1118o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages