How Go Build and test create file lists needed for compile, build and link when CGO is enabled

51 views
Skip to first unread message

Mahdi Hosseini

unread,
Aug 4, 2020, 2:48:22 PM8/4/20
to golang-nuts
Hi,
I have a problem when trying to run the test for runtime when CGO is enabled. The test I want to run is CGO_ENABLED=1 go test -run=TestCgoSignalDeadlock inside src/runtime of the goroot. This test on my machine never compile the c files and hence led to link problem while my other CGO program build and run perfectly.
I try to run the test using -x -work command to see the details and I found out that for some reason the test never compile the c file inside src/runtime/cgo. As I checked the CGO_ENBALED=1 pass to the build command.
I am using Clang instead of gcc and all of my CGO project compiled without problem except this test.
I want to know how go create the list of file needed to be compiled and linked and why src/runtime/cgo directory was excluded while I have both build tag for CGO and import "C".

Regards,

Ian Lance Taylor

unread,
Aug 4, 2020, 9:10:30 PM8/4/20
to Mahdi Hosseini, golang-nuts
The test TestCgoSignalDeadlock runs the go command itself to build
another program, then runs that program. When you use -x you are
seeing the way that the runtime test itself is built; that test is not
expected to use cgo or build runtime/cgo. That isn't showing you
anything about the commands that the test uses to build the program it
is going to run. The easiest way to see those commands will probably
be to edit buildTestProg in runtime/crash_test.go.

Ian
Reply all
Reply to author
Forward
0 new messages