]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/link: use path from "cc --print-prog-name ar" for c-archive buildmode
authorThan McIntosh <thanm@google.com>
Tue, 28 Mar 2023 13:17:27 +0000 (09:17 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 28 Mar 2023 17:52:20 +0000 (17:52 +0000)
commit422f4483f183622ecd19dc9ae98a16802c4be40e
treef2f4c01d771f7b9b5cab8a37440938b4e256e417
parentc02e1bfbdb7ff9d4c2ecf8a9859ccecd8eadfc59
cmd/link: use path from "cc --print-prog-name ar" for c-archive buildmode

When external linking with -buildmode=c-archive, the Go linker
eventually invokes the "ar" tool to create the final archive library.
Prior to this patch, if the '-extar' flag was not in use, we would
just run "ar". This works well in most cases but breaks down if we're
doing cross-compilation targeting Windows (macos system "ar"
apparently doesn't create the windows symdef section correctly). To
fix the problem, capture the output of "cc --print-prog-name ar" and
invoke "ar" using the path returned by that command.

Fixes #59221.

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