summaryrefslogtreecommitdiff
path: root/src/cmd/go
Commit message (Collapse)AuthorAgeFilesLines
* cmd/go: add space after comma in 'go help test'Justin Traglia2022-07-252-2/+2
| | | | | | | | | | | | | | This PR fixes a simple typo. It adds a space after a comma. Noticed while looking at `go help test` output. Change-Id: I5b54f4da0d08a056bffc04899983d858dfa91043 GitHub-Last-Rev: da9cab5eb946523b8783aafe4f05f516e4a77437 GitHub-Pull-Request: golang/go#53931 Reviewed-on: https://go-review.googlesource.com/c/go/+/418034 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* cmd/compile: revert "remove -installsuffix flag"Matthew Dempsky2022-07-181-0/+3
| | | | | | | | | | | | | | This reverts CL 415236 (commit 558785a0a9df5fbb7e9617c05059cf2892884620). Reason for revert: Google's internal build system uses -installsuffix. Restoring -installsuffix for Go 1.19, and will try again for Go 1.20. Change-Id: Id6571f34f99f01bcf55e8e949e6fe7b6c1896134 Reviewed-on: https://go-review.googlesource.com/c/go/+/418036 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com>
* cmd/go/internal/modfetch: avoid duplicating path components in Git fetch errorsBryan C. Mills2022-07-143-11/+28
| | | | | | | | | | | Fixes #51114 Change-Id: Iebfe65f826b7b583ff2b48b8bc9d2eb23f2726af Reviewed-on: https://go-review.googlesource.com/c/go/+/386234 Reviewed-by: Valentin Deleplace <deleplace@google.com> Reviewed-by: Nooras Saba‎ <saba@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go: save zip sums for downloaded modules in 'go mod download' in a workspaceBryan C. Mills2022-07-142-9/+27
| | | | | | | | | | | | | | | | | | | | | Within a single module we expect all needed checksums to have already been recorded by a previous call to 'go get' or 'go mod tidy' in that module. However, when we combine multiple modules in a workspace, they may upgrade each other's dependencies, so a given module might be upgraded above the highest version recorded in the individual go.sum files for the workspace modules. Since the checksums might not be present in individual go.sum files, record them in go.work.sum. Fixes #51946. Change-Id: Icb4ea874b9e5c5b1950d42650974a24b5d6543d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/417654 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go: avoid re-enqueuing workspace dependencies with errorsBryan C. Mills2022-07-142-3/+61
| | | | | | | | | | | Fixes #53874. Change-Id: I41ab15cb9b86b807a9d9ad21fe21fb7aa5fbb46f Reviewed-on: https://go-review.googlesource.com/c/go/+/417594 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/compile: remove -installsuffix flagMatthew Dempsky2022-07-131-3/+0
| | | | | | | | | | | | | | | | | | Obsoleted by -importcfg. cmd/link has a similar flag, but it seems to still be needed at least for misc/cgo/testshared.TestGopathShlib. I can't immediately tell why (has something to do with finding .so files), but it doesn't appear to possibly affect cmd/compile. Updates #51225. Change-Id: I80c6aef860bd162c010ad4a1a4f532b400cf901c Reviewed-on: https://go-review.googlesource.com/c/go/+/415236 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: in script tests, avoid checking non-main packages for stalenessBryan C. Mills2022-07-122-15/+16
| | | | | | | | | | | | | | | | | | | | | Non-main packages in module mode should not be installed to GOPATH/pkg, but due to #37015 they were installed there anyway. Lacking a proper install location, 'go install' becomes a no-op for non-main packages in module mode. This change switches the 'go install' commands in the test_fuzz_cache and build_overlay tests to instead use 'go build', using the '-x' flag to check for compile commands instead of querying 'go list' about staleness. For #37015. Change-Id: I56d80cf2a43efb6163c62082c86cd3e4f0ff73c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/417095 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: avoid indexing GOROOT packages when the compiler is 'gccgo'Bryan C. Mills2022-07-121-0/+3
| | | | | | | | | | | | | | | | | | | | The gccgo compiler does not load standard-library packages from GOROOT/src, so we cannot load those packages from the GOROOT/src index when using that compiler. This fixes TestScript/gccgo_link_c (and perhaps other gccgo tests) when a 'gccgo' executable is present. Unfortunately, only a few builders caught the broken test because 'gccgo' is not installed on most Go project builders (see #35786). For #53577. Fixes #53815. Change-Id: I11a5cf6dbf4ac9893c4d02bd6ab7ef60f67b1e87 Reviewed-on: https://go-review.googlesource.com/c/go/+/417094 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: port TestIssue16471 to a script test and add verbose loggingBryan C. Mills2022-07-122-15/+22
| | | | | | | | | | | For #50471 Change-Id: I082c1f96113a3228f2ef423a04eaa9fbaa6c7522 Reviewed-on: https://go-review.googlesource.com/c/go/+/376359 Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go/internal/modfetch/codehost: add missing newline in '# lock' log messageBryan C. Mills2022-07-121-1/+1
| | | | | | | | | Change-Id: Ib92e983b6cdeed2b275a028c85b2bba583def059 Reviewed-on: https://go-review.googlesource.com/c/go/+/403850 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
* cmd/go/internal/modload: ignore disallowed errors when checking for updatesJay Conrod2022-07-123-1/+26
| | | | | | | | | | | | | | | | | | | | | | addUpdate calls Query with the query "upgrade". Normally, this returns the highest release version (or prerelease, etc.) that is higher than the current version and is not retracted or excluded. If there is no such version, Query should return the current version. If the current version is retracted or excluded, then Query currently returns an error. addUpdate should ignore this error, as it ignores ErrNotExist and NoMatchingVersionError. For 'go list -m -u', addRetraction is also called, and that will detect the retraction. Fixes #53594 Change-Id: I90a2872cdeabf03894acad9e0cbdd7db4a4e269e Reviewed-on: https://go-review.googlesource.com/c/go/+/414825 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* cmd/go: avoid spurious readdir during fsys.WalkRuss Cox2022-07-124-18/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fsys.Walk is cloned from filepath.Walk, which has always handled a walk of a directory by reading the full directory before calling the callback on the directory itself. So if the callback returns fs.SkipDir, those entries are thrown away, but the expense of reading them was still incurred. (Worse, this is the expensive directory read that also calls Stat on every entry.) On machines with slow file system I/O, these reads are particularly annoying. For example, if I do go list m... there is a call to filepath.Walk that is told about $GOROOT/src/archive and responds by returning filepath.SkipDir because archive does not start with m, but it only gets the chance to do that after the archive directory has been read. (Same for all the other top-level directories.) Even something like go list github.com/foo/bar/... reads every top-level $GOPATH/src directory. When we designed filepath.WalkDir, one of the changes we made was to allow calling the callback twice for a directory: once before reading it, and then possibly again if the read produces an error (uncommon). This CL changes fsys.Walk to use that same model. None of the callbacks need changing, but now the $GOROOT/src/archive and other top-level directories won't be read when evaluating a pattern like 'm...'. For #53577. Fixes #53765. Change-Id: Idfa3b9e2cc335417bfd9d66dd584cb16f92bd12e Reviewed-on: https://go-review.googlesource.com/c/go/+/416179 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: make module index loading O(1)Russ Cox2022-07-114-275/+327
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | For a large module, opening the index was populating tables with entries for every package in the module. If we are only using a small number of those packages, this is wasted work that can dwarf the benefit from the index. This CL changes the index reader to avoid loading all packages at module index open time. It also refactors the code somewhat for clarity. It also removes some duplication by defining that a per-package index is a per-module index containing a single package, rather than having two different formats and two different decoders. It also changes the string table to use uvarint-prefixed data instead of having to scan for a NUL byte. This makes random access to long strings more efficient - O(1) instead of O(n) - and can significantly speed up the strings.Compare operation in the binary search looking for a given package. Also add a direct test of the indexing code. For #53577. Change-Id: I7428d28133e4e7fe2d2993fa014896cd15af48af Reviewed-on: https://go-review.googlesource.com/c/go/+/416178 Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go: use package index for std in load.loadPackageDataRuss Cox2022-07-115-2/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | load.loadPackageData was only using an index for modules, not for standard library packages. Other parts of the code were using the index, so there was some benefit, but not as much as you'd hope. With the index disabled, the Script/work test takes 2.2s on my Mac. With the index enabled before this CL, it took 2.0s. With the index enabled after this CL, it takes 1.6s. Before this CL, the Script/work test issued: 429 IsDir 19 IsDirWithGoFiles 7 Lstat 9072 Open 993 ReadDir 256 Stat 7 Walk 3 indexModule 24 openIndexModule 525 openIndexPackage After this CL, it issued: 19 IsDirWithGoFiles 7 Lstat 60 Open 606 ReadDir 256 Stat 7 Walk 3 indexModule 24 openIndexModule 525 openIndexPackage This speedup helps the Dragonfly builder, which has very slow file I/O and is timing out since a recent indexing change. Times for go test -run=Script/^work$ on the Dragonfly builder: 50s before indexing changes 31s full module indexing of std 46s per-package indexing of std It cuts the time for go test -run=Script/^work$ from 44s to 20s. For #53577. Change-Id: I7189a77fc7fdf61de3ab3447efc4e84d1fc52c25 Reviewed-on: https://go-review.googlesource.com/c/go/+/416134 Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go: avoid setting variables for '/' and ':' in TestScript subprocess ↵Bryan C. Mills2022-07-083-18/+27
| | | | | | | | | | | | | | | | environments Also simplify platform-dependent handling of the PATH variable, to make it more like the existing platform-dependent handling for HOME and TMPDIR. Fixes #53671. Change-Id: Ica2665d3f61988c66fb6982b9feb61ca48eced79 Reviewed-on: https://go-review.googlesource.com/c/go/+/416554 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: default to "exe" build mode for windows -raceThan McIntosh2022-07-071-1/+5
| | | | | | | | | | | | | | | | | | This patch changes the default build mode from "pie" to "exe" when building programs on windows with "-race" in effect. The Go command already issues an error if users explicitly ask for -buildmode=pie in combination with -race on windows, but wasn't revising the default "pie" build mode if a specific buildmode was not requested. Updates #53539. Updates #35006. Change-Id: I2f81a41a1d15a0b4f5ae943146175c5a1202cbe0 Reviewed-on: https://go-review.googlesource.com/c/go/+/416174 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Than McIntosh <thanm@google.com>
* cmd/go: set up git identity for build_buildvcs_auto.txtDaniel Martí2022-07-061-0/+4
| | | | | | | | | | | | | | Just like in other tests like get_dotfiles.txt or version_buildvcs_git.txt. Without it, I get a failure on my machine: fatal: empty ident name (for <mvdan@p14s.localdomain>) not allowed Change-Id: I1c17c0d58c539b59154570b5438c7bd850bac5aa Reviewed-on: https://go-review.googlesource.com/c/go/+/416095 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* cmd/go: make module@nonexistentversion failures reusableRuss Cox2022-07-056-21/+136
| | | | | | | | | | | | | | | | | | | CL 411398 added the -reuse flag for reusing cached JSON output when the remote Git repository has not changed. One case that was not yet cached is a lookup of a nonexistent version. This CL adds caching of failed lookups of nonexistent versions, by saving a checksum of all the heads and tags refs on the remote server (we never consider other kinds of refs). If none of those have changed, then we don't need to download the full server. Fixes #53644. Change-Id: I428bbc8ec8475bd7d03788934d643e1e2be3add0 Reviewed-on: https://go-review.googlesource.com/c/go/+/415678 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: add -reuse flag to make proxy invocations more efficientRuss Cox2022-07-0515-65/+711
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The go list -m and go mod download commands now have a -reuse flag, which is passed the name of a file containing the JSON output from a previous run of the same command. (It is up to the caller to ensure that flags such as -versions or -retracted, which affect the output, are consistent between the old and new run.) The new run uses the old JSON to evaluate whether the answer is unchanged since the old run. If so, it reuses that information, avoiding a costly 'git fetch', and sets a new Reuse: true field in its own JSON output. This dance with saving the JSON output and passing it back to -reuse is not necessary on most systems, because the go command caches version control checkouts in the module cache. That cache means that a new 'git fetch' would only download the commits that are new since the previous one (often none at all). The dance becomes important only on systems that do not preserve the module cache, for example by running 'go clean -modcache' aggressively or by running in some environment that starts with an empty file system. For #53644. Change-Id: I447960abf8055f83cc6dbc699a9fde9931130004 Reviewed-on: https://go-review.googlesource.com/c/go/+/411398 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go: record origin metadata during module downloadRuss Cox2022-07-0512-121/+435
| | | | | | | | | | | | | | | | | | | | | | | | This change adds an "Origin" JSON key to the output of go list -json -m and go mod download -json. The associated value is a JSON object with metadata about the source control system. For Git, that metadata is sufficient to evaluate whether the remote server has changed in any interesting way that might invalidate the cached data. In most cases, it will not have, and a fetch could then avoid downloading a full repo from the server. This origin metadata is also now recorded in the .info file for a given module@version, for informational and debugging purposes. This change only adds the metadata. It does not use it to optimize away unnecessary git fetch operations. (That's the next change.) For #53644. Change-Id: I4a1712a2386d1d8ab4e02ffdf0f72ba75d556115 Reviewed-on: https://go-review.googlesource.com/c/go/+/411397 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go, go/build: clarify build constraint docsIan Lance Taylor2022-07-013-22/+22
| | | | | | | | | | | | | | | | | Clarify that the //go:build line is an expression of constraints, not a constraint itself. Fixes #53308 Change-Id: Ib67243c6ee5cfe3b688c12b943b5e7496f686035 Reviewed-on: https://go-review.googlesource.com/c/go/+/411697 Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
* cmd/go/internal/modindex: remove spurious field from index_format documentationBryan C. Mills2022-06-303-8/+7
| | | | | | | | | | | | | | | | The 'path' field was removed in an earlier revision to the format. While auditing the format, I also cleaned up a couple of minor typographical issues. For #53586. Change-Id: I4cd1ce9e970023441c11244428ed2971be1d8138 Reviewed-on: https://go-review.googlesource.com/c/go/+/415514 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: include module root in package index keyBryan C. Mills2022-06-302-3/+26
| | | | | | | | | | | | | | | | | | | The package index format includes the directory relative to the module root. The module root for a given directory can change even if the contents of the directory itself do not (by adding or removing a go.mod file in some parent directory). Thus, we need to invalidate the index for a package when its module root location changes. Fixes #53586 (I think). Change-Id: I2d9f4de80e16bce75b3106a2bad4a11d8378d037 Reviewed-on: https://go-review.googlesource.com/c/go/+/415475 Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: add a 'sleep' command for script testsBryan C. Mills2022-06-302-0/+21
| | | | | | | | | | | | | | | | | | Due to mtime skew we don't index mutable packages with an mtime younger than 2 seconds. In order to test indexed packages reliably, we want to be able to sleep long enough for the files in the package to be cached. (As an alternative we could instead use os.Chtimes to fake old enough timestamps, but sleeping keeps the tests more realistic.) For #53586. Change-Id: I1873f47c55a72d928451593b8c989f0092a557db Reviewed-on: https://go-review.googlesource.com/c/go/+/415474 Auto-Submit: 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>
* cmd/go: pass --no-decorate when listing git tags for a commithidu2022-06-282-1/+29
| | | | | | | | | | | | | | | | | This avoids a parse error when the user's global .gitconfig sets log.decorate to true. Fixes #51312. Change-Id: Ic47b0f604c0c3a404ec50d6e09f4e138045ac2f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/387835 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* cmd/go/internal/modfetch: cache latest revinfo in Versions funcBaokun Lee2022-06-281-8/+26
| | | | | | | | | | | | | | | | The responses have been cached by the web2 package before removed it in CL 170879. This change add latest revinfo cache in Versions func. Fixes #51391 Change-Id: I73597e0a6b4938238e69d85e1cbbaa9007776db3 Reviewed-on: https://go-review.googlesource.com/c/go/+/403335 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Lee Baokun <bk@golangcn.org> Reviewed-by: David Chase <drchase@google.com>
* cmd/go: omit build metadata that may contain system paths when -trimpath is setBryan C. Mills2022-06-282-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | CGO flag variables often include system paths for header files and compiled libraries. The point of -trimpath is to avoid dependending on system paths, so stamping these variables is counterproductive. Moreover, the point of stamping build information is to improve reproducibility. Since we don't also stamp the versions of C compilers, headers, and libraries used in a cgo build, only the most trivial cgo programs can be faithfully reproduced from the stamped information. Likewise, the -ldflags flag may include system-specific paths, particularly if external linking is in use. For now, we omit -ldflags entirely; however, in the future we may instead want to parse and redact the individual flags. Fixes #52372. Change-Id: I73318a01cce4371d66955b3261fc7ee58d4b33dd Reviewed-on: https://go-review.googlesource.com/c/go/+/409174 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go/internal/modload: fix doc commentRuss Cox2022-06-281-16/+15
| | | | | | | | Change-Id: Ib7f47c7fc2fa5db3adbe51612b1e7a9bb49647b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/411105 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: compile runtime/internal/syscall as a runtime packageMichael Pratt2022-06-271-9/+10
| | | | | | | | | | | | | | | | runtime/internal/syscall is a runtime package, so it should be built with -+. Specifically, we don't want libfuzzer instrumentation in Go functions defined in runtime/internal/syscall, which is disabled with -+. For #53190. Change-Id: I9f16f5c7c7ce10b98371e9de82fcea6da854e163 Reviewed-on: https://go-review.googlesource.com/c/go/+/413818 Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: add per-package indexing for modules outside mod cacheMichael Matloob2022-06-248-69/+242
| | | | | | | | | | | | | | Packages outside the module cache including the standard library will be indexed individually rather than as a whole module. For #52876 Change-Id: I142dad6a790e9e8eb4dc6430a588fbfa86552e49 Reviewed-on: https://go-review.googlesource.com/c/go/+/413815 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go/internal/list: update help info with Deprecated fieldSean Liao2022-06-242-26/+28
| | | | | | | | | | | | | | Also align Retracted documentation with actual type of []string Fixes #51876 Change-Id: I3b34e53424aa7ee5330eb71adac23510fff91798 Reviewed-on: https://go-review.googlesource.com/c/go/+/394677 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
* cmd/go: make module .zip files group/world readableDmitri Goutnik2022-06-221-1/+1
| | | | | | | | | | | | | | os.CreateTemp in downloadZip leaves downloaded .zip files readable only by the owner. Make them group/world readable. Fixes #52765 Change-Id: Iace13e4ad813201a533a1a5fc0c6d9b2e5349a42 Reviewed-on: https://go-review.googlesource.com/c/go/+/404854 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go, cmd/link: support failure to create _cgo_import.goIan Lance Taylor2022-06-222-10/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | For a package that uses cgo, the file _cgo_import.go is created to record information required for internal linking: the non-Go dynamic symbols and libraries that the package depends on. Generating this information sometimes fails, because it can require recreating all the dependencies of all transitively imported packages. And the information is rarely needed, since by default we use external linking when there are packages outside of the standard library that use cgo. With this CL, if generating _cgo_import.go fails, we don't report an error. Instead, we mark the package as requiring external linking, by adding an empty file named "dynimportfail" into the generated archive. If the linker sees a file with that name, it rejects an attempt to use internal linking. Fixes #52863 Change-Id: Ie586e6753a5b67e49bb14533cd7603d9defcf0ea Reviewed-on: https://go-review.googlesource.com/c/go/+/413460 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: avoid indexing modules in GOROOTBryan C. Mills2022-06-222-61/+11
| | | | | | | | | | | | | | | Scanning GOROOT modules for changes appears to be causing Windows builders to time out in x/tools tests. We may try a per-package index instead, but for now just skip GOROOT modules (as we do for main modules). Fixes #53493. Change-Id: Ic5bb90b4ce173a24fc6564e85fcde96e1f9b975f Reviewed-on: https://go-review.googlesource.com/c/go/+/413634 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go/internal/modindex: avoid walking modules when not neededBryan C. Mills2022-06-212-22/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to a missed condition in CL 412394, we were walking all modules (instead of just the ones contained in GOROOT) at each invocation of a devel version of cmd/go. Moreover, while we were running cmd/go tests, we were re-walking GOROOT at each 'go' invocation in the test even though we expect GOROOT to be stable within a test run. This change always avoids walking non-GOROOT modules, and also adds a salt (configurable via GODEBUG) and uses it to avoid walking GOROOT modules when GOROOT is known to be stable (such as over the course of a 'cmd/go' test run). This should fix the cmd/go test timeouts that are currently occurring on the dragonfly-amd64 builder, such as this one: https://build.golang.org/log/21c01c3ae5490d387d84abeaf872b3a0a76ab8e5 Updates #53290. Change-Id: Ic807d215831a3cd21c63e0bccd3d7acd10d8f2b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/412779 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go/internal/modfetch: prevent duplicate hashes in go.sumJosh Powers2022-06-172-0/+39
| | | | | | | | | | | | | | | | | | | To write go.sum, each module and then each hash is looped through. The hashes are kept in a slice and there is no check to ensure that hashes were not added or already exist in the file. Therefore, unique the hashes of each module before writing to prevent duplicates. Fixes: #28456 Change-Id: I1cf7e7cdee3e7530a0ee605cd76d738627be1e0d GitHub-Last-Rev: 0ed02e9591e966fe5f6ba275635c3974daa2656e GitHub-Pull-Request: golang/go#53291 Reviewed-on: https://go-review.googlesource.com/c/go/+/411154 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go/internal/work: log clearer detail for subprocess errors in ↵Bryan C. Mills2022-06-171-2/+5
| | | | | | | | | | | | | (*Builder).toolID For #52647. Change-Id: Ic12123769d339c2df677500ed59f15a4ee5037d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/412954 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* cmd/go: add more tracingMichael Matloob2022-06-163-0/+16
| | | | | | | | | Change-Id: I26ed64c097533ee9276e598653db72efc053c4e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/403156 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go: pass GOEXPERIMENT through to subtestsRuss Cox2022-06-161-0/+1
| | | | | | | | | | | | | | | | | | | | This fixes: export GOEXPERIMENT=unified go install cmd go install std cmd go install std cmd go test -short cmd/go -run=TestScript/test_relative_import_dash_i That script test checks that runtime is non-stale, but whether it's stale depends on the setting of GOEXPERIMENT. Stop filtering that variable out. Change-Id: I71bdbca495c16981cdcddf4ab4d87a38ca72a389 Reviewed-on: https://go-review.googlesource.com/c/go/+/412874 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
* cmd/go: parallelize matchPackages work in each moduleMichael Matloob2022-06-161-12/+26
| | | | | | | | | | | | | In each module matchPackages looks in, when doing the walk, do the scanDir call in a par.Queue so all the read work can be done in parallel. Change-Id: I27153dbb3a2ed417ca24972f47134e9e914a55d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/404097 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go/internal/modindex: disable indexing for modules outside GOROOT and ↵Bryan C. Mills2022-06-151-25/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the module cache Since CL 410821 we were indexing these modules with a cache key based on the mtimes of the files within the module. However, that seems to be causing test failures (#53269 and maybe #53371). In addition, indexing these modules caused a potentially-expensive operation (re-indexing a whole module) whenever any individual file within the module is changed, even if it isn't relevant to the package(s) being loaded from that module. In some cases, that could cause a significant performance regression for 'go' commands invoked on a small subset of the packages in the module (such as running 'go test' on a single changed package — a common case during development). Instead, we now index only those modules found within the module cache and within GOROOT. In addition, we now check mtimes when indexing GOROOT modules if the Go version begins with the string "devel ", which indicates a non-released Go version that may include local file edits within GOROOT. For #53371. For #53269. Change-Id: Id3aa81b55ecfc478e47dd420148d39d2cf476f2d Reviewed-on: https://go-review.googlesource.com/c/go/+/412394 Reviewed-by: Michael Matloob <matloob@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* cmd/go: quote package directory when calling globIan Lance Taylor2022-06-145-4/+42
| | | | | | | | | | | | | Fixes #53314 Change-Id: I4933b59ee247daec5cf96eb15c52ff54d3ec26a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/411696 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
* cmd/go/testdata/script: fix skip on list_replace_absolute_windowsMichael Matloob2022-06-081-1/+2
| | | | | | | | | | | | | | The test should skip if it's not on windows *or* it's a short test, but instead is now skipping if it's not on windows *and* it's a short test, causing it to be run on non-windows longtest builders. Change-Id: Ica011bab632b713b0564fefabd5b42878d401844 Reviewed-on: https://go-review.googlesource.com/c/go/+/411122 Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Michael Matloob <matloob@golang.org> Auto-Submit: Michael Matloob <matloob@golang.org>
* cmd/go: clean paths before using them form index functionsMichael Matloob2022-06-082-1/+39
| | | | | | | | | | | | | | | | We use str.TrimFilePathPrefix to trim the module root prefix and get the relative path of each package in the module when scanning the module and in the RelPath function. Make sure to clean the path before indexing and in RelPath to ensure that each path starts with that prefix, because walk will clean the root path before joining each subdirectory path to it. Change-Id: I1dc1eddbd42030eb6d5d8e76a8675f94216447c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/411118 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go: enable module index by defaultMichael Matloob2022-06-082-4/+10
| | | | | | | | | | | | | | | This changes the module index to be enabled by default, rather than disabled by default. The index can still be disabled by setting GODEBUG=index=0. Fixes #53290. Change-Id: Ic3728fc69d96bb6ef56b56e8c9f2dce35f2923cc Reviewed-on: https://go-review.googlesource.com/c/go/+/410821 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
* cmd/go: properly call PackageModuleRoot to get modroot for indexMichael Matloob2022-06-081-1/+1
| | | | | | | | | | | | PackageModuleRoot needs to be called with the package's path, not its directory on disk. Change-Id: I080fe8ce2aeb72e1466624db81595a00915606bb Reviewed-on: https://go-review.googlesource.com/c/go/+/410820 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org>
* cmd/go: set Root and target fields for packages in GOPATHMichael Matloob2022-06-082-14/+61
| | | | | | | | | | | | | | | | | | | This change replicates the behavior filed in issue #37015 for packages imported from the module index. That behavior is that packages that happen to exist in a GOPATH src directory have p.Root and p.Target set even when the packages are loaded from modules. This is likely unintentional behavior because in module mode, packages shouldn't behave differently depending on whether their directories exist in GOPATH. But for uniformity, (and because two of our tests depend on this behavior), this CL will implement this behavior. We can remove it from the module index when we remove it from the go/build logic. Change-Id: I3f501c92fbb76eaf86b6b9275539f2129b67f884 Reviewed-on: https://go-review.googlesource.com/c/go/+/410822 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: use index to match packages in dependency modulesMichael Matloob2022-06-063-4/+68
| | | | | | | | | | | If we're trying to search in a module in the module cache, instead iterate over the packages in the index. Change-Id: Ia94cbe6e9690110c28b93dbb33810680e3010381 Reviewed-on: https://go-review.googlesource.com/c/go/+/403756 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Peter Weinberger <pjw@google.com> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: boringcrypto post-merge cleanupRuss Cox2022-06-061-2/+2
| | | | | | | | | | | | | This CL addresses the comments on CL 403154. For #51940. Change-Id: I99bb3530916d469077bfbd53095bfcd1d2aa82ef Reviewed-on: https://go-review.googlesource.com/c/go/+/403976 Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* cmd/go: index standard library packagesMichael Matloob2022-06-044-28/+110
| | | | | | | | | Change-Id: I07594303a1e9833723522d5ff94577a5510ca6f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/404714 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>