]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: on Mach-O, generate LC_UUID by default
authorCherry Mui <cherryyz@google.com>
Tue, 8 Oct 2024 16:46:01 +0000 (12:46 -0400)
committerCherry Mui <cherryyz@google.com>
Mon, 21 Oct 2024 17:56:35 +0000 (17:56 +0000)
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 <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

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

index a00a7bc0f221db7e271e70805311c259632b8365..fb3e4f50717b4222bc8b7993f968998c07013e1d 100644 (file)
@@ -807,6 +807,9 @@ func elfwritefreebsdsig(out *OutBuf) int {
 
 func addbuildinfo(ctxt *Link) {
        val := *flagHostBuildid
+       if val == "" || val == "none" {
+               return
+       }
        if val == "gobuildid" {
                buildID := *flagBuildid
                if buildID == "" {
index 12bc896c66c3d75f33cd5b0bbf21e39f6b9afdb7..532d6dc80ea891912182e9bb0a97d92a56c11956 100644 (file)
@@ -95,7 +95,7 @@ var (
        flagN             = flag.Bool("n", false, "no-op (deprecated)")
        FlagS             = flag.Bool("s", false, "disable symbol table")
        flag8             bool // use 64-bit addresses in symbol table
-       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")
+       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")
        flagInterpreter   = flag.String("I", "", "use `linker` as ELF dynamic linker")
        flagCheckLinkname = flag.Bool("checklinkname", true, "check linkname symbol references")
        FlagDebugTramp    = flag.Int("debugtramp", 0, "debug trampolines")
@@ -294,9 +294,10 @@ func Main(arch *sys.Arch, theArch Arch) {
                *flagBuildid = "go-openbsd"
        }
 
-       if *flagHostBuildid != "" {
-               addbuildinfo(ctxt)
+       if *flagHostBuildid == "" && *flagBuildid != "" && ctxt.IsDarwin() {
+               *flagHostBuildid = "gobuildid"
        }
+       addbuildinfo(ctxt)
 
        // enable benchmarking
        var bench *benchmark.Metrics