diff options
author | Cherry Mui <cherryyz@google.com> | 2021-08-17 17:21:03 -0400 |
---|---|---|
committer | Cherry Mui <cherryyz@google.com> | 2021-09-01 17:06:03 +0000 |
commit | 47a57bc4f0c6a2b7ac12d4eed4ce305446654459 (patch) | |
tree | 515918241780441a1ac711b33aa7496ea5a7254b | |
parent | 2d97a87287366f384a08ad1bb4da7b630fd589a0 (diff) | |
download | go-47a57bc4f0c6a2b7ac12d4eed4ce305446654459.tar.gz go-47a57bc4f0c6a2b7ac12d4eed4ce305446654459.zip |
[release-branch.go1.17] cmd/link: do not use GO_LDSO when cross compile
GO_LDSO is a setting that is set when the toolchain is build. It
only makes sense to use it on the host platform. Do not use it
when targetting a different platform.
In the past it was not a problem as GO_LDSO was almost always
unset. Now, with CL 301989 it is almost always set (maybe we want
to revisit it).
Updates #47760.
Fixes #47782.
Change-Id: I2704b9968781f46e2d2f8624090db19689b1a32f
Reviewed-on: https://go-review.googlesource.com/c/go/+/343010
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit ddfcc02352feb9e15ff9aa423bb49bfb37d689a3)
Reviewed-on: https://go-review.googlesource.com/c/go/+/343309
-rw-r--r-- | src/cmd/link/internal/ld/elf.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ld/elf.go b/src/cmd/link/internal/ld/elf.go index 81011638bc..d16539e4bf 100644 --- a/src/cmd/link/internal/ld/elf.go +++ b/src/cmd/link/internal/ld/elf.go @@ -16,6 +16,7 @@ import ( "fmt" "internal/buildcfg" "path/filepath" + "runtime" "sort" "strings" ) @@ -1749,7 +1750,7 @@ func asmbElf(ctxt *Link) { sh.Flags = uint64(elf.SHF_ALLOC) sh.Addralign = 1 - if interpreter == "" && buildcfg.GO_LDSO != "" { + if interpreter == "" && buildcfg.GOOS == runtime.GOOS && buildcfg.GOARCH == runtime.GOARCH && buildcfg.GO_LDSO != "" { interpreter = buildcfg.GO_LDSO } |