aboutsummaryrefslogtreecommitdiff
path: root/misc/cgo
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2022-09-21 15:51:27 -0400
committerMichael Matloob <matloob@golang.org>2022-10-28 23:35:08 +0000
commitb726b0cadb5102bb718f879bede0e76d1e5f5c34 (patch)
treed5e474a4699d75e73039ef92f73ed86d5920424f /misc/cgo
parent4c69d0eeb869cdc987e35d09a052a0e0320c0c96 (diff)
downloadgo-b726b0cadb5102bb718f879bede0e76d1e5f5c34.tar.gz
go-b726b0cadb5102bb718f879bede0e76d1e5f5c34.zip
cmd/go: don't install most GOROOT .a files in pkg
Packages in GOROOT that don't use cgo will not be installed in GOROOT/pkg, and will instead be cached as usual like other Go packages. - add a internal/buildinternal package to hold the identities of the five packages that use cgo - update dist's test code to do a go build std cmd before checking staleness on builders. Because most of those packages no longer have install locations, and have dependencies that don't either, the packages need to be cached to not be stale. - fix index_test to import packages with the path "." when preparing the "want" values to compare the indexed data to. (the module index matches the behavior of build.ImportDir, which always passes in "." as the path. - In both the index and go/build Importers, don't set PkgObj for GOROOT packages which will no longer have install targets. PkgTargetRoot will still be set to compute target paths, which will still be needed in buildmode=shared. - "downgrade" all install actions that don't have a target to build actions. (The target should already not be set for packages that shouldn't be installed). For #47257 Change-Id: Ia5aee6b3b20b58e028119cf0352a4c4a2f10f6b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/432535 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'misc/cgo')
-rw-r--r--misc/cgo/testshared/shared_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go
index 92c2166674..cd8a144d73 100644
--- a/misc/cgo/testshared/shared_test.go
+++ b/misc/cgo/testshared/shared_test.go
@@ -151,17 +151,17 @@ func testMain(m *testing.M) (int, error) {
myContext := build.Default
myContext.GOROOT = goroot
myContext.GOPATH = gopath
- runtimeP, err := myContext.Import("runtime", ".", build.ImportComment)
- if err != nil {
- return 0, fmt.Errorf("import failed: %v", err)
- }
- gorootInstallDir = runtimeP.PkgTargetRoot + "_dynlink"
// All tests depend on runtime being built into a shared library. Because
// that takes a few seconds, do it here and have all tests use the version
// built here.
goCmd(nil, append([]string{"install", "-buildmode=shared"}, minpkgs...)...)
+ shlib := goCmd(nil, "list", "-linkshared", "-f={{.Shlib}}", "runtime")
+ if shlib != "" {
+ gorootInstallDir = filepath.Dir(shlib)
+ }
+
myContext.InstallSuffix = "_dynlink"
depP, err := myContext.Import("./depBase", ".", build.ImportComment)
if err != nil {