paulborile
(Paul Stephen Borile)
May 17, 2018, 11:42am
1
Hi, I’m trying to understand if it is possible to use -race for build/testrun while linking binary packages that use cgo : lookup at go build code there seems to be a requierement CGO_ENABLED=1 :
https://go.googlesource.com/go/+/refs/changes/33/22433/4/src/cmd/go/build.go#3660
but then there an exclusion during what seems to be a cgo related part :
https://go.googlesource.com/go/+/refs/changes/33/22433/4/src/cmd/go/build.go#952
like if linking cgo dependencies is disabled if the -race flag is true.
Anyone knows if binary packages + cgo are testable with -race ?
Thanks in advance
-Paul
calmh
(Jakob Borg)
May 17, 2018, 11:51am
2
I think the race detector should work even in the presence of cgo packages, but I’m not sure if it covers accesses done from C land.
-t race is something else though, and there I’m not sure. Although I would expect it to work.
Have you tried?
paulborile
(Paul Stephen Borile)
May 17, 2018, 12:50pm
3
Sorry, it was a typo for -race : looks like that -race works with a go source package (even if the package uses CGO) but does not when the packge is a binary one.
calmh
(Jakob Borg)
May 17, 2018, 1:14pm
4
That I can believe. The race detector adds instrumentation to the code when it compiles it. If it can’t compile it, that can’t happen.
paulborile
(Paul Stephen Borile)
May 17, 2018, 1:17pm
5
Is there a way to provide -race compiled binaries as a binary-package ? I tried to build the binary package using -race but this does not work.
calmh
(Jakob Borg)
May 17, 2018, 1:19pm
6
I’ve no idea, I’ve never used a binary package. But what would be the point? If a problem was detected it would point to the source, and require the source to understand, source which doesn’t exist.
paulborile
(Paul Stephen Borile)
May 17, 2018, 3:28pm
7
Consider a project with 100 packages and tests running after -race build. If one binary package prevents the whole suite from running in -race mode this might be perceived as a problem.
calmh
(Jakob Borg)
May 17, 2018, 4:50pm
8
Oh, certainly. I thought you were talking about being able to run race testing on the binary package.
In general, binary packages are not a well supported thing.
system
(system)
Closed
August 15, 2018, 4:50pm
9
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.