]> Cypherpunks repositories - gostls13.git/commit
cmd/link: avoid stamping runtime.defaultGOROOT when paths are being trimmed
authorBryan C. Mills <bcmills@google.com>
Tue, 15 Mar 2022 20:37:50 +0000 (16:37 -0400)
committerBryan Mills <bcmills@google.com>
Fri, 18 Mar 2022 21:55:03 +0000 (21:55 +0000)
commit9ac75d39514402d9b314e758524dcc28612b8937
treebf2873b870c1263d294193dd1575cce056a9a2b5
parent9a932c5712bebb2620e0719a93773403f4fb563d
cmd/link: avoid stamping runtime.defaultGOROOT when paths are being trimmed

Previously, runtime.GOROOT() would return the string "go" in a binary
build with -trimpath. This change stamps the empty string instead,
using a sentinel value passed from cmd/go that looks like the GOROOT
environment variable (either "$GOROOT" or "%GOROOT%", depending on the
platform).

Fixes #51461

Change-Id: I1f10ef2435016a7b6213bd8c547df911f7feeae7
Reviewed-on: https://go-review.googlesource.com/c/go/+/390024
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/go/internal/work/gc.go
src/cmd/go/testdata/script/build_trimpath_goroot.txt [new file with mode: 0644]
src/cmd/link/internal/ld/main.go
src/cmd/link/internal/ld/pcln.go