cmd/link: work around race syso weak import on macOS

With https://github.com/llvm/llvm-project/pull/182943, the race
detector syso has a weak import of __dyld_get_dyld_header, which
is only defined on newer macOS (26.4+). For external linking with
a pre-Xcode 26.4 C toolchain, we need to tell the C linker to
permit that symbol not being defined. Pass a flag to do so.

Change-Id: I95a3cd2c7fd3ad50bc47985b3ecca0d4e8352162
Reviewed-on: https://go-review.googlesource.com/c/go/+/755261
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
This commit is contained in:
Cherry Mui
2026-03-13 17:28:33 -04:00
parent 1e994e0a48
commit e22437d192

View File

@@ -1488,6 +1488,12 @@ func (ctxt *Link) hostlink() {
argv = append(argv, "-Wl,-x")
}
}
if *flagRace {
// With https://github.com/llvm/llvm-project/pull/182943, the race object
// has a weak import of __dyld_get_dyld_header, which is only defined on
// newer macOS (26.4+).
argv = append(argv, "-Wl,-U,__dyld_get_dyld_header")
}
if *flagHostBuildid == "none" {
argv = append(argv, "-Wl,-no_uuid")
}