-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime/race: __acrt_iob_func not defined building with -race on Windows #23649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In which directory are you running |
@ianlancetaylor anywhere can be possible.
|
Can you show us the output of The references may possibly be coming from runtime/race/race_windows_amd64.syso. |
|
@mattn are you sure? I cannot reproduce this:
Alex |
Yes, I found this on my Windows7. Now I'm on Windows10 and reproduce this. This is gcc version I use.
|
If I put following code on same directory,
|
The latest of gcc I have is version 5. How do I install 7.3.0 ? Thank you Alex |
I installed gcc 7.3.0 from https://github.com/Alexpux/MINGW-packages Yesterday, I updated mingw gcc using pacman command. And it seems that this problem disappears. I apologize for bothering you |
No worries. All is good. Alex |
I could reproduce this on my Windows 10. So I reopen this. |
Seems to be related on https://sourceforge.net/p/mingw-w64/mingw-w64/ci/af149abc81550de19a80fba0f9d0e89fe4d01f2f/ |
libgcc.a (which is placed at pointed by diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index bfff5209a6..9f18cfac50 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -528,6 +528,9 @@ func (ctxt *Link) loadlib() {
if p := ctxt.findLibPath("libmingw32.a"); p != "none" {
hostArchive(ctxt, p)
}
+ if p := ctxt.findLibPath("libmsvcrt.a"); p != "none" {
+ hostArchive(ctxt, p)
+ }
// TODO: maybe do something similar to peimporteddlls to collect all lib names
// and try link them all to final exe just like libmingwex.a and libmingw32.a:
/* Any idea to fix this? |
facing same issue |
I have the same issue. If it helps to have more logs, here are mine. This is the version of MinGW I am using on Windows 10. |
Workaround for this, try to add |
Can confirm this as well on windows 10, go 1.10.3 and gcc 8.1.0 x86_64 |
Having the same issue. @mattn 's workaround did not work for me. Windows 10 |
Seems to be related to golang/go#23649.
This is an attempt to work around golang/go#23649.
Seems to be related to golang/go#23649.
Also seeing this. Only effects tests that bring in cgo code Windows 10 Full GCC version info:
|
CC @dvyukov |
Not an entirely new data point, but, on Windows 7 with Go 1.11.4.
AFAICT, I only get it when not importing "C". |
I just downloaded x86_64-7.3.0-release-win32-seh-rt_v5-rev0.7z file from https://sourceforge.net/projects/mingw-w64/files/ The file contains
Seems to be working fine for me
Alex |
mingw64 compiler bundled on msys2
|
Hey! I know nothing about GCC. But mine has
Try find GCC similar to mine. Or download one from https://sourceforge.net/projects/mingw-w64/files/ See, if it works. Alex |
@mattn I managed to reproduce your problem, if I use internal linker:
Alex |
Ran into this issue recently when trying to build gdrive on Linux. Here's the build script that was used and the log. Was only able to fix it with @mattn's workaround above. Edited: To provide more stable links to these artifacts. |
I reproduce this error every time I try debugging a binary with a |
Applying workaround patch to ignore duplicate symbol to link. diff --git a/src/cmd/link/internal/loadpe/ldpe.go b/src/cmd/link/internal/loadpe/ldpe.go
index f08e1241a7..b02ffd0ceb 100644
--- a/src/cmd/link/internal/loadpe/ldpe.go
+++ b/src/cmd/link/internal/loadpe/ldpe.go
@@ -465,6 +465,7 @@ func readpesym(arch *sys.Arch, syms *sym.Symbols, f *pe.File, pesym *pe.COFFSymb
switch pesym.StorageClass {
case IMAGE_SYM_CLASS_EXTERNAL: //global
s = syms.Lookup(name, 0)
+ s.Attr |= sym.AttrDuplicateOK
case IMAGE_SYM_CLASS_NULL, IMAGE_SYM_CLASS_STATIC, IMAGE_SYM_CLASS_LABEL:
s = syms.Lookup(name, localSymVersion) And replace
Now I could generate |
Change https://golang.org/cl/190481 mentions this issue: |
Another solution is removing stderr from runtime/cgo/windows.c |
I do not understand. What exactly are you proposing? Thank you. Alex |
stdout/stdin/stderr is macro of __acrt_iob_func. So if remove using them, this error should be removed, I guess. |
We have no control over what other people do in their C code. They could include whatever headers they need. So this will not work. Alex |
Change https://golang.org/cl/197977 mentions this issue: |
Change https://golang.org/cl/203603 mentions this issue: |
So if the fix was reverted, should this be reopened? |
Change https://golang.org/cl/203603 has not been submitted yet. So the fix is still there. We are considering to use this copy of Mingw - http://musl.cc/x86_64-w64-mingw32-native.zip (see #35006 (comment) for details). If you are affected by this current issue, can you try this Mingw to see, if it fixes your problem? Thank you. Alex |
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.
|
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
)?What did you do?
What did you expect to see?
works
What did you see instead?
failed with following errors
The text was updated successfully, but these errors were encountered: