1
0
mirror of https://github.com/golang/go synced 2024-11-13 12:40:26 -07:00

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 <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Cherry Mui 2024-10-08 12:46:01 -04:00
parent 0bb2183d45
commit 6a4feb5644
2 changed files with 7 additions and 3 deletions

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

View 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