]> Cypherpunks repositories - gostls13.git/commit
cmd/link: read crt2.o for windows internal-linking CGO
authorThan McIntosh <thanm@google.com>
Thu, 3 Feb 2022 13:23:10 +0000 (08:23 -0500)
committerThan McIntosh <thanm@google.com>
Thu, 31 Mar 2022 14:08:58 +0000 (14:08 +0000)
commita9d13a9c230bafba64469f126202315ba4d24eea
tree304a475f4ba726e1d8e8e4ce2e32d926856115a4
parent821420d6bbc53d4cd8b3f9a903fccd0c6432eb6f
cmd/link: read crt2.o for windows internal-linking CGO

For Windows internal linking with CGO, when using more modern
LLVM-based compilers, we may need to read in the object file "crt2.o"
so as to have a definition of "atexit" (for example when linking the
runtime/cgo test), and we also need to allow for the possibility that
a given host archive might have to be looked at more than once. The goal
here is to get all.bash working on Windows when using an up to date
mingw C compiler (including those based on clang + LLD).

This patch also adds a new "hostObject" helper routine, similar to
"hostArchive" but specific to individual object files. There is also a
change to hostArchive to modify the pseudo-package name assigned when
reading archive elements: up until this point, a package name of
"libgcc" was used (even when reading a host archive like
"libmingex.a"), which led to very confusing errors messages if symbols
were missing or there were duplicate definitions.

Updates #35006.

Change-Id: I19c17dea9cfffa9e79030fc23064c7c63a612097
Reviewed-on: https://go-review.googlesource.com/c/go/+/382838
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/link/internal/ld/ar.go
src/cmd/link/internal/ld/lib.go