Skip to content

Commit 6a4feb5

Browse files
committed
cmd/link: on Mach-O, generate LC_UUID by default
On Mach-O, default to "-B gobuildid", so it generates the UUID based on Go buildid by default. Fixes #68678. Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64_14,gotip-darwin-arm64_13 Change-Id: I6c1a6bcafd8370a13174657e05d7d9620a8d4f12 Reviewed-on: https://go-review.googlesource.com/c/go/+/618598 Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Than McIntosh <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 0bb2183 commit 6a4feb5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/cmd/link/internal/ld/elf.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,9 @@ func elfwritefreebsdsig(out *OutBuf) int {
807807

808808
func addbuildinfo(ctxt *Link) {
809809
val := *flagHostBuildid
810+
if val == "" || val == "none" {
811+
return
812+
}
810813
if val == "gobuildid" {
811814
buildID := *flagBuildid
812815
if buildID == "" {

src/cmd/link/internal/ld/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var (
9595
flagN = flag.Bool("n", false, "no-op (deprecated)")
9696
FlagS = flag.Bool("s", false, "disable symbol table")
9797
flag8 bool // use 64-bit addresses in symbol table
98-
flagHostBuildid = flag.String("B", "", "set ELF NT_GNU_BUILD_ID `note` or Mach-O UUID; use \"gobuildid\" to generate it from the Go build ID")
98+
flagHostBuildid = flag.String("B", "", "set ELF NT_GNU_BUILD_ID `note` or Mach-O UUID; use \"gobuildid\" to generate it from the Go build ID; \"none\" to disable")
9999
flagInterpreter = flag.String("I", "", "use `linker` as ELF dynamic linker")
100100
flagCheckLinkname = flag.Bool("checklinkname", true, "check linkname symbol references")
101101
FlagDebugTramp = flag.Int("debugtramp", 0, "debug trampolines")
@@ -294,9 +294,10 @@ func Main(arch *sys.Arch, theArch Arch) {
294294
*flagBuildid = "go-openbsd"
295295
}
296296

297-
if *flagHostBuildid != "" {
298-
addbuildinfo(ctxt)
297+
if *flagHostBuildid == "" && *flagBuildid != "" && ctxt.IsDarwin() {
298+
*flagHostBuildid = "gobuildid"
299299
}
300+
addbuildinfo(ctxt)
300301

301302
// enable benchmarking
302303
var bench *benchmark.Metrics

0 commit comments

Comments
 (0)