cmd/go: clear GOROOT for func ldShared when -trimpath is used
In commit [cmd: remove support for GOROOT_FINAL][1], it clear GOROOT for func ld when -trimpath is used. [2]
This commit do the same thing for func ldShared, otherwise run go_bootstrap with -trimpath does not remove build path directory from the generated share libarary
$ ./make.bash --target-only --no-banner std
$ go_bootstrap install -linkshared -buildmode=shared -trimpath std
$ grep "$(pwd)" ./pkg/linux_amd64_dynlink/libstd.so
Binary file ./pkg/linux_amd64_dynlink/libstd.so matches
[1] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98
[2] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98#diff-cab5921f94f2667bb0bc1b935d2d46b4c03541b4351b33438ab7290b94dea212R669
This PR will be imported into Gerrit with the title and first
comment (this text) used to generate the subject and body of
the Gerrit change.
**Please ensure you adhere to every item in this list.**
More info can be found at https://github.com/golang/go/wiki/CommitMessage
+ The PR title is formatted as follows: `net/http: frob the quux before blarfing`
+ The package name goes before the colon
+ The part after the colon uses the verb tense + phrase that completes the blank in,
"This change modifies Go to ___________"
+ Lowercase verb after the colon
+ No trailing period
+ Keep the title as short as possible. ideally under 76 characters or shorter
+ No Markdown
+ The first PR comment (this one) is wrapped at 76 characters, unless it's
really needed (ASCII art, table, or long link)
+ If there is a corresponding issue, add either `Fixes #1234` or `Updates #1234`
(the latter if this is not a complete fix) to this comment
+ If referring to a repo other than `golang/go` you can use the
`owner/repo#issue_number` syntax: `Fixes golang/tools#1234`
+ We do not use Signed-off-by lines in Go. Please don't add them.
Our Gerrit server & GitHub bots enforce CLA compliance instead.
+ Delete these instructions once you have read and applied them
diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go
index 3a173ef..8b7a44e 100644
--- a/src/cmd/go/internal/work/gc.go
+++ b/src/cmd/go/internal/work/gc.go
@@ -728,7 +728,14 @@
// the output file path is recorded in the .gnu.version_d section.
dir, targetPath := filepath.Split(targetPath)
- return b.Shell(root).run(dir, targetPath, nil, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags)
+ env := []string{}
+ // When -trimpath is used, GOROOT is cleared
+ if cfg.BuildTrimpath {
+ env = append(env, "GOROOT=")
+ } else {
+ env = append(env, "GOROOT="+cfg.GOROOT)
+ }
+ return b.Shell(root).run(dir, targetPath, env, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags)
}
func (gcToolchain) cc(b *Builder, a *Action, ofile, cfile string) error {
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I spotted some possible problems.
These findings are based on simple heuristics. If a finding appears wrong, briefly reply here saying so. Otherwise, please address any problems and update the GitHub PR. When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above.
Possible problems detected:
1. Do you still have the GitHub PR instructions in your commit message text? The PR instructions should be deleted once you have applied them.
2. Do you have the right bug reference format? For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message.
The commit title and commit message body come from the GitHub PR title and description, and must be edited in the GitHub web interface (not via git). For instructions, see [here](https://go.dev/wiki/GerritBot/#how-does-gerritbot-determine-the-final-commit-message). For guidelines on commit messages for the Go project, see [here](https://go.dev/doc/contribute#commit_messages).
(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Congratulations on opening your first change. Thank you for your contribution!
Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.
During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://go.dev/s/release
for more details.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
cmd/go: clear GOROOT for func ldShared when -trimpath is used
In commit [cmd: remove support for GOROOT_FINAL][1], it clear GOROOT
for func ld when -trimpath is used. [2]
This commit do the same thing for func ldShared, otherwise run go_bootstrap
with -trimpath does not remove build path directory from the generated share
libarary
$ ./make.bash --target-only --no-banner std
$ go_bootstrap install -linkshared -buildmode=shared -trimpath std
$ grep "$(pwd)" ./pkg/linux_amd64_dynlink/libstd.so
Binary file ./pkg/linux_amd64_dynlink/libstd.so matches
[1] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98
[2] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98#diff-cab5921f94f2667bb0bc1b935d2d46b4c03541b4351b33438ab7290b94dea212R669
diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go
index 3a173ef..8b7a44e 100644
--- a/src/cmd/go/internal/work/gc.go
+++ b/src/cmd/go/internal/work/gc.go
@@ -728,7 +728,14 @@
// the output file path is recorded in the .gnu.version_d section.
dir, targetPath := filepath.Split(targetPath)
- return b.Shell(root).run(dir, targetPath, nil, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags)
+ env := []string{}
+ // When -trimpath is used, GOROOT is cleared
+ if cfg.BuildTrimpath {
+ env = append(env, "GOROOT=")
+ } else {
+ env = append(env, "GOROOT="+cfg.GOROOT)
+ }
+ return b.Shell(root).run(dir, targetPath, env, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags)
}
func (gcToolchain) cc(b *Builder, a *Action, ofile, cfile string) error {
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
t hepuddsDuplicated with https://go-review.googlesource.com/c/go/+/653895
Hi, if this is duplicate, can you close the GitHub PR in the GitHub UI? That should automatically close this CL as well a few minutes later.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
CL seems to implement proposal https://github.com/golang/go/issues/69565 which is pending processing.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
CL seems to implement proposal https://github.com/golang/go/issues/69565 which is pending processing.
Is that the right proposal link? In any case we should have a link to the issue in the change description.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |