]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: link libgcc archive after mingw archives
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 24 Feb 2021 15:47:58 +0000 (16:47 +0100)
committerRuss Cox <rsc@golang.org>
Fri, 9 Apr 2021 13:10:36 +0000 (13:10 +0000)
When compiling with the race detector using modern mingw, this prevents:

    libgcc(.text): relocation target ___chkstk_ms not defined

Change-Id: I2095ad09a535505b54f9ff2d3075fd20ac85e515
Reviewed-on: https://go-review.googlesource.com/c/go/+/295910
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/link/internal/ld/lib.go

index 4d5be30d82f3ddd823b52b4058383f5a91001f79..46d238a3181f940e1e20282cb6cdfec495de3f16 100644 (file)
@@ -603,9 +603,6 @@ func (ctxt *Link) loadlib() {
                                // errors - see if we can find libcompiler_rt.a instead.
                                *flagLibGCC = ctxt.findLibPathCmd("--print-file-name=libcompiler_rt.a", "libcompiler_rt")
                        }
-                       if *flagLibGCC != "none" {
-                               hostArchive(ctxt, *flagLibGCC)
-                       }
                        if ctxt.HeadType == objabi.Hwindows {
                                if p := ctxt.findLibPath("libmingwex.a"); p != "none" {
                                        hostArchive(ctxt, p)
@@ -627,6 +624,9 @@ func (ctxt *Link) loadlib() {
                                        libmsvcrt.a libm.a
                                */
                        }
+                       if *flagLibGCC != "none" {
+                               hostArchive(ctxt, *flagLibGCC)
+                       }
                }
        }