Skip to content

cmd/go: macOS plugin builds are not reproducible #58557

@misha-ridge

Description

@misha-ridge

What version of Go are you using (go version)?

Tested with Go 1.19 and Go 1.20

$ go version
go version go1.19.5 darwin/arm64
$ go version
go version go1.20.1 darwin/arm64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/roman/Library/Caches/go-build"
GOENV="/Users/roman/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/roman/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/roman/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org/,direct"
GOROOT="/Users/roman/Work/Ridge/tectonic/_deps.darwin-arm64/go-1.20.1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/roman/Work/Ridge/tectonic/_deps.darwin-arm64/go-1.20.1/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/roman/Work/Ridge/tectonic/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w2/fyw22w5x5737wfqnpw5ngnc40000gn/T/go-build2948842969=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I have created a package with single main function and built it on Mac twice as a plugin:

package main
func main() {}
go build -trimpath -buildvcs=false -buildmode=plugin -o a.so .
go build -trimpath -buildvcs=false -buildmode=plugin -o b.so .

The resulting binaries differ.

Reproducer is at https://github.com/misha-ridge/test-plugin-build

What did you expect to see?

I expected the binaries to be identical.

What did you see instead?

Plugin embeds a temporary directory path, plus some other differences that might be related to it:

--- /dev/fd/63	2023-02-16 10:47:27
+++ /dev/fd/62	2023-02-16 10:47:27
@@ -113,7 +113,7 @@
 00000700  64 65 72 73 2f 39 35 2f  76 7a 77 63 76 35 79 64  |ders/95/vzwcv5yd|
 00000710  33 32 78 33 36 39 7a 30  63 39 74 34 62 66 72 30  |32x369z0c9t4bfr0|
 00000720  30 30 30 30 67 6e 2f 54  2f 67 6f 2d 62 75 69 6c  |0000gn/T/go-buil|
-00000730  64 31 38 39 36 31 38 31  30 36 30 2f 62 30 30 31  |d1896181060/b001|
+00000730  64 34 30 38 38 30 39 37  33 31 37 2f 62 30 30 31  |d4088097317/b001|
 00000740  2f 65 78 65 2f 61 2e 6f  75 74 2e 73 6f 00 00 00  |/exe/a.out.so...|
 00000750  34 00 00 80 10 00 00 00  00 00 11 00 48 2d 00 00  |4...........H-..|
 00000760  33 00 00 80 10 00 00 00  48 2d 11 00 08 2d 00 00  |3.......H-...-..|
@@ -124,7 +124,7 @@
 000007b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
 000007c0  28 11 12 00 44 01 00 00  00 00 00 00 00 00 00 00  |(...D...........|
 000007d0  00 00 00 00 00 00 00 00  1b 00 00 00 18 00 00 00  |................|
-000007e0  39 45 f5 ea 0b 6e 3b 3b  ba 71 2b 6d e9 69 0a 0a  |9E...n;;.q+m.i..|
+000007e0  0a c9 64 b8 eb f2 39 97  b9 ea b9 30 3d a0 3f 2f  |..d...9....0=.?/|
 000007f0  32 00 00 00 20 00 00 00  01 00 00 00 00 00 0d 00  |2... ...........|
 00000800  00 01 0d 00 01 00 00 00  03 00 00 00 00 01 34 03  |..............4.|
 00000810  2a 00 00 00 10 00 00 00  00 00 00 00 00 00 00 00  |*...............|
@@ -74414,9 +74414,9 @@
 0012ff80  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
 *
 0012ffa0  00 06 80 00 00 00 00 00  00 00 00 00 61 2e 6f 75  |............a.ou|
-0012ffb0  74 00 21 40 04 9e 12 52  25 b7 3f 1f 1c 73 1f e2  |[email protected]%.?..s..|
-0012ffc0  6a 66 ba 9e 1d 06 01 62  9c 52 53 97 e4 69 e2 16  |jf.....b.RS..i..|
-0012ffd0  76 c5 ad 7f ac b2 58 6f  c6 e9 66 c0 04 d7 d1 d1  |v.....Xo..f.....|
+0012ffb0  74 00 be f5 bf aa 8d 4d  87 8a b8 93 bf bd 90 fc  |t......M........|
+0012ffc0  fe 3e f6 e7 54 cb 57 58  fe 78 bd e5 f8 cf fa 57  |.>..T.WX.x.....W|
+0012ffd0  c9 87 ad 7f ac b2 58 6f  c6 e9 66 c0 04 d7 d1 d1  |......Xo..f.....|
 0012ffe0  6b 02 4f 58 05 ff 7c b4  7c 7a 85 da bd 8b 48 89  |k.OX..|.|z....H.|
 0012fff0  2c a7 ad 7f ac b2 58 6f  c6 e9 66 c0 04 d7 d1 d1  |,.....Xo..f.....|
 00130000  6b 02 4f 58 05 ff 7c b4  7c 7a 85 da bd 8b 48 89  |k.OX..|.|z....H.|

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions