go: runtime/race: __acrt_iob_func not defined building with -race on Windows

What version of Go are you using (go version)?

go version devel +6f37fee354 Wed Jan 31 22:12:10 2018 +0000 windows/amd64

Does this issue reproduce with the latest release?

No, maybe something wrong in recent commits.

What operating system and processor architecture are you using (go env)?

set GOARCH=amd64
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows

What did you do?

go test -race

What did you expect to see?

works

What did you see instead?

failed with following errors

runtime/cgo(.text): relocation target __acrt_iob_func not defined
runtime/cgo(.text): relocation target __acrt_iob_func not defined
runtime/cgo(.text): relocation target __acrt_iob_func not defined
runtime/cgo(.text): relocation target __acrt_iob_func not defined
runtime/cgo(.text): relocation target __acrt_iob_func not defined
runtime/cgo(.text): undefined: "__acrt_iob_func"
runtime/cgo(.text): undefined: "__acrt_iob_func"
runtime/cgo(.text): undefined: "__acrt_iob_func"
runtime/cgo(.text): undefined: "__acrt_iob_func"
runtime/cgo(.text): undefined: "__acrt_iob_func"

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 39 (25 by maintainers)

Commits related to this issue

Most upvoted comments

Workaround for this, try to add -ldflags="-linkmode=external" for build.

I reproduce this error every time I try debugging a binary with a -race argument for go tool in the GoLand IDE.

Can confirm this as well on windows 10, go 1.10.3 and gcc 8.1.0 x86_64

For anyone else who ends up here, I’ve used the excellent MinGW compiler collection bundle from @StephanTLavavej for building CGO stuff on Windows for years. It’s great, up-to-date, and it fixed this issue for me.

  1. Download from https://nuwen.net/mingw.html
  2. Unpack to C:\MinGW
  3. Add C:\MinGW\bin to PATH
  4. Profit.

Having the same issue. @mattn 's workaround did not work for me.

Windows 10 mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0 go version go1.10.3 windows/amd64