title: Build error using golang race detector
body: <p>My software compiles and runs fine but when I add the -race option to check for race conditions it does not build:</p>
  
  <pre><code>GOROOT=C:\Go
  
  GOPATH=&lt;deleted&gt;;D:\Golang
  
  C:\Go\bin\go.exe build -race -o C:\Users\Andrewp\AppData\Local\Temp\___1Race_Detector.exe -gcflags "-N -l" -a &lt;deleted&gt;
  
  # 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
  </code></pre>
  
  <p>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.</p>
  
  <p>Also I am building with GoLand (under Windows 10) but I get the same problem when I build from the command line.</p>
  
  <p>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?</p>
  
  <p>Extra info:
  I can build fine from the terminal using:</p>
  
  <blockquote>
    <p>go build -race</p>
  </blockquote>
  
  <p>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:</p>
  
  <blockquote>
    <p>go build -race -a .</p>
  </blockquote>
  
  <p>But this is OK:</p>
  
  <blockquote>
    <p>go build -a .</p>
  </blockquote>