aboutsummaryrefslogtreecommitdiff
path: root/src/internal
AgeCommit message (Collapse)Author
2023-01-26crypto/rand, internal/syscall/unix: add support for getrandom on NetBSD ≥ 10.0json-isValidNumber-beforeTobias Klauser
The getrandom syscall was added to NetBSD in version 10.0, see https://man.netbsd.org/NetBSD-10.0-STABLE/getrandom.2 Change-Id: I2714c1040791f7f4728be8d869058a38cbd93d4d Reviewed-on: https://go-review.googlesource.com/c/go/+/463123 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2023-01-25cmd: remove GOEXPERIMENT=nounified knobMatthew Dempsky
This CL removes the GOEXPERIMENT=nounified knob, and any conditional statements that depend on that knob. Further CLs to remove unreachable code follow this one. Updates #57410. Change-Id: I39c147e1a83601c73f8316a001705778fee64a91 Reviewed-on: https://go-review.googlesource.com/c/go/+/458615 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-25internal/testpty: fix error handlingHeschi Kreinick
When calling a c library function, you discover that an error has occurred, typically by looking at the return value of the function. Only after that can you use errno to figure out the cause of the error. Nothing about cgo changes that story -- you still have to look at the result before checking the error that represents errno. If not you can get false errors if the function happens to leak a non-zero errno. Fix testpty to check errors correctly. Change-Id: Idb95f8dd6a8ed63f653190c2e722e742cf50542b Reviewed-on: https://go-review.googlesource.com/c/go/+/463397 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-24go/types, types2: refuse pointer to array as argument to "clear" builtinCuong Manh Le
The accepted proposal only permits map and slice types. Updates #56351 Change-Id: I95cf4c856a5ecfcdf564601b6215eda3cb6ba86b Reviewed-on: https://go-review.googlesource.com/c/go/+/463075 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-01-24os: use handle based APIs to read directories on windowsqmuntal
This CL updates File.readdir() on windows so it uses GetFileInformationByHandleEx with FILE_ID_BOTH_DIR_INFO instead of Find* APIs. The former is more performant because it allows us to buffer IO calls and reduces the number of system calls, passing from 1 per file to 1 every ~100 files (depending on the size of the file name and the size of the buffer). This change improve performance of File.ReadDir by 20-30%. name old time/op new time/op delta ReadDir-12 562µs ±14% 385µs ± 9% -31.60% (p=0.000 n=9+9) name old alloc/op new alloc/op delta ReadDir-12 29.7kB ± 0% 29.5kB ± 0% -0.88% (p=0.000 n=8+10) name old allocs/op new allocs/op delta ReadDir-12 399 ± 0% 397 ± 0% -0.50% (p=0.000 n=10+10) This change also speeds up calls to os.SameFile when using FileStats returned from File.readdir(), as their file ID can be inferred while reading the directory. Change-Id: Id56a338ee66c39656b564105cac131099218fb5d Reviewed-on: https://go-review.googlesource.com/c/go/+/452995 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-01-23internal/abi: repair broken self-bootstrapDavid Chase
Fixes bug caused by https://go.dev/cl/462115 Change-Id: Id91a139db827f2962be837b8fd218e7b895ce8b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/463175 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-23runtime: enable sha512 optimizations on arm64 via hwcaps.Matt Horsnell
Change-Id: I9d88c8eb91106de412a9abc6601cdda06537d818 Reviewed-on: https://go-review.googlesource.com/c/go/+/461747 Reviewed-by: Martin Möhrmann <moehrmann@google.com> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org>
2023-01-23internal/abi,runtime: refactor map constants into one placeDavid Chase
Previously TryBot-tested with bucket bits = 4. Also tested locally with bucket bits = 5. This makes it much easier to change the size of map buckets, and hopefully provides pointers to all the code that in some way depends on details of map layout. Change-Id: I9f6669d1eadd02f182d0bc3f959dc5f385fa1683 Reviewed-on: https://go-review.googlesource.com/c/go/+/462115 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Austin Clements <austin@google.com>
2023-01-20internal/coverage/decodemeta: fix coding error in func literal handlingThan McIntosh
Fix a coding error in coverage meta-data decoding in the method decodemeta.CoverageMetaDataDecoder.ReadFunc. The code was not unconditionally assigning the "function literal" field of the coverage.FuncDesc object passed in, resulting in bad values depending on what the state of the field happened to be in the object. Fixes #57942. Change-Id: I6dfd7d7f7af6004f05c622f9a7116e9f6018cf4f Reviewed-on: https://go-review.googlesource.com/c/go/+/462955 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-20internal/profile: use internal/lazyregexp for the legacy parserDaniel Martí
Per benchinit, this makes a big difference to init times: name old time/op new time/op delta InternalProfile 185µs ± 1% 6µs ± 1% -96.51% (p=0.008 n=5+5) name old alloc/op new alloc/op delta InternalProfile 101kB ± 0% 4kB ± 0% -95.72% (p=0.008 n=5+5) name old allocs/op new allocs/op delta InternalProfile 758 ± 0% 25 ± 0% -96.70% (p=0.008 n=5+5) The fixed 0.2ms init cost is saved for any importer of net/http/pprof, but also for cmd/compile, as it supports PGO now. A Go program parsing profiles might not even need to compile these regular expressions at all, if it doesn't encounter any legacy files. I suspect this will be the case with most invocations of cmd/compile. Updates #26775. Change-Id: I8374dc64459f0b6bb09bbdf9d0b6c55d7ae1646e Reviewed-on: https://go-review.googlesource.com/c/go/+/460545 Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20all: fix typos in go file commentsMarcel Meyer
This is the second round to look for spelling mistakes. This time the manual sifting of the result list was made easier by filtering out capitalized and camelcase words. grep -r --include '*.go' -E '^// .*$' . | aspell list | grep -E -x '[A-Za-z]{1}[a-z]*' | sort | uniq This PR will be imported into Gerrit with the title and first comment (this text) used to generate the subject and body of the Gerrit change. Change-Id: Ie8a2092aaa7e1f051aa90f03dbaf2b9aaf5664a9 GitHub-Last-Rev: fc2bd6e0c51652f13a7588980f1408af8e6080f5 GitHub-Pull-Request: golang/go#57737 Reviewed-on: https://go-review.googlesource.com/c/go/+/461595 Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-19internal/godebug: export non-default-behavior counters in runtime/metricsRuss Cox
Allow GODEBUG users to report how many times a setting resulted in non-default behavior. Record non-default-behaviors for all existing GODEBUGs. Also rework tests to ensure that runtime is in sync with runtime/metrics.All, and generate docs mechanically from metrics.All. For #56986. Change-Id: Iefa1213e2a5c3f19ea16cd53298c487952ef05a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/453618 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-01-17cmd/go: do not confuse files for standard library packagesRuss Cox
I often create dummy files holding various data named things like 'z'. If a file (not directory) GOROOT/src/z exists, it confuses cmd/go into thinking z is a standard library package, which breaks the test Script/mod_vendor. This CL fixes internal/goroot to only report that something is a standard library package when a directory with that name exists, not just a file. Change-Id: I986c9a425e78d23c7e033aeadb8e9f71aab2b878 Reviewed-on: https://go-review.googlesource.com/c/go/+/461955 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
2023-01-17cmd/compile: remove support for old comparable semanticsRobert Griesemer
Change-Id: I730da5082ea6de1510482aabaa2915e83d3819a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/461607 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-17go/types, types2: do not abort constraint type inference eagerlyRobert Griesemer
During constraint type inference, unification may fail because it operates with limited information (core types) even if the actual type argument satisfies the type constraint in question. On the other hand, it is safe to ignore failing unification during constraint type inference because if the failure is true, an error will be reported when checking instantiation. Fixes #53650. Change-Id: Ia76b21ff779bfb1282c1c55f4174847b29cc6f3a Reviewed-on: https://go-review.googlesource.com/c/go/+/454655 Auto-Submit: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17go/types, types2: distinguish between substring and regexp error patternsRobert Griesemer
Use ERROR for substrings, and ERRORx for regexp error patterns. Correctly unquote patterns for ERROR and ERRORx. Adjust all tests in internal/types/testdata and locally as needed. The changes to internal/types/testdata were made through repeated applications of regexpr find/replace commands and manual cleanups. Fixes #51006. Change-Id: Ib9ec5001243b688bf5aee56b7d4105fb55999ab4 Reviewed-on: https://go-review.googlesource.com/c/go/+/455755 Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-17internal/types: consistently use double quotes around ERROR patternsRobert Griesemer
Before matching the pattern, the double quotes are simply stripped (no Go string unquoting) for now. This is a first step towards use of proper Go strings as ERROR patterns. The changes were obtained through a couple of global regexp find/replace commands: /\* ERROR ([^"]+) \*/ => /* ERROR "$1" */ // ERROR ([^"]+)$ => // ERROR "$1" followed up by manual fixes where multiple "/* ERROR"-style errors appeared on the same line (in that case, the first regexp matches the first and last ERROR). For #51006. Change-Id: Ib92c2d5e339075aeec1ea74c339b5fecf953d1a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/455718 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17cmd/compile/internal/syntax: rename ErrorMap to CommentMap, make more flexibleRobert Griesemer
Change the ErrorMap function to collect all comments with a comment text that matches a given regexp pattern. Also rename it to CommentMap. Adjust uses and corresponding test. Adjust various type-checker tests with incorrect ERROR patterns. For #51006. Change-Id: I749e8f31b532edbf8568f27ba1546dc849efd143 Reviewed-on: https://go-review.googlesource.com/c/go/+/456155 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Cherry Mui <cherryyz@google.com>
2023-01-17internal/goversion: update Version to 1.21Cherry Mui
This is the start of the Go 1.21 development cycle, so update the Version value accordingly. It represents the Go 1.x version that will soon open up for development (and eventually become released). For #40705. For #57736. Change-Id: I31b739f632bdc8d14f46560e0e5bf333fb8e7740 Reviewed-on: https://go-review.googlesource.com/c/go/+/462456 Reviewed-by: Carlos Amedee <carlos@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-01-11go/types, types2: don't look up fields or methods when expecting a typeRobert Findley
As we have seen many times, the type checker must be careful to avoid accessing named type information before the type is fully set up. We need a more systematic solution to this problem, but for now avoid one case that causes a crash: checking a selector expression on an incomplete type when a type expression is expected. For golang/go#57522 Change-Id: I7ed31b859cca263276e3a0647d1f1b49670023a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/461577 Run-TryBot: Robert Findley <rfindley@google.com> Auto-Submit: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-11cmd/compile: better error message for when a type is in a constraint but not ↵Robert Griesemer
the type set While at it, also remove the word "constraint" in the detail explanation of an unsatisfied constraint. Fixes #57500. Change-Id: I55dae1694de2cfdb434aeba9d4a3530af7aca8f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/460455 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-04cmd/compile: use "satisfies" (not "implements") for constraint errorsRobert Griesemer
Per the latest spec, we distinguish between interface implementation and constraint satisfaction. Use the verb "satisfy" when reporting an error about failing constraint satisfaction. This CL only changes error messages. It has no impact on correct code. Fixes #57564. Change-Id: I6dfb3b2093c2e04fe5566628315fb5f6bd709f17 Reviewed-on: https://go-review.googlesource.com/c/go/+/460396 Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-12-29go/types, types2: use strict comparability for type set intersectionRobert Griesemer
Fixes #57486. Change-Id: I4b71199a724718886ce6d7a49e96a9ebdcbcf737 Reviewed-on: https://go-review.googlesource.com/c/go/+/459816 Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-16syscall, internal/poll: fall back to accept on linux-armIan Lance Taylor
Our minimum Linux version is 2.6.32, and the accept4 system call was introduced in 2.6.28, so we use accept4 everywhere. Unfortunately, it turns out that the accept4 system call was only added to linux-arm in 2.6.36, so for linux-arm only we need to try the accept4 system call and then fall back to accept if it doesn't work. The code we use on linux-arm is the code we used in Go 1.17. On non-arm platforms we continue using the simpler code introduced in Go 1.18. Adding accept4 to the ARM Linux kernel was: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=21d93e2e29722d7832f61cc56d73fb953ee6578e Fixes #57333 Change-Id: I6680cb54dd4d3514a6887dda8906e6708c64459d Reviewed-on: https://go-review.googlesource.com/c/go/+/457995 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-13go/types, types2: report type mismatch error when conversion is impossibleRobert Griesemer
Rather than reporting an impossible conversion error when mixing an untyped value with a pointer type in an operation, report a type mismatch error. This fixes a regression in error quality compared to pre-1.18. For the fix, clean up the implementation of canMix, add documentation, and give it a better name. Adjust test case for corresponding error code bacause we now get a better error message (and error code) for the old error code example. Fixes #57160. Change-Id: Ib96ce7cbc44db6905fa2f1c90a3769af609e101b Reviewed-on: https://go-review.googlesource.com/c/go/+/457055 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
2022-12-08go/types, types2: always rename type parameters during inferenceRobert Findley
Type inference uses a trick of "renaming" type parameters in the type parameter list to avoid cycles during unification. This separates the identity of type parameters from type arguments. When this trick was introduced in CL 385494, we restricted its application to scenarios where inference is truly self-recursive: the type parameter list being inferred was the same as the type parameter list of the outer function declaration. Unfortunately, the heuristic used to determine self-recursiveness was flawed: type-checking function literals clobbers the type-checker environment, losing information about the outer signature. We could fix this by introducing yet more state into the type-checker (e.g. a 'declSig' field that would hold the signature of the active function declaration), but it is simpler to just avoid this optimization and always perform type parameter renaming. We can always optimize later. This CL removes the check for true self-recursion, always performing the renaming. Fixes golang/go#57155 Change-Id: I34c7617005c1f0ccfe2192da0e5ed104be6b92c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/456236 Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-07internal/safefilepath: fix TestFromFS on Plan 9David du Colombier
CL 455716 added TestFromFS. This test was failing on Plan 9 because fromFS didn't return an empty string in case of error. This change fixes TestFromFS by returning an empty string in case of error. Fixes #57142. Change-Id: Ie50dfba5e70154d641f762fa43f1c26c3d12b6f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/455835 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: David du Colombier <0intro@gmail.com>
2022-12-07os/user: fix buffer retry loop on macOSRuss Cox
getpwnam_r and friends return the errno as the result, not in the global errno. The code changes in CL 449316 inadvertently started using the global errno. So if a lookup didn't fit in the first buffer size, it was treated as not found instead of growing the buffer. Fixes #56942. Change-Id: Ic5904fbeb31161bccd858e5adb987e919fb3e9d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/455815 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
2022-12-06os, net/http: avoid escapes from os.DirFS and http.Dir on WindowsDamien Neil
Do not permit access to Windows reserved device names (NUL, COM1, etc.) via os.DirFS and http.Dir filesystems. Avoid escapes from os.DirFS(`\`) on Windows. DirFS would join the the root to the relative path with a path separator, making os.DirFS(`\`).Open(`/foo/bar`) open the path `\\foo\bar`, which is a UNC name. Not only does this not open the intended file, but permits reference to any file on the system rather than only files on the current drive. Make os.DirFS("") invalid, with all file access failing. Previously, a root of "" was interpreted as "/", which is surprising and probably unintentional. Fixes CVE-2022-41720 Fixes #56694 Change-Id: I275b5fa391e6ad7404309ea98ccc97405942e0f0 Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1663834 Reviewed-by: Tatiana Bradley <tatianabradley@google.com> Reviewed-by: Julie Qiu <julieqiu@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/455362 Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Jenny Rakoczy <jenny@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/455716 Reviewed-by: Jenny Rakoczy <jenny@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
2022-12-06go/types, types2: better error message for invalid method expressionRobert Griesemer
Fixes #53358. Change-Id: I38528da1596b6e1aaedcab89b1513fb8acac596c Reviewed-on: https://go-review.googlesource.com/c/go/+/455335 Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
2022-12-05go/types, types2: better error message for failing constraint type inferenceRobert Griesemer
We know the type argument against which constraint type inference fails: print the type argument instead of the corresponding type parameter. Fixes #57096. Change-Id: Ia1da9c87fac6f8062e4d534b82e895fa4617fddc Reviewed-on: https://go-review.googlesource.com/c/go/+/455278 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-01go/internal/gcimporter: load cached export data for packages individuallyBryan C. Mills
Previously, we were using internal/goroot.PkgfileMap to locate cached export data. However, PkgfileMap regenerates export data for the entire standard library, whereas gcimporter may only need a single package. Under the new approach, we load the export data (still using 'go list -export') for each GOROOT package individually, avoiding work to rebuild export data for packages that are not needed. This is a tradeoff: if most packages in GOROOT are actually needed, we end up making many more calls to 'go list', and may build packages sequentially instead of in parallel (but with lower latency to start using the export data from the earlier packages). On my workstation, starting from a clean cache for each run, this reduces the wall time of 'go test go/internal/gcimporter -run=TestImportedTypes' from 22s real time (2m10s user time) to 6s real (27s user), and only increases 'go test go/internal/gcimporter' from 28s real (2m16s user) to 30s real (2m19s user). Updates #56967. Updates #47257. Change-Id: I22556acdd9b1acc56533ed4c2728ea29b585c073 Reviewed-on: https://go-review.googlesource.com/c/go/+/454497 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>
2022-12-01go/types, types2: make the new comparable semantics the defaultRobert Griesemer
Ordinary interface types now satisfy comparable constraints. This is a fully backward-compatible change: it simply permits additional code to be valid that wasn't valid before. This change makes the new comparable semantics the default behavior, depending on the Go -lang version. It also renames the flag types2.Config.AltComparableSemantics to types2.Config.OldComparableSemantics and inverts its meaning (or types.Config.oldComparableSemantics respectively). Add new predicate Satisfies (matching the predicate Implements but for constraint satisfaction), per the proposal description. Adjust some existing tests by setting -oldComparableSemantics and add some new tests that verify version-dependent behavior. The compiler flag -oldcomparable may be used to temporarily switch back to the Go 1.18/1.19 behavior should this change cause problems, or to identify that a problem is unrelated to this change. The flag will be removed for Go 1.21. For #52509. For #56548. For #57011. Change-Id: I8b3b3d9d492fc24b0693567055f0053ccb5aeb42 Reviewed-on: https://go-review.googlesource.com/c/go/+/454575 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2022-12-01Revert "go/types, types2: make the new comparable semantics the default"Robert Griesemer
The CL below was accidentally submitted, while waiting for the freeze exception. Reverting. This reverts commit 15e705ea963b5008112793507365e24b743606bc. Change-Id: I4dbf92dcb01fa9245a6e6a2d1514d8aa898d0048 Reviewed-on: https://go-review.googlesource.com/c/go/+/454476 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Auto-Submit: Robert Griesemer <gri@google.com>
2022-12-01internal/coverage: use io.Seek* constantsTobias Klauser
Use the io.Seek* constants instead of their deprecated os.SEEK_* counterparts. Change-Id: Ie899f9cf286de7304a394d9a2a091a55937542ad Reviewed-on: https://go-review.googlesource.com/c/go/+/453576 Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
2022-12-01go/types, types2: make the new comparable semantics the defaultRobert Griesemer
Ordinary interface types now satisfy comparable constraints. This change makes the new comparable semantics the default behavior, depending on the Go -lang version. It also renames the flag types2.Config.AltComparableSemantics to types2.Config.OldComparableSemantics and inverts its meaning (or types.Config.oldComparableSemantics respectively). Adjust some existing tests by setting -oldComparableSemantics and add some new tests that verify version-dependent behavior. The compiler flag -oldcomparable may be used to temporarily switch back to the Go 1.18/1.19 behavior should this change cause problems, or to identify that a problem is unrelated to this change. The flag will be removed for Go 1.21. For #52509. For #56548. Change-Id: Ic2b22db9433a8dd81dc1ed9d30835f0395fb7205 Reviewed-on: https://go-review.googlesource.com/c/go/+/453978 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Robert Griesemer <gri@google.com>
2022-11-21go/types, types2: report empty type sets in operand descriptionsRobert Griesemer
This leads to better error messages where operations are not permitted because of empty type sets. Fixes #51525. Change-Id: I8d15645e2aff5145e458bdf9aaa4d2bee28d37fa Reviewed-on: https://go-review.googlesource.com/c/go/+/452535 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
2022-11-21cmd/go,internal/platform: enable pie buildmode for windows/arm64qmuntal
This CL adds windows/arm64 to the list of ports that supports PIE build mode. It is probably an oversight that this port is not marked as pie-capable because windows/arm64 only supports PIE build mode. Fixes #56872 Change-Id: I2bdd3ac207280f47ddcf8c2582f13025dafb9278 Reviewed-on: https://go-review.googlesource.com/c/go/+/452415 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-18all: add missing periods in commentscui fliter
Change-Id: I69065f8adf101fdb28682c55997f503013a50e29 Reviewed-on: https://go-review.googlesource.com/c/go/+/449757 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joedian Reid <joedian@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-18runtime: add page tracerMichael Knyszek
This change adds a new GODEBUG flag called pagetrace that writes a low-overhead trace of how pages of memory are managed by the Go runtime. The page tracer is kept behind a GOEXPERIMENT flag due to a potential security risk for setuid binaries. Change-Id: I6f4a2447d02693c25214400846a5d2832ad6e5c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/444157 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-17go/types, types2: implement type checking of "clear" built-inRobert Griesemer
Will become available with Go 1.21. Recognizing the `clear` built-in early is not causing any problems: if existing code defines a `clear`, that will be used as before. If code doesn't define `clear` the error message will make it clear that with 1.21 the function will be available. It's still possible to define a local `clear` and get rid of the error; but more likely the name choice should be avoided going forward, so this provides a useful early "heads-up". For #56351. Change-Id: I3d0fb1eb3508fbc78d7514b6238eac89610158c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/448076 Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
2022-11-17internal/profile: remove unused encodeStringOptTobias Klauser
Change-Id: Icaee8064c5ab61cc2ad28c2d1d06d70f845754fa Reviewed-on: https://go-review.googlesource.com/c/go/+/451535 Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2022-11-16cmd/go: make testterminal18153 a normal testAustin Clements
Currently, cmd/go's testterminal18153 is implemented as a special test that doesn't run as part of cmd/go's regular tests. Because the test requires stdout and stderr to be a terminal, it is currently run directly by "dist test" so it can inherit the terminal of all.bash. This has a few problems. It's yet another special case in dist test. dist test also has to be careful to not apply its own buffering to this test, so it can't run in parallel and it limits dist test's own scheduler. It doesn't run as part of regular "go test", which means it usually only gets coverage from running all.bash. And since we have to skip it if all.bash wasn't run at a terminal, I'm sure it often gets skipped even when running all.bash. Fix all of this by rewriting this test to create its own PTY and re-exec "go test" to check that PTY passes through go test. This makes the test self-contained, so it can be a regular cmd/go test, we can drop it from dist test, and it's not sensitive to the environment of all.bash. Preparation for #37486. Updates #18153. Change-Id: I6493dbb0143348e299718f6e311ac8a63f5d69c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/449503 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-16internal/testpty: move from os/signal/internal/ptyAustin Clements
We're going to use this for another test, so make it more accessible. Preparation for #37486. Change-Id: If194cc4244c4b9e1b1f253759b813555b39ad67e Reviewed-on: https://go-review.googlesource.com/c/go/+/449502 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-16go/types, types2: ensure invalid generic types are marked as invalidRobert Findley
When detecting invalid types, we may detect cycles through instances. Ensure that the uninstantiated origin type is also marked invalid. Fixes #56665 Change-Id: Id67653bcb072ac80161dea07d0ced566e61564a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/449275 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
2022-11-16internal/goroot: report PkgfileMap error on invalid lineTobias Klauser
Ref. https://go-review.googlesource.com/c/go/+/442303/comment/7caca6eb_0ebe4d51/ Change-Id: Id351b9c25380f0959453bb84ed123d0e784e4866 Reviewed-on: https://go-review.googlesource.com/c/go/+/450595 Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
2022-11-14os,syscall: File.Stat to use file handle for directories on Windowsqmuntal
Updates syscall.Open to support opening directories via CreateFileW. CreateFileW handles are more versatile than FindFirstFile handles. They can be used in Win32 APIs like GetFileInformationByHandle and SetFilePointerEx, which are needed by some Go APIs. Fixes #52747 Fixes #36019 Change-Id: I26a00cef9844fb4abeeb18d2f9d854162a146651 Reviewed-on: https://go-review.googlesource.com/c/go/+/405275 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Patrik Nyblom <pnyb@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-14internal/godebug: define more efficient APIRuss Cox
We have been expanding our use of GODEBUG for compatibility, and the current implementation forces a tradeoff between freshness and efficiency. It parses the environment variable in full each time it is called, which is expensive. But if clients cache the result, they won't respond to run-time GODEBUG changes, as happened with x509sha1 (#56436). This CL changes the GODEBUG API to provide efficient, up-to-date results. Instead of a single Get function, New returns a *godebug.Setting that itself has a Get method. Clients can save the result of New, which is no more expensive than errors.New, in a global variable, and then call that variable's Get method to get the value. Get costs only two atomic loads in the case where the variable hasn't changed since the last call. Unfortunately, these changes do require importing sync from godebug, which will mean that sync itself will never be able to use a GODEBUG setting. That doesn't seem like such a hardship. If it was really necessary, the runtime could pass a setting to package sync itself at startup, with the caveat that that setting, like the ones used by runtime itself, would not respond to run-time GODEBUG changes. Change-Id: I99a3acfa24fb2a692610af26a5d14bbc62c966ac Reviewed-on: https://go-review.googlesource.com/c/go/+/449504 Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-11internal/syscall/unix: use runtime.gostring for GostringIan Lance Taylor
Under the race detector, checkptr flags uses of unsafe.Slice that result in slices that straddle multiple Go allocations. Avoid that scenario by calling existing runtime code. This fixes a failure on the darwin-.*-race builders introduced in CL 446178. Change-Id: I6e0fdb37e3c3f38d97939a8799bb4d10f519c5b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/449936 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2022-11-11os/user: use libc (not cgo) on macOSRuss Cox
With net converted to libc, os/user is the last remaining cgo code in the standard libary on macOS. Convert it to libc too. Now only plugin remains as a cgo-using package on macOS. Change-Id: Ibb518b5c62ef9ec1e6ab6191f4b576f7c5a4501c Reviewed-on: https://go-review.googlesource.com/c/go/+/449316 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>