···11-From e7357c383188dd735592bd9f2202d2afcfffa39d Mon Sep 17 00:00:00 2001
22-From: =?UTF-8?q?Mustafa=20=C3=87al=C4=B1=C5=9Fkan?= <muscaln@protonmail.com>
33-Date: Sun, 11 Sep 2022 17:08:33 +0300
44-Subject: [PATCH 3/3] Use out path as build id on darwin
55-66-77-diff --git a/builder/buildid.go b/builder/buildid.go
88-index e6527700..65cb08e8 100644
99---- a/builder/buildid.go
1010-+++ b/builder/buildid.go
1111-@@ -3,8 +3,6 @@ package builder
1212- import (
1313- "bytes"
1414- "debug/elf"
1515-- "debug/macho"
1616-- "encoding/binary"
1717- "fmt"
1818- "io"
1919- "os"
2020-@@ -53,30 +51,9 @@ func ReadBuildID() ([]byte, error) {
2121- return goID, nil
2222- }
2323- case "darwin":
2424-- // Read the LC_UUID load command, which contains the equivalent of a
2525-- // build ID.
2626-- file, err := macho.NewFile(f)
2727-- if err != nil {
2828-- return nil, err
2929-- }
3030-- for _, load := range file.Loads {
3131-- // Unfortunately, the debug/macho package doesn't support the
3232-- // LC_UUID command directly. So we have to read it from
3333-- // macho.LoadBytes.
3434-- load, ok := load.(macho.LoadBytes)
3535-- if !ok {
3636-- continue
3737-- }
3838-- raw := load.Raw()
3939-- command := binary.LittleEndian.Uint32(raw)
4040-- if command != 0x1b {
4141-- // Looking for the LC_UUID load command.
4242-- // LC_UUID is defined here as 0x1b:
4343-- // https://opensource.apple.com/source/xnu/xnu-4570.71.2/EXTERNAL_HEADERS/mach-o/loader.h.auto.html
4444-- continue
4545-- }
4646-- return raw[4:], nil
4747-- }
4848-+ // On darwin, os.Executable() returns broken path in nix build environment
4949-+ // So we are using $out path as build id since its also unique
5050-+ return []byte("OUT_PATH"), nil
5151- default:
5252- // On other platforms (such as Windows) there isn't such a convenient
5353- // build ID. Luckily, Go does have an equivalent of the build ID, which
5454---
5555-2.37.2
5656-