Skip to content

Commit 787414c

Browse files
mknyszekgopherbot
authored andcommitted
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. This change, along with CL 589295, should fully fix the clang builders. Fixes #67698. Change-Id: I3bfbcd609e7d0fd70e52ac7e2a0817db95664f20 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-clang15,gotip-linux-386-clang15 Reviewed-on: https://go-review.googlesource.com/c/go/+/589296 Auto-Submit: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 1cf862e commit 787414c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cmd/cgo/internal/swig/swig_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,18 @@ func run(t *testing.T, dir string, lto bool, args ...string) {
4444
cmd := exec.Command("go", runArgs...)
4545
cmd.Dir = dir
4646
if lto {
47+
// On the builders we're using the default /usr/bin/ld, but
48+
// that has problems when asking for LTO in particular. Force
49+
// use of lld, which ships with our clang installation.
50+
extraLDFlags := ""
51+
if strings.Contains(testenv.Builder(), "clang") {
52+
extraLDFlags += " -fuse-ld=lld"
53+
}
4754
const cflags = "-flto -Wno-lto-type-mismatch -Wno-unknown-warning-option"
4855
cmd.Env = append(cmd.Environ(),
4956
"CGO_CFLAGS="+cflags,
5057
"CGO_CXXFLAGS="+cflags,
51-
"CGO_LDFLAGS="+cflags)
58+
"CGO_LDFLAGS="+cflags+extraLDFlags)
5259
}
5360
out, err := cmd.CombinedOutput()
5461
if string(out) != "OK\n" {

0 commit comments

Comments
 (0)