From c432917061f6dc9e5e9bfa0745991f7291be794e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 24 Feb 2021 16:47:58 +0100 Subject: [PATCH] cmd/link: link libgcc archive after mingw archives 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 Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Russ Cox --- src/cmd/link/internal/ld/lib.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 4d5be30d82f..46d238a3181 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -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) + } } }