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" {