-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/6l: CGO program will only link with MinGW 4.8.1 on Windows #8811
Labels
Milestone
Comments
(attachment) Attachments:
|
The output is rather large? View it in full at http://pastebin.com/1niy3W2U C:\Users\stephen\Desktop\godev\src\mingwbug>go build -x ...trimmed by me... cd C:\Users\stephen\Desktop\godev\src\mingwbug "C:\\tipgoamd64\\pkg\\tool\\windows_amd64\\6g.exe" -o "C:\\Users\\stephen\\AppData\\Local\\Temp\\go-build954290891\\mingwbug.a" -t rimpath "C:\\Users\\stephen\\AppData\\Local\\Temp\\go-build954290891" -p mingwbug -complete -D _/C_/Users/stephen/Desktop/godev/sr c/mingwbug -I "C:\\Users\\stephen\\AppData\\Local\\Temp\\go-build954290891" -I "C:\\Users\\stephen\\Desktop\\godev\\pkg\\windows_a md64" -pack "C:\\Users\\stephen\\Desktop\\godev\\src\\mingwbug\\main.go" cd . "C:\\tipgoamd64\\pkg\\tool\\windows_amd64\\6l.exe" -o "C:\\Users\\stephen\\AppData\\Local\\Temp\\go-build954290891\\mingwbug\\_obj \\exe\\a.out.exe" -L "C:\\Users\\stephen\\AppData\\Local\\Temp\\go-build954290891" -L "C:\\Users\\stephen\\Desktop\\godev\\pkg\\wi ndows_amd64" -extld=gcc "C:\\Users\\stephen\\AppData\\Local\\Temp\\go-build954290891\\mingwbug.a" # mingwbug mingwbug/glfw(.text): mingwbug/glfw(/76): not defined mingwbug/glfw(.text): undefined: mingwbug/glfw(/76) |
Owner changed to @rsc. Status changed to Accepted. |
The form mingwbug/glfw(name) refers to the section name inside an object in mingwbug/glfw. The name /76 is a PE-encoded string table reference, since they only reserved 8 letters for the section name. $GOROOT/src/cmd/ld/ldpe.c needs to look for the /%d form of section name and do the appropriate translation to the correct section name. Labels changed: added release-go1.4, removed release-go1.4maybe. Owner changed to ---. |
There are 2 problems here as far as I can see (in ldpe.c): 1) section names are not read properly - that is why we see /76 in mingwbug/glfw(/76), /76 is a reference into "string table" where real name lives; 2) ldpe.c code assumes (in a few places) that all symbols with name starting with "." are section names - this is broken now that new gcc starts some symbols with ".". I am not familiar with that code enough to decide how to change it safely yet. But I will keep looking. Alex |
I had trouble finding latest gcc. http://nuwen.net/mingw.html is what I end-up using. Alex |
@Alex: http://mingw-w64.sourceforge.net/ - on Windows the easiest way is to use the mingw-builds distribution. |
@Alex Here's a 32-bit version: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.1/ Here's a 64-bit version: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.1/ If you go up to the parent folder, you'll find 4.8.1, 4.8.2, etc. as well. |
Interesting, there are more .rdata symbols on the 4.9.1 object file by the equivalent c code. e:\tmp>diff -uprN _cgo_export.o_good_481.sym _cgo_export.o_wrong_491.sym --- _cgo_export.o_good_481.sym Wed Oct 08 16:48:13 2014 +++ _cgo_export.o_wrong_491.sym Wed Oct 08 16:47:11 2014 @@ -6,7 +6,9 @@ 0000000000000000 N .debug_info 0000000000000000 N .debug_line 0000000000000000 p .pdata +0000000000000000 r .rdata$.refptr._cgoexp_9f48158d77e0_something 0000000000000000 r .rdata$zzz +0000000000000000 R .refptr._cgoexp_9f48158d77e0_something 0000000000000000 t .text 0000000000000000 r .xdata U _cgoexp_9f48158d77e0_something Jens |
e:\tmp>diff -uprN two_good_481.sym two_wrong_491.sym --- two_good_481.sym Wed Oct 08 17:49:32 2014 +++ two_wrong_491.sym Wed Oct 08 17:49:50 2014 @@ -7,7 +7,9 @@ 0000000000000000 N .debug_line 0000000000000000 N .debug_str 0000000000000000 p .pdata +0000000000000000 r .rdata$.refptr._glfwInitialized 0000000000000000 r .rdata$zzz +0000000000000000 R .refptr._glfwInitialized 0000000000000000 t .text 0000000000000000 r .xdata U _glfwInitialized If I replace two.o and _cgo_export.o with the 4.8.1 versions and build all manually then it will work. Now the question is: are the additional gcc .rdata sections wrong or has the 6l.exe a bug and should handle it right? Jens |
I think https://golang.org/issue/8856 is related to. |
I think https://golang.org/issue/8856 is related to this too. Jens |
That's the minimal setup to reproduce the issue. Jens Attachments:
|
CL https://golang.org/cl/154210044 mentions this issue. |
Please, review https://golang.org/cl/152410043 to see if that fixes your problem. Thank you. Alex Status changed to Started. |
CL https://golang.org/cl/152410043 mentions this issue. |
This issue was updated by revision d0ee959. LGTM=iant, jfrederich R=golang-codereviews, iant, jfrederich CC=golang-codereviews https://golang.org/cl/154210044 |
This issue was closed by revision d704bb0. Status changed to Fixed. |
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 25, 2018
Our current pe object reader assumes that every symbol starting with '.' is section. It appeared to be true, until now gcc 4.9.1 generates some symbols with '.' at the front. Change that logic to check other symbol fields in addition to checking for '.'. I am not an expert here, but it seems reasonable to me. Added test, but it is only good, if tested with gcc 4.9.1. Otherwise the test PASSes regardless. Fixes golang#8811. Fixes golang#8856. LGTM=jfrederich, iant, stephen.gutekanst R=golang-codereviews, jfrederich, stephen.gutekanst, iant CC=alex.brainman, golang-codereviews https://golang.org/cl/152410043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 26, 2018
Our current pe object reader assumes that every symbol starting with '.' is section. It appeared to be true, until now gcc 4.9.1 generates some symbols with '.' at the front. Change that logic to check other symbol fields in addition to checking for '.'. I am not an expert here, but it seems reasonable to me. Added test, but it is only good, if tested with gcc 4.9.1. Otherwise the test PASSes regardless. Fixes golang#8811. Fixes golang#8856. LGTM=jfrederich, iant, stephen.gutekanst R=golang-codereviews, jfrederich, stephen.gutekanst, iant CC=alex.brainman, golang-codereviews https://golang.org/cl/152410043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 9, 2018
Our current pe object reader assumes that every symbol starting with '.' is section. It appeared to be true, until now gcc 4.9.1 generates some symbols with '.' at the front. Change that logic to check other symbol fields in addition to checking for '.'. I am not an expert here, but it seems reasonable to me. Added test, but it is only good, if tested with gcc 4.9.1. Otherwise the test PASSes regardless. Fixes golang#8811. Fixes golang#8856. LGTM=jfrederich, iant, stephen.gutekanst R=golang-codereviews, jfrederich, stephen.gutekanst, iant CC=alex.brainman, golang-codereviews https://golang.org/cl/152410043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 30, 2018
Our current pe object reader assumes that every symbol starting with '.' is section. It appeared to be true, until now gcc 4.9.1 generates some symbols with '.' at the front. Change that logic to check other symbol fields in addition to checking for '.'. I am not an expert here, but it seems reasonable to me. Added test, but it is only good, if tested with gcc 4.9.1. Otherwise the test PASSes regardless. Fixes golang#8811. Fixes golang#8856. LGTM=jfrederich, iant, stephen.gutekanst R=golang-codereviews, jfrederich, stephen.gutekanst, iant CC=alex.brainman, golang-codereviews https://golang.org/cl/152410043
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: