aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2024-05-30 03:36:41 +0000
committerJoedian Reid <joedian@google.com>2024-06-24 17:06:33 +0000
commit14f0251867fbc400674333723e4d6e0dab122761 (patch)
tree853494143271c651b37f3743340b5cd0a92f84b7
parentab60a7bc18c990513532b4d33c1e2673fb1ea703 (diff)
downloadgo-14f0251867fbc400674333723e4d6e0dab122761.tar.xz
[release-branch.go1.22] cmd/cgo/internal/swig: force use of lld for LTO tests on the builders
For whatever reason, on the builders, when using /usr/bin/ld (the default linker) with -flto we end up with problems. Specifically, the linker seems to require LLVMgold.so and can't find it. I'm not really sure why, but what definitely seems to work is forcing use of lld, which ships with our clang installation on the builders. Just enforce this on the builders for now; I've actually had very few problems running this locally (and I think I'm also mixing and matching linkers and toolchains too...), so it may be related to the version of clang we're testing with. For #67698. For #67715. Change-Id: I3bfbcd609e7d0fd70e52ac7e2a0817db95664f20 Cq-Include-Trybots: luci.golang.try:go1.22-linux-amd64-clang15,go1.22-linux-386-clang15 Reviewed-on: https://go-review.googlesource.com/c/go/+/589296 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/591375
-rw-r--r--src/cmd/cgo/internal/swig/swig_test.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/cgo/internal/swig/swig_test.go b/src/cmd/cgo/internal/swig/swig_test.go
index 41563138a7..923378b2dd 100644
--- a/src/cmd/cgo/internal/swig/swig_test.go
+++ b/src/cmd/cgo/internal/swig/swig_test.go
@@ -44,11 +44,18 @@ func run(t *testing.T, dir string, lto bool, args ...string) {
cmd := exec.Command("go", runArgs...)
cmd.Dir = dir
if lto {
+ // On the builders we're using the default /usr/bin/ld, but
+ // that has problems when asking for LTO in particular. Force
+ // use of lld, which ships with our clang installation.
+ extraLDFlags := ""
+ if strings.Contains(testenv.Builder(), "clang") {
+ extraLDFlags += " -fuse-ld=lld"
+ }
const cflags = "-flto -Wno-lto-type-mismatch -Wno-unknown-warning-option"
cmd.Env = append(cmd.Environ(),
"CGO_CFLAGS="+cflags,
"CGO_CXXFLAGS="+cflags,
- "CGO_LDFLAGS="+cflags)
+ "CGO_LDFLAGS="+cflags+extraLDFlags)
}
out, err := cmd.CombinedOutput()
if string(out) != "OK\n" {