From 3aa7ada60791f8c6c3cb6abd04d446bbc90efdab Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 21 Mar 2023 16:27:14 -0400 Subject: [PATCH] cmd/go: extend the linker -o workaround for plugins to all platforms On Linux, for a shared object, at least with the Gold linker, the output file path is recorded in the .gnu.version_d section. When the output file path is in a temporary directory, it causes nondeterministic build. This is similar to #58557, but for Linux with the Gold linker. Apply the same workaround as in CL 477296. Should fix the linux-arm64-longtest builder. Change-Id: Ic703bff32c1bcc40054b89be696e04280855e876 Reviewed-on: https://go-review.googlesource.com/c/go/+/478196 Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills --- src/cmd/go/internal/work/gc.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go index c144413f85..4f6f18ee1d 100644 --- a/src/cmd/go/internal/work/gc.go +++ b/src/cmd/go/internal/work/gc.go @@ -683,8 +683,10 @@ func (gcToolchain) ld(b *Builder, root *Action, out, importcfg, mainpkg string) // just the final path element. // On Windows, DLL file name is recorded in PE file // export section, so do like on OS X. + // On Linux, for a shared object, at least with the Gold linker, + // the output file path is recorded in the .gnu.version_d section. dir := "." - if (cfg.Goos == "darwin" || cfg.Goos == "windows") && (cfg.BuildBuildmode == "c-shared" || cfg.BuildBuildmode == "plugin") { + if cfg.BuildBuildmode == "c-shared" || cfg.BuildBuildmode == "plugin" { dir, out = filepath.Split(out) } -- 2.48.1