-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/link: cgo linking fails on Windows with GCC 11.2.0 + MinGW-w64 9.0.0 (UCRT) from winlibs.com #51007
Comments
Do you have a sample program that reproduces this issue? |
any code that causes go-sqlite3 to compile is enough. |
I haven't dug in too far, but I suspect that the problem here is skew between the precompiled When we stop shipping precompiled object files (#47257) then version skew should no longer be an issue. @NewUserHa, in the meantime you may be able to work around the problem by installing Go from source. Could you give that a try and post the results? |
I don't have any toolchain for that except the only pre-build gcc compiler. so probably needs others to test |
You shouldn't need much else on top of the |
|
|
Thanks! Perhaps not surprisingly, many of those test failures are the same tests (but with different failure modes) as what @thanm observed in #35006 (comment). |
The failure mode for The link errors in |
Intriguingly, the string |
ok. |
No idea, but I would really like it to be fixed before Go 1.19 because I want to be able to test
That is tracked in #20982. It is currently milestoned |
thanks. |
I have a CL that should (in theory) take care of this problem, https://go-review.googlesource.com/c/go/+/382837. When I get that stack checked in (other parts still need work) I'll be sure to test this scenario (winlib + gosqlite). Thanks. |
see golang/go#51007 see docker#293 (comment) Signed-off-by: Sebastiaan van Stijn <[email protected]>
This message seems to happen in any program that uses featurs such as import "C" and import ' Here is a simple go file which will cause go build to fail with this error: `
` go build github.com/steowens/goWebviewC:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1 |
@steowens thanks for the note. Much work has been done on the Go linker's windows host object loading phase since this issue was filed last February. Things are better now on Go tip (e.g. the version about to be released as Go 1.20). I tested your example by hand using Go 1.20 RC1 and these compilers from winlibs.com, and things work ok for me. If you get a change, perhaps you can download the release candidate and try it yourself, see this email. |
Your compile/link recipe doesn't look right. In general for C++ programs it is not a viable strategy to invoke the linker directly -- one needs to invoke the C++ driver during the link stage, and then the C++ driver will run the linker passing the right flags and libraries. Here is an example (linux machine):
Try running the last command above with "-v" and you can see all of the various libraries being passed to the linker by the driver. Also want to add that the use of MSVC (e.g. cl.exe, link.exe) is something that is not supported/test by the Go team at the moment; I would recommend instead sticking with mingw-based compilers and linkers. |
@thanm Thank you for the quick reply! I tried to make it simpler, but you are right, we usually link through the compiler. I changed my build script for this repro to build and link with the compiler in one step, and I also added building with GCC (I also fixed the Go code, so it actually prints the string instead of the address, but it does not matter). new build.ps1
I get the following output: build.ps1 output
So, it still does not work with MSVC and Clang, but it works with GCC as one would expect. Is there any plan to extend the support to at least Clang & LLVM toolchain, if not MSVC? |
@AMDG2 you are using clang-cl.exe, which is the MSVC-compatible version of clang. Please use a mingw-based version of clang (such as https://github.com/mstorsjo/llvm-mingw) |
### Description Due to the latest `windows-2022` runner image no longer including a "built from source" Go binary, we're running into golang/go#51007 Luckily as of `1.20` Go is no longer shipping these precompiled object files so we will hopefully not run into the issues. ### Testing Instructions CI Closes TURBO-1344 --------- Co-authored-by: Chris Olszewski <Chris Olszewski>
This might also fix the CLI build for Windows: golang/go#51007
…y changes Apparently issues with stdio was fixed in Go 1.20. See golang/go#51007
…y changes Apparently issues with stdio was fixed in Go 1.20. See golang/go#51007
…y changes Apparently issues with stdio was fixed in Go 1.20. See golang/go#51007
…y changes Apparently issues with stdio was fixed in Go 1.20. See golang/go#51007
This commit updates the Windows CI job to use Go 1.19 instead of Go 1.18. See golang/go#51007.
This commit updates the Windows CI job to use Go 1.20 instead of Go 1.18. See golang/go#51007.
This also makes Windows pass tests again (fixed in Go 1.20: golang/go#51007) Signed-off-by: Brad Fitzpatrick <[email protected]>
This also makes Windows pass tests again (fixed in Go 1.20: golang/go#51007) Signed-off-by: Brad Fitzpatrick <[email protected]>
Original post: mattn/go-sqlite3#1012
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
maybe
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
import it
andgo build
orgo run .
What did you expect to see?
no output
What did you see instead?
The text was updated successfully, but these errors were encountered: