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 <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
Cherry Mui 2023-03-21 16:27:14 -04:00
parent eedd97d5fd
commit 3aa7ada607
1 changed files with 3 additions and 1 deletions

View File

@ -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)
}