]> Cypherpunks repositories - gostls13.git/commit
[dev.boringcrypto] cmd/go: pass dependency syso to cgo too
authorRuss Cox <rsc@golang.org>
Wed, 27 Apr 2022 13:02:52 +0000 (09:02 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 29 Apr 2022 14:23:21 +0000 (14:23 +0000)
commit1f0547c4ec4fe18d46192d8c670190111b1d3d79
treee4916df6ac044d2c911dbdbf559d52bb40369edf
parente5407501cb5c43f9ba874fe5dad215435acbf5a2
[dev.boringcrypto] cmd/go: pass dependency syso to cgo too

Proposal #42477 asked for a way to apply conditional build tags
to syso files (which have no source code to hold //go:build lines).

We ended up suggesting that the standard answer should be to
put the syso in its own package and then import that package from
a source file that is itself conditionally compiled.

A followup comment on that issue pointed out a problem that I did
not understand until I tried to use this approach myself: the cgo
build fails by default, because the link step only uses syso files from
the current package. You have to override this explicitly by arranging
to pass a “ignore unresolved symbols” flag to the host linker.
Many users will not know how to do this.
(I don't know how to do this off the top of my head.)

If we want users to use this approach, we should make it work better.
This CL does that, by including the syso files from dependencies of
the current package in the link step.

For #51940.

Change-Id: I53a0371b2df17e39a000a645b7686daa6a98722d
Reviewed-on: https://go-review.googlesource.com/c/go/+/402596
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/go/internal/work/exec.go
src/cmd/go/testdata/script/link_syso_deps.txt [new file with mode: 0644]