使用Golang竞赛检测器生成错误

My software compiles and runs fine but when I add the -race option to check for race conditions it does not build:

GOROOT=C:\Go

GOPATH=<deleted>;D:\Golang

C:\Go\bin\go.exe build -race -o C:\Users\Andrewp\AppData\Local\Temp\___1Race_Detector.exe -gcflags "-N -l" -a <deleted>

# runtime/cgo

gcc_libinit_windows.c: In function 'x_cgo_sys_thread_create':
gcc_libinit_windows.c:56:12: error: implicit declaration of function '_beginthread' [-Werror=implicit-function-declaration]
  thandle = _beginthread(func, 0, arg);
            ^
cc1: all warnings being treated as errors

Compilation finished with exit code 2

Note that it worked previously but I have since upgraded to go version go1.9.2 windows/amd64 (though I don't think that is related). Also have MSYS installed.

Also I am building with GoLand (under Windows 10) but I get the same problem when I build from the command line.

Does anyone have info on how the Go compiler works esp. when using race detector or cgo, so I can track down the cause of this?

Extra info: I can build fine from the terminal using:

go build -race

It seems that the problem is caused by the -a option that GoLand added to the command line since this almost identical command line fails:

go build -race -a .

But this is OK:

go build -a .

Details are in this issue. A workaround is usually to set -vet=off