Skip to content

cmd/6l: CGO program will only link with MinGW 4.8.1 on Windows #8811

Closed

Description

@emidoots
I have tried the following Go versions:
* Tip
* Official Go 1.3.1 binaries.

What steps reproduce the problem?

1. Extract attached zip file (5 files, 47 lines in total) to $GOPATH/src/
2. cd $GOPATH/src/mingwbug
3. go build

What happened?

C:\Users\stephen\Desktop\godev\src\mingwbug>go build -a main.go
# command-line-arguments
mingwbug/glfw(.text): mingwbug/glfw(/76): not defined
mingwbug/glfw(.text): undefined: mingwbug/glfw(/76)

What should have happened instead?

The program should link.

Please provide any additional information below.

The program compiles, links, and runs fine when using MinGW 4.8.1.

If using MinGW 4.8.3 OR 4.9.1 (MinGW-W64 project or TDM-GCC) then the linker reports the
errors above.

This issue is a minimal example if the problem we ran into at
go-gl/glfw#91 if you want more information.

Activity

  1. emidoots commented on Sep 26, 2014

    @emidoots
    Author

    Comment 1:

    (attachment)

    Attachments:

    1. mingwbug.zip (1498 bytes)
  2. ianlancetaylor commented on Sep 26, 2014

    @ianlancetaylor
    Contributor

    Comment 2:

    Please try running "go build -x" and report the results here so that we can see just
    which command failed.  Thanks.

    Labels changed: added repo-main, release-go1.4maybe, os-windows.

  3. emidoots commented on Sep 26, 2014

    @emidoots
    Author

    Comment 3:

    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)
  4. ianlancetaylor commented on Sep 26, 2014

    @ianlancetaylor
    Contributor

    Comment 4:

    Sorry, I have no idea what is going on.  This is failing when running the Go linker on
    Go code, so I can't see why changing the GCC version would make any difference.  I also
    don't know what the "(/76)" is doing there.  This will have to be debugged by somebody
    running Windows.
  5. rsc commented on Oct 7, 2014

    @rsc
    Contributor

    Comment 5:

    Owner changed to @rsc.

    Status changed to Accepted.

  6. rsc commented on Oct 7, 2014

    @rsc
    Contributor

    Comment 6:

    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 ---.

  7. alexbrainman commented on Oct 7, 2014

    @alexbrainman
    Member

    Comment 7:

    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
  8. alexbrainman commented on Oct 7, 2014

    @alexbrainman
    Member

    Comment 8:

    I had trouble finding latest gcc. http://nuwen.net/mingw.html is what I end-up using.
    Alex
  9. andlabs commented on Oct 7, 2014

    @andlabs
    Contributor

    Comment 9:

    @Alex: http://mingw-w64.sourceforge.net/ - on Windows the easiest way is to use the
    mingw-builds distribution.
  10. gopherbot commented on Oct 7, 2014

    @gopherbot
    Contributor

    Comment 10 by rich.amacker:

    @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.
  11. frederich commented on Oct 8, 2014

    @frederich
    Contributor

    Comment 11:

    I'll fix the issue.
  12. alexbrainman commented on Oct 8, 2014

    @alexbrainman
    Member

    Comment 12:

    Sure, go ahead. I also have started on this issue. One of us will succeed. :-)
    Alex
  13. frederich commented on Oct 8, 2014

    @frederich
    Contributor

    Comment 13:

    Oh sorry Alex, I've thought no one is on it. You can fix it if you want?
    Jens
  14. alexbrainman commented on Oct 8, 2014

    @alexbrainman
    Member

    Comment 14:

    No, please continue with your fix. I am not certain my solution is correct. Two heads
    are better then one. Whoever is ready first will discuss during review.
    Alex
  15. frederich commented on Oct 8, 2014

    @frederich
    Contributor

    Comment 15:

    ok
  16. 11 remaining items

  17. alexbrainman commented on Oct 10, 2014

    @alexbrainman
    Member

    Comment 27:

    Thanks for review. I will wait for others.
    Alex
  18. alexbrainman commented on Oct 11, 2014

    @alexbrainman
    Member

    Comment 28:

    This issue was updated by revision d0ee959.

    LGTM=iant, jfrederich
    R=golang-codereviews, iant, jfrederich
    CC=golang-codereviews
    https://golang.org/cl/154210044
  19. alexbrainman commented on Oct 11, 2014

    @alexbrainman
    Member

    Comment 29:

    This issue was closed by revision d704bb0.

    Status changed to Fixed.

  20. added this to the Go1.4 milestone on Apr 14, 2015
  21. locked and limited conversation to collaborators on Jun 25, 2016
  22. added 2 commits that reference this issue on Jun 25, 2018
    c8e8a2a
    c8b74bf
  23. added a commit that references this issue on Jul 9, 2018
    933b494
  24. added a commit that references this issue on Jul 30, 2018
    030fd8f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions