]> Cypherpunks 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>
Thu, 13 Jun 2024 16:35:16 +0000 (16:35 +0000)
commit7bfc82429c4067664d9645c70323cd76ee0496c0
tree86f2d425e096dae627abe06958ecd0e22dec6f0d
parenta2026cf0d9e84346e3103f4f429107b9499eca26
cmd/link: use path from "cc --print-prog-name ar" for c-archive buildmode

[This is a roll-forward of CL 479775, which had to be rolled back due
to bad interactions with the wrappers used by the ios-arm64-corellium
builder. ios-arm64-corellium is no longer being maintained AFAICT,
meaning that it should be ok to move ahead with this patch again].

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: Ie367541b23641266a6f48ac68adf971501bff9fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/592375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/link/internal/ld/lib.go