summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* cmd/compile: enhance tighten pass for memory valueseric fang2023-05-163-7/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [This is a roll-forward of CL 458755, which was reverted due to make.bash being broken on GOAMD64=v3. But it turned out that the problem was caused by wrong bswap/load rewrite rules, and it was fixed in CL 492616.] This CL enhances the tighten pass. Previously if a value has memory arg, then the tighten pass won't move it, actually if the memory state is consistent among definition and use block, we can move the value. This CL optimizes this case. This is useful for the following situation: b1: x = load(...mem) if(...) goto b2 else b3 b2: use(x) b3: some_op_not_use_x For the micro-benchmark mentioned in #56620, the performance improvement is about 15%. There's no noticeable performance change in the go1 benchmark. Fixes #56620 Change-Id: I36ea68bed384986cd3ae81cb9e6efe84bb213adc Reviewed-on: https://go-review.googlesource.com/c/go/+/492895 Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Eric Fang <eric.fang@arm.com>
* os, syscall: permit setting mtime to Unix 0 on WindowsIan Lance Taylor2023-05-163-3/+33
| | | | | | | | | | | | | This edge case was accidentally broken by CL 219638. Change-Id: I673b3b580fbe379a04f8650cf5969fe9bce83691 Reviewed-on: https://go-review.googlesource.com/c/go/+/495036 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@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>
* Revert "net/http: do not force the Content-Length header if nilled"Austin Clements2023-05-152-35/+1
| | | | | | | | | | | | | | | This reverts CL 469095. The newly added TestDisableContentLength is failing on all longtest builders. Change-Id: Id307df61c7bf80691d9c276e8d200eebf6d4a59c Reviewed-on: https://go-review.googlesource.com/c/go/+/495017 Auto-Submit: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* log/slog: document that NewRecord should be used to create a recordJonathan Amsterdam2023-05-151-0/+1
| | | | | | | | Change-Id: I5ce32a94660bdf12c577fd7f41a7627469f6467b Reviewed-on: https://go-review.googlesource.com/c/go/+/494618 Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
* cmd/compile: update rules to generate more prefixed instructionsLynn Boger2023-05-154-141/+230
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This modifies some existing rules to allow more prefixed instructions to be generated when using GOPPC64=power10. Some rules also check if PCRel is available, which is currently supported for linux/ppc64le and linux/ppc64 (internal linking only). Prior to p10, DS-offset loads and stores had a 16 bit size limit for the offset field. If the offset of the data for load or store was beyond this range then an indexed load or store would be selected by the rules. In p10 the assembler can generate prefixed instructions in this case, but does not if an indexed instruction was selected during the lowering pass. This allows many more cases to use prefixed loads or stores, reducing function sizes and improving performance in some cases where the code change happens in key loops. For example in strconv BenchmarkAppendQuoteRune before: 12c5e4: 15 00 10 06 pla r10,1425660 12c5e8: fc c0 40 39 12c5ec: 00 00 6a e8 ld r3,0(r10) 12c5f0: 10 00 aa e8 ld r5,16(r10) After this change: 12a828: 15 00 10 04 pld r3,1433272 12a82c: b8 de 60 e4 12a830: 15 00 10 04 pld r5,1433280 12a834: c0 de a0 e4 Performs better in the second case. A testcase was added to verify that the rules correctly select a load or store based on the offset and whether power10 or earlier. Change-Id: I4335fed0bd9b8aba8a4f84d69b89f819cc464846 Reviewed-on: https://go-review.googlesource.com/c/go/+/477398 Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Archana Ravindar <aravind5@in.ibm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Paul Murphy <murp@ibm.com>
* net/http: handle WriteHeader(101) as a non-informational headerDamien Neil2023-05-152-2/+74
| | | | | | | | | | | | | | | | | | | | | | Prior to Go 1.19 adding support for sending 1xx informational headers with ResponseWriter.WriteHeader, WriteHeader(101) would send a 101 status and disable further writes to the response. This behavior was not documented, but is intentional: Writing to the response body explicitly checks to see if a 101 status has been sent before writing. Restore the pre-1.19 behavior when writing a 101 Switching Protocols header: The header is sent, no subsequent headers are sent, and subsequent writes to the response body fail. For #59564 Change-Id: I72c116f88405b1ef5067b510f8c7cff0b36951ee Reviewed-on: https://go-review.googlesource.com/c/go/+/485775 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net/http: do not force the Content-Length header if nilledLaurent Senta2023-05-152-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | According to the ResponseWriter documentation: To suppress automatic response headers (such as "Date"), set their value to nil. In some cases, this documentation is incorrect: chunkWriter writes a Content-Length header even if the value was set to nil. Meaning there is no way to suppress this header. This patch replaces the empty string comparison with a call to `header.has` which takes into account nil values as expected. This is similar to the way we handle the "Date" header. Change-Id: Ie10d54ab0bb7d41270bc944ff867e035fe2bd0c5 GitHub-Last-Rev: e0616dd46388a724df7c6ea821b3808ed1663cab GitHub-Pull-Request: golang/go#58578 Reviewed-on: https://go-review.googlesource.com/c/go/+/469095 Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Damien Neil <dneil@google.com> Run-TryBot: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Damien Neil <dneil@google.com>
* cmd/go/internal/modload: replace import error message from goroot to stdjchen0382023-05-159-16/+16
| | | | | | | | | | | | | | | When importing a package that does not exist, it would show goroot error message and path. We would like to replace goroot with std instead. Fixes #56965. Change-Id: I86f8a7fab6555b68f792a3a4686de20d51eced8b Reviewed-on: https://go-review.googlesource.com/c/go/+/453895 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@google.com>
* misc: remove misc/arm/a scriptAustin Clements2023-05-151-58/+0
| | | | | | | | | | | | | This appears to be a very old wrapper around adb for testing on Android before we had the go_android_exec wrapper. Change-Id: I847bb15c98febbcffc063f00719a084e5c99a18b Reviewed-on: https://go-review.googlesource.com/c/go/+/493604 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
* cmd/cgo: enable test with non-sensible build tagAustin Clements2023-05-151-1/+1
| | | | | | | | | | | | | | | The build tag on this file is currently unsatisfiable. It was clearly supposed to be "linux || freebsd || openbsd", but the test doesn't actually compile on FreeBSD or OpenBSD because they don't define SYS_gettid. Change the build tag to just "linux". Change-Id: Ifaffac5438e1b94a8588b5a00435461aa171a6fc Reviewed-on: https://go-review.googlesource.com/c/go/+/493603 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* os, syscall: support ill-formed UTF-16 strings on Windowsqmuntal2023-05-1512-36/+402
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Windows UTF-16 strings can contain unpaired surrogates, which can't be decoded into a valid UTF-8 string. This file defines a set of functions that can be used to encode and decode potentially ill-formed UTF-16 strings by using the [the WTF-8 encoding](https://simonsapin.github.io/wtf-8/). WTF-8 is a strict superset of UTF-8, i.e. any string that is well-formed in UTF-8 is also well-formed in WTF-8 and the content is unchanged. Also, the conversion never fails and is lossless. The benefit of using WTF-8 instead of UTF-8 when decoding a UTF-16 string is that the conversion is lossless even for ill-formed UTF-16 strings. This property allows to read an ill-formed UTF-16 string, convert it to a Go string, and convert it back to the same original UTF-16 string. Fixes #59971 Change-Id: Id6007f6e537844913402b233e73d698688cd5ba6 Reviewed-on: https://go-review.googlesource.com/c/go/+/493036 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Paul Hampson <Paul.Hampson@Pobox.com>
* cmd/go/internal/modindex: update index_format.txtBryan C. Mills2023-05-132-8/+14
| | | | | | | | | | | | | | | | This incorporates the changes from CL 453603 and CL 416178. Please review carefully: I did my best to read through the CLs, but I'm not entirely confident I haven't made a mistake. Fixes #59770. Change-Id: Ib8937e55dcd11e3f75c16b28519d3d91df1d4da3 Reviewed-on: https://go-review.googlesource.com/c/go/+/492596 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/link: fix checks for supported linker flags with relative paths.James Bartlett2023-05-121-2/+3
| | | | | | | | | | | | | | | | The existing way of checking for supported linker flags causes false negatives when there are relative paths passed to go tool link. This fixes the issue by calling the external linker in the current working directory, instead of in a temporary directory. Fixes #59952 Change-Id: I173bb8b44902f30dacefde1c202586f87667ab70 Reviewed-on: https://go-review.googlesource.com/c/go/+/491796 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* cmd/dist: use registerStdTestSpecially for normal Go tests onlyDmitri Shuralyov2023-05-121-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It was my oversight in CL 463276 to skip registerStdTestSpecially packages in the race bench test registration loop. Package testdir has no benchmarks and doesn't need to be skipped. (And if it had benchmarks, it's very unlikely they'd need any special handling.) By now there are more cmd/cgo/internal/... packages that are registered specially, and there isn't a need for their few benchmarks not to be used for the purpose of race bench tests. If the 3 benchmarks in cmd/cgo/internal/test were to require something special, then we can add it to a new registerRaceBenchTestSpecially map with a comment, and do register them specially in registerTests instead of forgetting to. This restores the automatic 'go_test_bench:cmd/cgo/internal/test' registration and reduces prevalence of registerStdTestSpecially a bit. For #37486. For #56844. Change-Id: I1791fe5bf94cb4b4e0859c5fff4e7a3d5a23723e Reviewed-on: https://go-review.googlesource.com/c/go/+/494656 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
* test: add escape test for reflect.Value operationsCherry Mui2023-05-121-0/+462
| | | | | | | | | | | | | | | | | | With CL 408826 reflect.Value does not always escape. We need to make sure Value operations does (or does not) escape the Value correctly. This CL adds a test. There are still a few unfortunate cases, where some Value operations escape more than necessary (comparing to a non-reflect version of the code), but hard to fix. These are mostly that a Value would escape conditionally (mostly on the type of the Value), but currently we don't have a good way to express that. Change-Id: I9fdfc7584670aa09c5a01f6b2803f2043aaddb65 Reviewed-on: https://go-review.googlesource.com/c/go/+/441938 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
* os, runtime: remove unused implementations of os.sigpipeIan Lance Taylor2023-05-124-12/+2
| | | | | | | | | | | | | | | Clean up instances that are unused since CL 6450058. Change-Id: I0e9ae28cfa83fcc8abda8f5eca9c7dfc2c1c4ad1 Reviewed-on: https://go-review.googlesource.com/c/go/+/477396 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
* reflect: make Value.IsZero not escapeCherry Mui2023-05-121-2/+6
| | | | | | | | | | | | | | With CL 408826 reflect.Value not always escape. IsZero still escapes the Value because in some cases it passes the Value pointer to the equal function, which is function pointer. Equal functions are compiler generated and never escapes, but the escape analysis doesn't know. Add noescape to help. Change-Id: Ica397c2be77cac9e8a46d03d70bac385b0aa9e82 Reviewed-on: https://go-review.googlesource.com/c/go/+/441937 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* reflect: do not escape Value.TypeCherry Mui2023-05-127-122/+170
| | | | | | | | | | | | | | | | | | | Types are either static (for compiler-created types) or heap allocated and always reachable (for reflection-created types, held in the central map). So there is no need to escape types. With CL 408826 reflect.Value does not always escape. Some functions that escapes Value.typ would make the Value escape without this CL. Had to add a special case for the inliner to keep (*Value).Type still inlineable. Change-Id: I7c14d35fd26328347b509a06eb5bd1534d40775f Reviewed-on: https://go-review.googlesource.com/c/go/+/413474 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* reflect: allow Value be stack allocatedCherry Mui2023-05-123-16/+69
| | | | | | | | | | | | | | | | | | | Currently, reflect.ValueOf forces the referenced object to be heap allocated. This CL makes it possible to be stack allocated. We need to be careful to make sure the compiler's escape analysis can do the right thing, e.g. channel send, map assignment, unsafe pointer conversions. Tests will be added in a later CL. CL 408827 might help ensure the correctness. Change-Id: I8663651370c7c8108584902235062dd2b3f65954 Reviewed-on: https://go-review.googlesource.com/c/go/+/408826 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
* cmd/compile: remove post-inlining PGO graph dumpMichael Pratt2023-05-122-100/+0
| | | | | | | | | | | | | | | | | | | The RedirectEdges logic is fragile and not quite complete (doesn't update in-edges), which adds overhead to maintaining this package. In my opinion, the post-inlining graph doesn't provide as much value as the pre-inlining graph. Even the latter I am not convinced should be in the compiler rather than an external tool, but it is comparatively easier to maintain. Drop it for now. Perhaps we'll want it back in the future for tracking follow-up optimizations, but for now keep things simple. Change-Id: I3133a2eb97893a14a6770547f96a3f1796798d17 Reviewed-on: https://go-review.googlesource.com/c/go/+/494655 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Michael Pratt <mpratt@google.com>
* cmd/compile/internal/pgo: remove node weights from IRNodeMichael Pratt2023-05-121-66/+32
| | | | | | | | | | | | | | | | | | | | | | | Actual PGO operation doesn't use these weights at all. They are theoretically used when printing a dot graph for debugging, but that doesn't actually work because these weights are always zero. These fields are initialized by looking for a NodeMap entry with key {CallerName: sym, CalleeName: "", CallSiteOffset: 0}. These entries will never exist, as we never put entries in NodeMap without CalleeName. Since they aren't really used and don't work, just remove them entirely, which offers nice simplification. This leaves IRNode with just a single field. I keep the type around as a future CL will make the *ir.Func optional, allowing nodes with a name but no IR. Change-Id: I1646654cad1d0779ce071042768ffad2a7e6ff49 Reviewed-on: https://go-review.googlesource.com/c/go/+/494616 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Michael Pratt <mpratt@google.com>
* time: update windows zoneinfo_abbrsCarlos Amedee2023-05-122-4/+4
| | | | | | | | | | | | | | | | | | | | The primary branch of the github.com/unicode-org/cldr repository has changed to main instead of master. This changes the branch used to download the Windows zone file. Ran: go generate time For #58113 Change-Id: Idb3dcaf44fc52d4b6abfed5a3ca6cd6f745dc3f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/493477 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Auto-Submit: Carlos Amedee <carlos@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Carlos Amedee <carlos@golang.org>
* cmd/cgo/internal/testcarchive: build on all platformsAustin Clements2023-05-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | This test package uses syscall.SIGSEGV and syscall.SIGPIPE, which are defined on most, but not all platforms. Normally this test runs as part of dist test, which only registers this test on platforms that support c-archive build mode, which includes all platforms that define these signals. But this doesn't help if you're just trying to type check everything in cmd. Add build constraints so that this package type checks on all platforms. Fixes #60164. Updates #37486. Change-Id: Id3f9ad4cc9f80146de16aedcf85d108a77215ae6 Reviewed-on: https://go-review.googlesource.com/c/go/+/494659 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Austin Clements <austin@google.com> Auto-Submit: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/cgo/internal/testsanitizers: build on all platformsAustin Clements2023-05-128-5/+24
| | | | | | | | | | | | | | | | | | | | | | This test package uses the Pdeathsig field of syscall.SysProcAttr, which is only available on a few platforms. Currently, dist test checks for compatible platforms and only registers it as part of all.bash on platforms where it can build. But this doesn't help if you're just trying to type check everything in cmd. Make this package pass type checking by moving the condition from dist into build tags on the test package itself. For #60164. Updates #37486. Change-Id: I58b12d547c323cec895320baa5fca1b82e99d1b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/494658 Auto-Submit: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com>
* net: add tests for forceGoDNS and forceCgoDNSMateusz Poliwczak2023-05-121-0/+21
| | | | | | | | | | | | | | | | There was a bug in forceCgoDNS (CL 479416), it was fixed by CL 487196, so add a test case for it. Change-Id: I2010374451ef236dc2898d9e9ea006eb8b40d02e GitHub-Last-Rev: 34a84fad33404c66c3ee20cb63803214c42e991d GitHub-Pull-Request: golang/go#59922 Reviewed-on: https://go-review.googlesource.com/c/go/+/491255 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* cmd/internal/bootstrap_test: update TestExperimentToolID for Go 1.21Dmitri Shuralyov2023-05-122-29/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | This test is configured to run only when explicitly requested due to being costly. Apply two updates so it can run on the toolchain today: - overlay GOROOT/lib for zoneinfo.zip (similarly to CL 462279) - stop expecting framepointer to be listed in the GOEXPERIMENT section of the compiler version (see CL 49252 and CL 249857) I checked if by now there's another test that would report a problem if the fix made in CL 186200 had regressed. Running all.bash locally with GO_TEST_SHORT=0 GO_BUILDER_NAME=darwin-arm64-longtest passed ok, while this manual test did catch the problem. Also simplify the test implementation while here so it's less different from TestRepeatBootstrap. For #33091. Change-Id: I14eea18c19c2e8996bcba31c80e03dcf679f56ab Reviewed-on: https://go-review.googlesource.com/c/go/+/493475 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* cmd/go: add a regression test for Git configurations with ↵Bryan C. Mills2023-05-121-0/+19
| | | | | | | | | | | | safe.bareRepository=explicit Change-Id: I394265a4bf849ec89ac44c67aeaaaca801e46caa Reviewed-on: https://go-review.googlesource.com/c/go/+/493476 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Emily Shaffer <emilyshaffer@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go/internal/modload: reject the -modfile flag in workspace modeZeke Lu2023-05-127-14/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, in workspace mode, the -modfile flag affects all the modules listed in the go.work file. This is not desirable most of the time. And when it results in an error, the error message does not help. For example, when there are more than one modules listed in the go.work file, running "go list -m -modfile=path/to/go.mod" gives this error: go: module example.com/foo appears multiple times in workspace This change reject -modfile flag explicitly with this error message: go: -modfile cannot be used in workspace mode While at here, correct some typos in the modload package. Fixes #59996. Change-Id: Iff4cd9f3974ea359889dd713a747b6932cf42dfd GitHub-Last-Rev: 7dbc9c3f2f9bfe8acab088eb3266a08d8ec1ba16 GitHub-Pull-Request: golang/go#60033 Reviewed-on: https://go-review.googlesource.com/c/go/+/493315 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
* strings: correct NewReader documentationJabar Asadi2023-05-121-1/+1
| | | | | | | | | | | | | | | | | | | The provided description for `NewReader` says that the underlying string is read-only. but the following example shows that this is not the case. <br /> rd := strings.NewReader("this is a text") rd.Reset("new text") <--- underlying string gets updated here Change-Id: I95c7099c2e63670c84307d4317b702bf13a4025a GitHub-Last-Rev: a16a60b0f1e25d19e05e664c5b41ca57c4fcd9b2 GitHub-Pull-Request: golang/go#60074 Reviewed-on: https://go-review.googlesource.com/c/go/+/493817 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* internal/testdir: move to cmd/internal/testdirDmitri Shuralyov2023-05-124-5/+5
| | | | | | | | | | | | | | | | | | The effect and motivation is for the test to be selected when doing 'go test cmd' and not when doing 'go test std' since it's primarily about testing the Go compiler and linker. Other than that, it's run by all.bash and 'go test std cmd' as before. For #56844. Fixes #60059. Change-Id: I2d499af013f9d9b8761fdf4573f8d27d80c1fccf Reviewed-on: https://go-review.googlesource.com/c/go/+/493876 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* go/types: minor refactoring of missingMethod following CL 494615Rob Findley2023-05-122-8/+14
| | | | | | | | | | Make the refactoring suggested by gri@ in that CL. Change-Id: I6c363f3ba5aaa3c616d3982d998b989de7046a86 Reviewed-on: https://go-review.googlesource.com/c/go/+/494617 Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: call recordInstance in instantiateSignatureRobert Griesemer2023-05-122-38/+24
| | | | | | | | | | | | | This matches the pattern we use for type instantiations and factors out the recordInstance and associated assert calls. Change-Id: Ib7731c0e619aca42f418cb2d9a153785aaf014cb Reviewed-on: https://go-review.googlesource.com/c/go/+/494457 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com>
* go/types, types2: be sure to type-check wrong methods in missingMethodRob Findley2023-05-123-0/+18
| | | | | | | | | | | | | | | | In the case of a wrong method, we were not ensuring that it was type-checked before passing it to funcString. Formatting the missing method error message requires a fully set-up signature. Fixes #59848 Change-Id: I1467e036afbbbdd00899bfd627a945500dc709c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/494615 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
* cmd/go: diff .so files quietly in TestScript/build_plugin_reproducibleDmitri Shuralyov2023-05-121-1/+1
| | | | | | | | | | | | | | | This avoids printing verbose binary data and making bell sounds when the test fails. The binary data can be inspected via other means if needed. For #58557. Change-Id: Ia1c4f2c6b9ff2cf6f97611cf335b978fc7bb201f Reviewed-on: https://go-review.googlesource.com/c/go/+/494577 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* runtime: remove unused skip arg from fpTracebackPCsFelix Geisendörfer2023-05-123-7/+7
| | | | | | | | | | | | This was accidentally left behind when moving the logic to set the skip sentinel in pcBuf to the caller. Change-Id: Id7565f6ea4df6b32cf18b99c700bca322998d182 Reviewed-on: https://go-review.googlesource.com/c/go/+/489095 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
* Revert "reflect: change rtype so that it (not *rtype) implements Type"Austin Clements2023-05-126-146/+139
| | | | | | | | | | | | This reverts CL 487558, which is causing test failures in Google. See b/282133554. Change-Id: Icafa4ffc6aaa24a363abb90b8ae0b0183aca2b89 Reviewed-on: https://go-review.googlesource.com/c/go/+/494410 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Austin Clements <austin@google.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Austin Clements <austin@google.com>
* cmd/dist: drop goTest.dirAustin Clements2023-05-121-29/+23
| | | | | | | | | | | | At this point all tests are regular packages in std or cmd, so we no longer need goTest.dir. Change-Id: I46a0c7b4464b0738e9959e41bf840ba1b73e3590 Reviewed-on: https://go-review.googlesource.com/c/go/+/494194 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
* test/bench: deleteAustin Clements2023-05-1225-3765/+0
| | | | | | | | | | | | | | | | | | | | Russ added test/bench/go1 in CL 5484071 to have a stable suite of programs to use as benchmarks. For the compiler and runtime we had back then, those were reasonable benchmarks, but the compiler and runtime are now far more sophisticated and these benchmarks no longer have good coverage. We also now have better benchmark suites maintained outside the repo (e.g., golang.org/x/benchmarks). Keeping test/bench/go1 at this point is actively misleading. Indirectly related to #37486, as this also removes the last package dist test runs outside of src/. Change-Id: I2867ef303fe48a02acce58ace4ee682add8acdbf Reviewed-on: https://go-review.googlesource.com/c/go/+/494193 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/reboot: move to cmd/internal/bootstrap_testAustin Clements2023-05-124-16/+12
| | | | | | | | | | | | | This is the last test run from misc by dist. For #37486. Change-Id: I1a70ded29ba0de548c9a16611ba987a258121e80 Reviewed-on: https://go-review.googlesource.com/c/go/+/493606 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/dist: drop host test supportAustin Clements2023-05-127-111/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Host tests are used for emulated builders that use cross-compilation. Today, this is the android-{386,amd64}-emu builders and all wasm builders. These builders run all.bash on a linux/amd64 host to build all packages and most tests for the emulated guest, and then run the resulting test binaries inside the emulated guest. A small number of test packages are “host tests”: these run on the host rather than the guest because they invoke the Go toolchain themselves (which only lives on the host) and run the resulting binaries in the guest. However, this host test mechanism is barely used today, despite being quite complex. This complexity is also causing significant friction to implementing structured all.bash output. As of this CL, the whole host test mechanism runs a total of 10 test cases on a total of two builders (android-{386,amd64}-emu). There are clearly several tests that are incorrectly being skipped, so we could expand it to cover more test cases, but it would still apply to only two builders. Furthermore, the two other Android builders (android-{arm,arm64}-corellium) build the Go toolchain directly inside Android and also have access to a C toolchain, so they are able to get significantly better test coverage without the use of host tests. This suggests that the android-*-emu builders could do the same. All of these tests are cgo-related, so they don't run on the wasm hosts anyway. Given the incredibly low value of host tests today, they are not worth their implementation complexity and the friction they cause. Hence, this CL drops support for host tests. (This was also the last use of rtSequential, so we drop support for sequential tests, too.) Fixes #59999. Change-Id: I3eaca853a8907abc8247709f15a0d19a872dd22d Reviewed-on: https://go-review.googlesource.com/c/go/+/492986 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/dist,internal/testdir: more cooperative host test mechanismAustin Clements2023-05-122-11/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | On cross-compiling builder machines, we run internal/testdir on the host, where it can access the Go toolchain to build binaries for the guest and run them through an exec wrapper. Currently this uses dist test's existing host test mechanism, which is quite complicated and we are planning to eliminate (#59999). Switch internal/testdir to use a more cooperative mechanism. With this CL, dist still understands that it has to build and run the test using the host GOOS/GOARCH, but rather than doing complicated manipulation of environment variables itself, it passes the guest GOOS/GOARCH to the test, which can easily inject it into its environment. This means dist test can use "go test" directly, rather than having to split up the build and run steps. For #37486. Change-Id: I556938c0b641960bb778b88b13f2b26256edc7c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/492985 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* test,internal/testdir: don't set GOOS/GOARCHAustin Clements2023-05-122-13/+8
| | | | | | | | | | | | | | | | | | The test directory driver currently sets the GOOS/GOARCH environment variables if they aren't set. This appears to be in service of a single test, test/env.go, which was introduced in September 2008 along with os.Getenv. It's not entirely clear what that test is even trying to check, since runtime.GOOS isn't necessarily the same as $GOOS. We keep the test around because golang.org/x/tools/go/ssa/interp uses it as a test case, but we simplify the test and eliminate the need for the driver to set GOOS/GOARCH. Change-Id: I5acc0093b557c95d1f0a526d031210256a68222d Reviewed-on: https://go-review.googlesource.com/c/go/+/493601 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* misc: update go.mod commentAustin Clements2023-05-121-8/+3
| | | | | | | | | | | We just moved all of the cgo tests out of misc, and this comment was already a little stale. Update it. Change-Id: Ide711cce53dbe6d9675de587c1d73514b063e952 Reviewed-on: https://go-review.googlesource.com/c/go/+/493600 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/swig: move tests to cmd/cgo/internalAustin Clements2023-05-129-18/+12
| | | | | | | | | | | | | | | | This moves the misc/swig test to cmd/cgo/internal. This lets these tests access facilities in internal/testenv. It's also now just a normal test that can run as part of the cmd tests. For #37486. Change-Id: Ibe5026219999d175aa0a310b9886bef3f6f9ed17 Reviewed-on: https://go-review.googlesource.com/c/go/+/492722 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* misc/swig: restructure as a driverAustin Clements2023-05-1213-184/+266
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the misc/swig tests directly use Swig and C++ and will fail to build if either Swig or a C++ compiler are not present. Typically, we hide this fact from users because dist test itself checks for Swig and a C++ compiler before even attempting to run this test, though users will see this is they try to go test ./... from misc. However, we're about to move the misc/swig tests into the cmd module, where they will be much more visible and much more likely to run unintentionally. To prevent build errors, this CL restructures these tests into a single pure Go test plus two test packages hidden in testdata. This is relatively easy to do for this test because there are only four test cases total. The pure Go test can check for the necessary build tools before trying to build and run the tests in testdata. This also gives us the opportunity to move the LTO variant of these tests out of dist and into the test itself, simplifying dist. For #37486. Change-Id: Ibda089b4069e36866cb31867a7006c790be2d8b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/493599 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/go: fix swigOne action with -nAustin Clements2023-05-121-2/+7
| | | | | | | | | | | | | | Currently, if cmd/go builds a swig file with the -n (dry run) flag, it will print the swig command invocation without executing it, but then attempt to actually rename one of swig's output files, which will fail. Make this rename conditional on -n. While we're here, we fix the missing logging of the rename command with -x, too. Change-Id: I1f6e6efc53dfe4ac5a42d26096679b97bc322827 Reviewed-on: https://go-review.googlesource.com/c/go/+/493255 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* misc/cgo: move registerCgoTests tests to cmd/cgo/internalAustin Clements2023-05-12131-39/+43
| | | | | | | | | | | | | | This moves the remaining cgo tests. For #37486. Change-Id: I99dea5a312a1974de338461a8b02242e5c1bae62 Reviewed-on: https://go-review.googlesource.com/c/go/+/492721 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* misc/cgo/test: add cgo build constraintsAustin Clements2023-05-1220-7/+39
| | | | | | | | | | | | | | | | | | | | | | | We're about to move this package to cmd/cgo/internal, where it will get caught up in the "CGO_ENABLED=0 go install cmd" done by make.bash. Currently, building this package with CGO_ENABLED=0 fails because it contains several source files that don't themselves import "C", but do import a subdirectory where that package imports "C" and thus has no exported API. Fix the CGO_ENABLED=0 build of this package by adding the necessary cgo build tags. Not all source files need it, but this CL makes "CGO_ENABLED=0 go test -c" work in this package. For #37486. Change-Id: Id137cdfbdd950eea802413536d990ab642ebcd7e Reviewed-on: https://go-review.googlesource.com/c/go/+/493215 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Austin Clements <austin@google.com>
* misc/cgo/test: fix vet errorAustin Clements2023-05-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Vet's cgocall check fails on misc/cgo/test with "possibly passing Go type with embedded pointer to C". This error is confusing, but the cgocall check is looking for passing pointers to Go slices to C, which is exactly what this test is doing. Normally we don't notice this because vet doesn't run on misc, but we're about to move this test to cmd/cgo/internal, where vet will start failing. I'm not sure why we're passing a pointer to a slice here. It's important that we call a C function with an unsafe.Pointer to memory containing a pointer to test #25941 and that the result is this call is then passed to another C function for #28540. This CL maintains these two properties without the use of a slice. For #37486. Change-Id: I672a3c35931a59f99363050498d6f0c80fb6cd98 Reviewed-on: https://go-review.googlesource.com/c/go/+/493137 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* misc/cgo: move easy tests to cmd/cgo/internalAustin Clements2023-05-12251-28/+42
| | | | | | | | | | | | | | | | | | | This moves most misc/cgo tests to cmd/cgo/internal. This is mostly a trivial rename and updating dist/test.go for the new paths, plus excluding these packages from regular dist test registration. A few tests were sensitive to what path they ran in, so we update those. This will let these tests access facilities in internal/testenv. For #37486. Change-Id: I3ed417c7c22d9b667f2767c0cb1f59118fcd4af6 Reviewed-on: https://go-review.googlesource.com/c/go/+/492720 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>