aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
AgeCommit message (Collapse)Author
2025-07-22cmd/internal/objabi: remove redundant word in commentcuishuang
Change-Id: I9bbce94a2f36d5de28b946c94652876f01907fe6 Reviewed-on: https://go-review.googlesource.com/c/go/+/680115 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Sean Liao <sean@liao.dev>
2025-07-21cmd/compile: for arm64 epilog, do SP increment with a single instructionKeith Randall
That way, the frame is atomically popped. Previously, for big frames the SP was unwound in two steps (because arm64 can only add constants up to 1<<12 in a single instruction). Fixes #73259 Change-Id: I382c249194ad7bc9fc19607c27487c58d90d49e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/689235 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com>
2025-07-21cmd/go: check subcommand propertiesIan Alexander
This change corrects the properties checked by Lookup. We were inspecting the properties of the Command receiver; now we are inspecting the properties of the subcommand. Fixes #73864. Change-Id: Ieb462e489fc4f8f0568aa3a2d404b322d627166c Reviewed-on: https://go-review.googlesource.com/c/go/+/678655 Reviewed-by: Michael Matloob <matloob@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-07-19cmd/internal/obj: enable got pcrel itype in fips140 for riscv64Meng Zhuo
This CL enable R_RISCV_GOT_PCREL_ITYPE in fips140 Fixes #74662 Change-Id: Ic189c4e352517ae74034f207a5f944b610f2eb73 Reviewed-on: https://go-review.googlesource.com/c/go/+/688635 Reviewed-by: Mark Ryan <markdryan@rivosinc.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Julian Zhu <jz531210@gmail.com>
2025-07-19cmd/compile/internal/ssa: restrict architectures for TestDebugLines_74576thepudds
CL 687815 recently added TestDebugLines_74576. The pre-existing debug_lines_test.go file generally restricts the tested architectures and contains multiple warnings that the testing approach is useful but fragile, such as: "These files must all be short because this is super-fragile." Despite that, initially I wanted to see what happened on the different architectures on the trybots in case it might show something surprising, and I let TestDebugLines_74576 run on all architectures. That seemed to initially work, but the test is now failing on a linux/risc64 builder (#74669), so it is likely more prudent to be more conservative and restrict the platforms like many of the other pre-existing tests, which is what this CL now does. Fixes #74669 Change-Id: I9e5a7d3ee901f58253cf72e03c2239df338479e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/688856 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com>
2025-07-18go/types: infer correct type for y in append(bytes, y...)Alan Donovan
The type-checking logic for append has a special case for append(bytes, s...) where the typeset for s contains string. However, this case was triggering even when the typeset contained only []byte, causing the creation of Signature types of the form func([]byte, Y) []byte, with the variadic flag set, where Y is the type of Y (e.g. a type parameter constrained to ~[]byte). This is an illegal combination: a variadic signature's last parameter must be a slice, or its typeset must contain string. This caused x/tools/go/ssa to crash. This CL narrows the special case to only typesets that contain string, and adds a test for the inferred signature. (There's little point in testing that a subsequent NewSignatureType call would succeed, because the inferred type plainly has no free type parameters.) Fixes #73871 Change-Id: Id7641104133371dd6b0077f281cdaa9db84cc1c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/688815 Reviewed-by: Mark Freeman <mark@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-07-17cmd/compile/internal/escape: improve DWARF .debug_line numbering for literal ↵thepudds
rewriting optimizations The literal rewriting optimizations to reduce user allocations that were implemented in CL 649079 and related CLs like CL 684116 could produce .debug_line tables such that the line numbers sometimes jumped back to a variable's declaration. This CL adjusts the positions of the IR nodes to avoid this. For the first test added here in i74576a.go: 11 func main() { 12 a := 1 13 runtime.Breakpoint() 14 sink = a 15 } Without this fix, the test reports debug lines of 12, 13, 13, 12, 14. Note it goes backwards from 13 to a second 12. With this fix, the test reports debug lines of 12, 13, 13, 14 without going backwards. The test added in i74576b.go creates a slice via make with a non-constant argument, which similarly shows debug lines going backwards before this fix but not after. To address the slice make case, we create a new BasicLit node to then set its position. There were some related allocation optimizations for struct literals such as CL 649555 during the Go 1.25 dev cycle, but at least in some basic test cases, those optimizations did not seem to produce debug line issues. The struct literal interface conversion test added in i74576c.go has the same behavior before and after this change. Finally, running 'go test ./...' in the delve repo root (4a2a6e1aeb) seems to have many failures with go1.25rc2, but seems to pass with this CL. Fixes #74576 Updates #71359 Change-Id: I31faf5fe4bb352fdcd06bdc8606dbdbc4bbd65f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/687815 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
2025-07-16cmd/compile/internal/escape: speed up analyzing some functions with many ↵thepudds
closures Escape analysis examines functions in batches. In some cases, closures are in the same batch as their parent function, but in other cases, the closures are in different batches. This can mean the per-batch ir.ReassignOracle cache is not as effective. For example, #74615 has 4,000 closures in a single function that are all in different batches. For that example, these caches had an ~80% hit rate. This CL makes the ir.ReassignOracle cache more broadly scoped, instead of per batch. This speeds up escape analysis when a function has many closures that end up in different batches, including this resolves #74615. For that example, this cache now has a ~100% hit rate. In addition, in (*batch).rewriteWithLiterals, we also slightly delay checking the ir.ReassignOracle cache, which is more natural to do now compared to when rewriteWithLiterals was first merged. This means we can avoid consulting or populating the cache in more cases. (We also leave a new type-related TODO there. If we were to also implement that TODO, a quick test suggests we could independently resolve the specific example in #74615 even without making the cache more broadly scoped, though other conceivable examples would not be helped; the scoping of the cache is the more fundamental improvement.) If we look at cumulative time spent via pprof for the #74615 example using this CL, the work of ir.ReassignOracle escape analysis cache now typically shows zero cpu samples. This CL passes "go build -toolexec 'toolstash -cmp' -a std cmd". Fixes #74615 Change-Id: I3c17c527fbb546ffb8a4fa52cd61e41ff3cdb869 Reviewed-on: https://go-review.googlesource.com/c/go/+/688075 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-07-16cmd/link, runtime: on Wasm, put only function index in method table and func ↵Cherry Mui
table In the type descriptor's method table, it contains relative PCs of the methods (relative to the start of the text section) stored as 32-bit offsets. On Wasm, a PC is PC_F<<16 + PC_B, where PC_F is the function index, and PC_B is the block index. When there are more than 65536 functions, the PC will not fit into 32-bit (and relative to the section start doesn't help). Since there are no more bits for the function index, and the method table always targets the entry of a method, we put just the PC_F there, and rewrite back to a full PC at run time when we need the PC. This way we can have more than 65536 functions. The func table also contains 32-bit relative PCs, and it also always points to function entries. Do the same there, as well as other places where we use relative text offsets. Also add the relocation type in the relocation overflow error message. Also add check for function too big on Wasm. If a function has more than 65536 blocks, PC_B will overflow and PC = PC_F<<16 + PC_B will points to the wrong function. Fixes #64856. Change-Id: If9c307e9fb1641f367a5f19c39f88f455805d0bb Reviewed-on: https://go-review.googlesource.com/c/go/+/552835 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-07-16cmd/internal/obj/wasm: use 64-bit instructions for indirect callsCherry Mui
Currently, on Wasm, an indirect call is compiled to // function index = PC>>16, PC is already on stack I32WrapI64 I32Const $16 ShrU // set PC_B to 0 ... // actual call CallIndirect Specifically, the function index is extracted from bits 16-31 of the "PC". When there are more than 65536 functions, this will overflow and wrap around, causing wrong function being called. This CL changes it to use 64-bit operations to extract the function index from the "PC", so there are enough bits to for it. For #64856. Change-Id: I83c11db4b78cf66250e88ac02a82bd13730a8914 Reviewed-on: https://go-review.googlesource.com/c/go/+/567896 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-07-15cmd/internal/doc: upgrade godoc pkgsite to 01b046eMichael Matloob
Increase the dependency on the doc tool to bring in the fixes to CL 687918 and CL 687976. Fixes golang/go#74459 Change-Id: I9cdefdfd9792a142ad14bae3d4f7bb9d8256a246 Reviewed-on: https://go-review.googlesource.com/c/go/+/687997 Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-07-11cmd/link: do size fixups after symbol references are loadedCherry Mui
When we do a size fixup, we need to clone the symbol to an external symbol so we can modify it. This includes cloning the relocations, which includes resolving the relocations. If the symbol being fixed has a relocation referencing a non-Go symbol, that symbol has not yet been created, it will be resolved to an empty symbol. Load the references first, so the referenced symbol, even if it is a non-Go symbol, exists. Fixes #74537. Change-Id: I81525bd7c3e232b80eefeb0f18e13ba5331e1510 Reviewed-on: https://go-review.googlesource.com/c/go/+/687315 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2025-07-08cmd/go: disable support for multiple vcs in one moduleRoland Shoemaker
Removes the somewhat redundant vcs.FromDir, "allowNesting" argument, which was always enabled, and disallow multiple VCS metadata folders being present in a single directory. This makes VCS injection attacks much more difficult. Also adds a GODEBUG, allowmultiplevcs, which re-enables this behavior. Thanks to RyotaK (https://ryotak.net) of GMO Flatt Security Inc for reporting this issue. Fixes #74380 Fixes CVE-2025-4674 Change-Id: I5787d90cdca8deb3aca6f154efb627df1e7d2789 Reviewed-on: https://go-review.googlesource.com/c/go/+/686515 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Commit-Queue: Carlos Amedee <carlos@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-07-08cmd/compile: document that nosplit directive is unsafeIan Lance Taylor
For #74478 Change-Id: I902e9a92cdacb5ad6dafa9896640f8196ba1d56a Reviewed-on: https://go-review.googlesource.com/c/go/+/686115 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-07-08cmd/compile: run fmt on ssaJorropo
prove.go used to make my editor and precomit checks very unhappy. Change-Id: I25f7ffa2191480bc1b4f91fa91ccf3e4768045fa Reviewed-on: https://go-review.googlesource.com/c/go/+/685818 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-07-07cmd/internal/doc: fix GOROOT skew and path joining bugsMichael Matloob
Use the goCmd() function to get the go command to invoke, so that when GOROOT is set, the go command that's invoked uses the same GOROOT. Otherwise there will be skew between the go command and the tools and runtime. Also use the environment when determining GOPROXY and GOMODCACHE, and use url.Join so the slashes in 'http://' aren't collapsed into one. Change-Id: Ie36ca2fffdb015a7f5f9bd7f514850e41fad2c1a Reviewed-on: https://go-review.googlesource.com/c/go/+/685319 Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-07-07cmd/compile/internal/ssa: skip EndSequence entries in TestStmtLinesqmuntal
The TestStmtLines test has been accessing a nil pointer when it tries to look up LineEntry.File.Name on a line entry with EndSequence set to true. The doc for EndSequence specifies that if EndSequence is set, only it and the Address field are meaningful. Skip the entries with EndSequence set when building the set of files. I've reproduced this issue locally. Probably also fixes #49372, but will leave that for a follow-up CL. Fixes #74475 Updates #49372 Change-Id: Ic0664f7652b52a0a20239d13fe16454622740821 Reviewed-on: https://go-review.googlesource.com/c/go/+/685835 Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2025-07-02cmd/cgo/internal/testsanitizers: skip asan tests when FIPS140 mode is onqmuntal
Executing "GODEBUG=fips140=on go test -run TestASAN ./cmd/cgo/internal/testsanitizers" fails because FIPS 140 mode is incompatible with ASAN. Change-Id: I1a489f3398bbabf597fe7ffc0982c86c3b86e07e Reviewed-on: https://go-review.googlesource.com/c/go/+/685495 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-07-01cmd/go/internal/modindex: apply changes in CL 502615 to modindex packageMichael Matloob
CL 502615 modified go/build to check for invalid import paths, but did not make those changes to the corresponding code in the modindex package. Apply those changes here. We should try to deduplicate the code to prevent this from happening again. For #73976 For #74446 Change-Id: I69fc5e2c829efb818c9974ec8126807a1c8f7913 Reviewed-on: https://go-review.googlesource.com/c/go/+/685317 TryBot-Bypass: Michael Matloob <matloob@google.com> Auto-Submit: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-06-30cmd/compile/internal/escape: add debug hash for literal allocation optimizationsthepudds
Several CLs earlier in this stack added optimizations to reduce user allocations by recognizing and taking advantage of literals, including CL 649555, CL 649079, and CL 649035. This CL adds debug hashing of those changes, which enables use of the bisect tool, such as 'bisect -compile=literalalloc go test -run=Foo'. This also allows these optimizations to be manually disabled via '-gcflags=all=-d=literalallochash=n'. Updates #71359 Change-Id: I854f7742a6efa5b17d914932d61a32b2297f0c88 Reviewed-on: https://go-review.googlesource.com/c/go/+/675415 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-06-30cmd/compile/internal/escape: stop disabling literal allocation optimizations ↵thepudds
when coverage is enabled CL 649079 and CL 649035 updated escape analysis to rewrite certain expressions in OMAKE and OCONVIFACE nodes as optimizations to reduce user allocations. Part of the change in CL 649079 disabled those optimzations when coverage instrumentation was enabled under an incorrect possible theory of how those optimizations might be "expected" to change coverage results -- in particular, the cover_build_pkg_select.txt testscript failed with different coverage results. I now realize that the proper explanation is that my fix in CL 684116 was needed. Now that CL 684116 is merged, we should no longer disable these optimizations when coverage is enabled, which is what this CL does. This has not been reported as a problem to my knowledge, but without this CL, one could imagine for example a test using testing.AllocsPerRun might start failing when coverage was enabled if the result relied on these optimizations. As expected, if we place this CL just before the necessary fix in CL 684116, the cover_build_pkg_select.txt testscript fails with a changed coverage result. If we place this CL just after CL 684116, the test passes, also as expected. Updates #71359 Change-Id: Ib5ff00c267acd85dd423c238d177e91a4d881f9e Reviewed-on: https://go-review.googlesource.com/c/go/+/684777 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-06-29cmd/doc: fix -http on Windowsqmuntal
On Windows, GOMODCACHE almost never starts with a slash, and "go doc -http" constructs a GOPROXY URL by doing "file://" + GOMODCACHE, resulting in an invalid file URI. For example, if GOMODCACHE is "C:\foo", then the file URI should be "file:///C:/foo", but it becomes "file://C:/foo" instead, where "C:" is understood as a host name, not a drive letter. Fixes #74137. Change-Id: I23e776e0f649a0062e01d1a4a6ea8268ba467331 Reviewed-on: https://go-review.googlesource.com/c/go/+/684575 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-06-26cmd/link: permit a larger size BSS reference to a smaller DATA symbolCherry Mui
Currently, if there is a BSS reference and a DATA symbol definition with the same name, we pick the DATA symbol, as it contains the right content. In this case, if the BSS reference has a larger size, we error out, because it is not safe to access a smaller symbol as if it has a larger size. Sometimes code declares a global variable in Go and defines it in assembly with content. They are expected to be of the same size. However, in ASAN mode, we insert a red zone for the variable on the Go side, making it have a larger size, whereas the assembly symbol is unchanged. This causes the Go reference (BSS) has a larger size than the assembly definition (DATA). It results in an error currently. This code is valid and safe, so we should permit that. We support this case by increasing the symbol size to match the larger size (of the BSS side). The symbol content (from the DATA side) is kept. In some sense, we merge the two symbols. When loading symbols, it is not easy to change its size (as the object file may be mapped read-only), so we add it to a fixup list, and fix it up later after all Go symbols are loaded. This is a very rare case, so the list should not be long. We could limit this to just ASAN mode. But it seems okay to allow this in general. As long as the symbol has the larger size, it is safe to access it with the larger size. Fixes #74314. Change-Id: I3ee6e46161d8f59500e2b81befea11e563355a57 Reviewed-on: https://go-review.googlesource.com/c/go/+/684236 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2025-06-26cmd/compile/internal/escape: evaluate any side effects when rewriting with ↵thepudds
literals CL 649035 and CL 649079 updated escape analysis to rewrite certain operands in OMAKE and OCONVIFACE nodes from non-constant expressions to basic literals that evaluate to the same value. However, when doing that rewriting, we need to evaluate any side effects prior to replacing the expression, which is what this CL now does. Issue #74379 reported a problem with OCONVIFACE nodes due to CL 649079. CL 649035 has essentially the same issue with OMAKE nodes. To illustrate that, we add a test for the OMAKE case in fixedbugs/issue74379b.go, which fails without this change. To avoid introducing an unnecessary temporary for OMAKE nodes, we also conditionalize the main work of CL 649035 on whether the OMAKE operand is already an OLITERAL. CL 649555 and CL 649078 were related changes that created read-only global storage for composite literals used in an interface conversion. This CL adds a test in fixedbugs/issue74379c.go to illustrate that they do not have the same problem. Updates #71359 Fixes #74379 Change-Id: I6645575ef34f1fe2b0241a22dc205875d66b7ada Reviewed-on: https://go-review.googlesource.com/c/go/+/684116 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com>
2025-06-24cmd/link: add one more linkname to the blocklistCherry Mui
I missed one in the previous CL. Change-Id: I448a871523d7fb8f429b4482839d7f101ea003b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/681497 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-24go/types: add test for interface method field typeRob Findley
Add a test that would have detected the regression in #74303: interface method fields should have a recorded type. For #74303 Change-Id: Ide5df51cd71c38809c364bb4f95950163ecefb66 Reviewed-on: https://go-review.googlesource.com/c/go/+/683595 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Robert Findley <rfindley@google.com>
2025-06-23cmd/dist: test encoding/json/... with GOEXPERIMENT=jsonv2Joe Tsai
This also updates wasip1_wasm to use a 8MiB stack, which is the same stack size as what is used by go_js_wasm_exec. The increase of stack size is necessary because the jsonv2 tests exercise that the jsonv2 and jsontext packages support a hard limit of a maximum JSON nesting depth of 10000. However, even with a depth limit of 10000, this still exceeds the previously specified maximum stack size of 1 MiB. For use of JSON with untrusted inputs in WASM, we really need to support #56733 as there is no right answer for the default max depth limit to use since the max wasm stack size is determined on a per-system basis. Updates #71845 Change-Id: I3b32c58cc9f594a5c59bb3e4b20f5e86d85d8209 Reviewed-on: https://go-review.googlesource.com/c/go/+/683575 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-23Revert "go/types, types2: don't register interface methods in Info.Types map"Robert Findley
This reverts commit 4ac729283c807cdbe0f6c7041f21606019b722cf. Reason for revert: changes semantics of types.Info.TypeOf; introduces new inconsistency around FieldList types. For #74303 Change-Id: Ib99558c95f1b615fa9a02b028500ed230c8bb185 Reviewed-on: https://go-review.googlesource.com/c/go/+/683297 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-06-18cmd/go/internal/fips140: ignore GOEXPERIMENT on errorMichael Pratt
During toolchain selection, the GOEXPERIMENT value may not be valid for the current version (but it is valid for the selected version). In this case, cfg.ExperimentErr is set and cfg.Experiment is nil. Normally cmd/go main exits when ExperimentErr is set, so Experiment is ~never nil. But that is skipped during toolchain selection, and fips140.Init is used during toolchain selection. Fixes #74111. Change-Id: I6a6a636c65ee5831feaf3d29993a60613bbec6f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/680976 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Junyang Shao <shaojunyang@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2025-06-16cmd/dist: always include variant in package namesMichael Anthony Knyszek
Our attempt to evenly distribute tests across shards struggles a bit because certain long-running targets are very difficult to distinguish in ResultDB, namely racebench and the test directory tests. These are the only tests where the JSON output from dist omits the variant from the package, making it impossible to distinguish them in the test result data. My current suspicion is that this is preventing the load balancing from being effective for the race builders in particular, though I worry the longtest builders have a similar situation with the test directory tests. For #65814. Change-Id: I5804c2af092ff9aa4a3f0f6897b4a57c4628f837 Reviewed-on: https://go-review.googlesource.com/c/go/+/681955 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Bypass: Michael Knyszek <mknyszek@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-16internal/trace: make Value follow reflect conventionsMichael Anthony Knyszek
A previous change renamed Value.Uint64 to Value.ToUint64 to accomodate string values. The method for a string value is then Value.ToString, while the method for a debug string (for example, for fmt) is just called String, as per fmt.Stringer. This change follows a request from Dominik Honnef, maintainer of gotraceui, to make Value follow the conventions of the reflect package. The Value type there has a method String which fulfills both purposes: getting the string for a String Value, and as fmt.Stringer. It's not exactly pretty, but it does make sense to just stick to convention. Change-Id: I55b364be88088d2121527bffc833ef03dbdb9764 Reviewed-on: https://go-review.googlesource.com/c/go/+/680978 Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-06-13cmd/link: block new standard library linknamesCherry Mui
In Go 1.25 we added a number of new linknames for standard library internal uses. Add them to the linker's blocklist to keep them internal. Change-Id: I5b6051a669b7ff132a1d2c05deefbbf74701c5d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/681475 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-12all: replace a few user-visible mentions of golang.org and godoc.orgAlberto Donizetti
This change replaces a few user-visible mentions of golang.org and godoc.org with go.dev and pkg.go.dev, respectively. Non-user-visible mentions (e.g. in test scripts) were left untouched. Change-Id: I5d828edcd618b6c55243d0dfcadc6fa1ce9422ce Reviewed-on: https://go-review.googlesource.com/c/go/+/681255 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-11cmd/compile: add up-to-date test for generated filesDavid Chase
This runs the ssa/_gen generator writing files into a temporary directory, and then checks that there are no differences with what is currently in the ssa directory, and also checks that any file with the "generated from _gen/..." header was actually generated, and checks that the headers on the generated file match the expected header prefix. Change-Id: Ic8eeb0b06cf6f2e576a013e865b331a12d3a77aa Reviewed-on: https://go-review.googlesource.com/c/go/+/680615 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2025-06-10cmd/dist: only install necessary tools when doing local testMichael Matloob
Instead of installing all of cmd, install only the tools that cmd/dist would normally install. Also, remove the addition of the buildid tool to the list of commands in the toolchain in debug mode. The uses of buildid were removed in CL 451360. For #71867 Change-Id: I062909d23c18294aa23ea43b9f7eeb69bfa80c8c Reviewed-on: https://go-review.googlesource.com/c/go/+/680475 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Matloob <matloob@google.com>
2025-06-09cmd/compile/internal/ssa: fix PPC64 merging of (AND (S[RL]Dconst ...)Paul Murphy
CL 622236 forgot to check the mask was also a 32 bit rotate mask. Add a modified version of isPPC64WordRotateMask which valids the mask is contiguous and fits inside a uint32. I don't this is possible when merging SRDconst, the first check should always reject such combines. But, be extra careful and do it there too. Fixes #73153 Change-Id: Ie95f74ec5e7d89dc761511126db814f886a7a435 Reviewed-on: https://go-review.googlesource.com/c/go/+/679775 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2025-06-09cmd/internal/doc: increase version of pkgsite doc command that's runMichael Matloob
This will incorporate the changes in CL 675957, CL 677596, and CL 675958. For #73848 Change-Id: Ie3d313e055a36b5b7aafec4a7462a1ced8a9f923 Reviewed-on: https://go-review.googlesource.com/c/go/+/680176 Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-09cmd/compile: relax reshaping conditionCuong Manh Le
CL 641955 changes the Unified IR reader to not doing shapify when reading reshaping expression. However, this condition only matters with pointer type shaping, which will lose the original type, causes the reshaping ends up with a completely different type. This CL relaxes the condition, always allow non-pointer types shaping. Updates #71184 Fixes #73947 Change-Id: Ib0bafd8932c52d99266f311b6cbfc75c00383f9b Reviewed-on: https://go-review.googlesource.com/c/go/+/678335 Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-06-06all: update vendored dependencies [generated]Carlos Amedee
The Go 1.25 RC is due soon. This is the time to once again update all golang.org/x/... module versions that contribute packages to the std and cmd modules in the standard library to latest master versions. For #36905. [git-generate] go install golang.org/x/build/cmd/updatestd@latest go install golang.org/x/tools/cmd/bundle@latest updatestd -goroot=$(pwd) -branch=master cat << EOF | patch diff --git a/src/cmd/go/testdata/script/test_json_build.txt b/src/cmd/go/testdata/script/test_json_build.txt index df8863ae03..2a572ace72 100644 --- a/src/cmd/go/testdata/script/test_json_build.txt +++ b/src/cmd/go/testdata/script/test_json_build.txt @@ -56,7 +56,7 @@ stdout '"Action":"fail","Package":"m/cycle/p","Elapsed":.*,"FailedBuild":"m/cycl ! go test -json -o=$devnull ./veterror stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"# m/veterror\\n"' stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"# \[m/veterror\]\\n"' -stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"veterror(/|\\\\)main_test.go:9:9: fmt.Printf format %s reads arg #1, but call has 0 args\\n"' +stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"veterror(/|\\\\)main_test.go:9:21: fmt.Printf format %s reads arg #1, but call has 0 args\\n"' stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-fail"' stdout '"Action":"start","Package":"m/veterror"' stdout '"Action":"output","Package":"m/veterror","Output":"FAIL\\tm/veterror \[build failed\]\\n"' EOF Change-Id: I6a8d35acdeab90c3bbd6395b8b1abb021673b5cb Reviewed-on: https://go-review.googlesource.com/c/go/+/678556 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-06-04Revert "cmd/compile: Enable inlining of tail calls"Cherry Mui
This reverts CL 650455 and CL 655816. Reason for revert: it causes #73747. Properly fixing it gets into trickiness with defer/recover, wrapper, and inlining. We're late in the Go 1.25 release cycle. Fixes #73747. Change-Id: Ifb343d522b18fec3fec73a7c886678032ac8e4df Reviewed-on: https://go-review.googlesource.com/c/go/+/678575 Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2025-06-04cmd/trace: handle Sync event at the beginning of the traceMichael Anthony Knyszek
Currently the code assumes that there's no Sync event at the start of the trace, but this hasn't been correct for some time. Count Syncs and look for at least one instead of looking for zero. Fixes #73962. Change-Id: I2b4199a21c699c5b50b3d5add37dc46a515108c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/678555 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-06-04test: add another regression test for issue 73309Cuong Manh Le
Fixed #73309 Change-Id: Id715b9c71c95c92143a7fdb5a66b24305346dd3b Reviewed-on: https://go-review.googlesource.com/c/go/+/678415 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-06-04cmd/compile: better error message when import embed packageqiulaidongfeng
Fixes #73955 Change-Id: I7cf3ab4c70dc2e2765b54b88ae8cfc77a3073344 Reviewed-on: https://go-review.googlesource.com/c/go/+/678355 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-03cmd/dist: don't install tools that won't be shipped in distributionMichael Matloob
We shouldn't be installing these tools because we will remove them in distpack. Installing the tools will also prevent us from testing what happens when the tools are missing. The changes below this on the stack, CL 677775 (cmd/doc: build cmd/doc directly into the go command) and CL 677636 (cmd/go/internal/cfg: fix GOROOT setting when forcing host config) are needed for this change to pass tests. The doc change is being done so we preserve the properties in the tests that doc can be invoked without doing a build. It's not strictly necessary (we could just remove the tests) but it's nice to have. The GOROOT setting is a significant bug in switching the configuration to host mode: the value of GOROOT wasn't being reset, which caused issues for go commands built with trimpath, because runtime.GOROOT wouldn't have the correct goroot value. For #71867 Change-Id: I4181711ba117066b7d62d7d013ad4b186871cfb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/677558 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-06-03cmd/doc: build cmd/doc directly into the go commandMichael Matloob
There are a couple of places where our tests expect that 'go doc' doesn't need to do a build. Invoke the cmd/doc code directly by the go command instead of starting the doc tool in a separate process so we can preserve that property. This change moves most of the doc code into the package cmd/internal/doc, and exposes a Main function from that function that's called both by the cmd/doc package, and by go doc. This change makes couple of additional changes to intergrate doc into the go command: The counter.Open call and the increment of invocations counter are only needed by cmd/doc. The go command will open the counters file and increment a counter for the doc subcommand. We add a cmd_go_bootstrap tagged variant of the file that defines go doc so that we don't end up linking net into the bootstrap version of the go command. We don't need doc in that version of the command. We create a new flagSet rather than using flag.CommandLine because when running as part of the go command, the flags to "go doc" won't be the top level flags. We change TestGoListTest in go_test.go to use gofmt instead of doc as an example of a main package in cmd with an in-package test. For #71867 Change-Id: I3e3df83e5fa266559606fdc086b461165e09f037 Reviewed-on: https://go-review.googlesource.com/c/go/+/677775 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-06-03cmd/go/internal/cfg: fix GOROOT setting when forcing host configMichael Matloob
We manage the state using a bunch of global config, so we need to make sure we're doing things in the right order. In this case, the SetGOROOT function was being called in init, setting the GOROOT on the global Context, but when we reset the context in ForceHost we lost the goroot configuration. We need to call SetGOROOT in ForceHost to re-set the GOROOT on the new context. This was uncovered by CL 677558 because a go command that was built with trimpath would try to use its runtime.GOROOT(), which wouldn't be valid in trimpath mode. Setting GOROOT properly with SetGOROOT will use the value from findGOROOT, assuming GOROOT isn't set in the environment, and findGOROOT will try to determine GOROOT using the path of the go command executable. For #71867 Change-Id: I731b6c5d859b4504fc128b29ab904e3a2886ff3c Reviewed-on: https://go-review.googlesource.com/c/go/+/677636 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-06-02cmd/compile/internal/noder: document quirk of string elementsMark Freeman
Change-Id: Ifc3bf896aaaf7c6ce06a01e3dd43780d203638cf Reviewed-on: https://go-review.googlesource.com/c/go/+/677755 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Mark Freeman <mark@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
2025-06-02cmd/compile/internal/noder: stub type section and adjust othersMark Freeman
The type definition and object definition sections have nearly the same structure - help illustrate that through consistent naming. Change-Id: Ibed374fca4883a293a7fc16b36034e1acb38362a Reviewed-on: https://go-review.googlesource.com/c/go/+/677378 Auto-Submit: Mark Freeman <mark@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-02cmd/compile/internal/noder: begin filling in SectionObjMark Freeman
SectionObj has to encode the definition information for each object type, so it will be a bit long. Change-Id: I9b9514d58a284a4e64020f99fd1b2a92f7752338 Reviewed-on: https://go-review.googlesource.com/c/go/+/677377 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Mark Freeman <mark@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-02cmd/compile/internal/noder: fill in SectionNameMark Freeman
Change-Id: Ib99d40a546cb095c1b6c2d33e0735f3b5c681539 Reviewed-on: https://go-review.googlesource.com/c/go/+/677237 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Mark Freeman <mark@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>