Skip to content

Commit c3ccb77

Browse files
committed
[release-branch.go1.17] all: merge master (b8ca6e5) into release-branch.go1.17
Merge List: + 2021-07-31 b8ca6e5 all: gofmt + 2021-07-30 b7a85e0 net/http/httputil: close incoming ReverseProxy request body + 2021-07-29 70fd4e4 runtime: avoid possible preemption when returning from Go to C + 2021-07-28 9eee0ed cmd/go: fix go.mod file name printed in error messages for replacements + 2021-07-28 b39e0f4 runtime: don't crash on nil pointers in checkptrAlignment + 2021-07-27 7cd10c1 cmd/go: use .mod instead of .zip to determine if version has go.mod file + 2021-07-27 c8cf0f7 cmd/go: add missing flag in UsageLine + 2021-07-27 7ba8e79 testing: clarify T.Name returns a distinct name of the running test + 2021-07-27 33ff155 go/types: preserve untyped constants on the RHS of a shift expression + 2021-07-26 840e583 runtime: correct variable name in comment + 2021-07-26 bfbb288 runtime: remove adjustTimers counter + 2021-07-26 9c81fd5 cmd/vet: add missing copyright header + 2021-07-26 ecaa681 doc: clarify non-nil zero length slice to array pointer conversion + 2021-07-26 1868f82 crypto/x509: update iOS bundled roots to version 55188.120.1.0.1 + 2021-07-25 849b791 spec: use consistent capitalization for rune literal hex constants + 2021-07-23 0914646 doc/1.17: fix two dead rfc links + 2021-07-22 052da57 cmd/compile: do not change field offset in ABI analysis + 2021-07-22 798ec73 runtime: don't clear timerModifiedEarliest if adjustTimers is 0 + 2021-07-22 fdb45ac runtime: move mem profile sampling into m-acquired section + 2021-07-21 3e48c03 reflect: add missing copyright header + 2021-07-21 48c88f1 reflect: add Value.CanConvert + 2021-07-20 9e26569 cmd/go: don't add C compiler ID to hash for standard library + 2021-07-20 d568e6e runtime/debug: skip TestPanicOnFault on netbsd/arm + 2021-07-19 c8f4e61 spec: correct example comment in Conversions from slice to array + 2021-07-19 1d91551 time: correct typo in documentation for UnixMicro + 2021-07-19 404127c cmd/compile: fix off-by-one error in traceback argument counting + 2021-07-19 6298cfe cmd/compile: fix typo in fatal message of builtinCall + 2021-07-19 49402be cmd/{compile,link}: fix bug in map.zero handling + 2021-07-18 a66190e test/bench/go1: fix size for RegexpMatchMedium_32 + 2021-07-18 650fc21 text/scanner: use Go convention in Position doc comment + 2021-07-16 aa4e0f5 net/http: correct capitalization in cancelTimeBody comment + 2021-07-15 0941dbc testing: clarify in docs that TestMain is advanced + 2021-07-15 69728ea cmd/go: update error messages in tests to match CL 332573 + 2021-07-15 c1cc9f9 cmd/compile: fix lookup package of redeclared dot import symbol + 2021-07-15 21a04e3 doc/go1.17: mention GOARCH=loong64 + 2021-07-14 2b00a54 go/build, runtime/internal/sys: reserve GOARCH=loong64 + 2021-07-14 60ddf42 cmd/go: change link in error message from /wiki to /doc. + 2021-07-13 d8f348a cmd/go: remove a duplicated word from 'go help mod graph' Change-Id: I63a540ba823bcbde7249348999ac5a7d9908b531
2 parents c3b47cb + b8ca6e5 commit c3ccb77

File tree

96 files changed

+1016
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1016
-235
lines changed

api/go1.17.txt

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pkg net/url, method (Values) Has(string) bool
8080
pkg reflect, func VisibleFields(Type) []StructField
8181
pkg reflect, method (Method) IsExported() bool
8282
pkg reflect, method (StructField) IsExported() bool
83+
pkg reflect, method (Value) CanConvert(Type) bool
8384
pkg runtime/cgo (darwin-amd64-cgo), func NewHandle(interface{}) Handle
8485
pkg runtime/cgo (darwin-amd64-cgo), method (Handle) Delete()
8586
pkg runtime/cgo (darwin-amd64-cgo), method (Handle) Value() interface{}

doc/go1.17.html

+25-2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ <h3 id="arm64">ARM64</h3>
119119
stack frame pointers only on Linux, macOS, and iOS.
120120
</p>
121121

122+
<h3 id="loong64">loong64 GOARCH value reserved</h3>
123+
124+
<p><!-- CL 333909 -->
125+
The main Go compiler does not yet support the LoongArch
126+
architecture, but we've reserved the <code>GOARCH</code> value
127+
"<code>loong64</code>".
128+
This means that Go files named <code>*_loong64.go</code> will now
129+
be <a href="/pkg/go/build/#hdr-Build_Constraints">ignored by Go
130+
tools</a> except when that GOARCH value is being used.
131+
</p>
132+
122133
<h2 id="tools">Tools</h2>
123134

124135
<h3 id="go-command">Go command</h3>
@@ -875,8 +886,8 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
875886
<dd>
876887
<p><!-- CL 272668 -->
877888
The new method <a href="/pkg/net/#IP.IsPrivate"><code>IP.IsPrivate</code></a> reports whether an address is
878-
a private IPv4 address according to <a href="http://tools.ietf.org/html/rfc1918">RFC 1918</a>
879-
or a local IPv6 address according <a href="http://tools.ietf.org/html/rfc4193">RFC 4193</a>.
889+
a private IPv4 address according to <a href="https://datatracker.ietf.org/doc/rfc1918">RFC 1918</a>
890+
or a local IPv6 address according <a href="https://datatracker.ietf.org/doc/rfc4193">RFC 4193</a>.
880891
</p>
881892

882893
<p><!-- CL 301709 -->
@@ -978,6 +989,18 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
978989

979990
<dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
980991
<dd>
992+
<p><!-- CL 334669 -->
993+
The new
994+
<a href="/pkg/reflect/#Value.CanConvert"><code>Value.CanConvert</code></a>
995+
method reports whether a value can be converted to a type.
996+
This may be used to avoid a panic when converting a slice to an
997+
array pointer type if the slice is too short.
998+
Previously it was sufficient to use
999+
<a href="/pkg/reflect/#Type.ConvertibleTo"><code>Type.ConvertibleTo</code></a>
1000+
for this, but the newly permitted conversion from slice to array
1001+
pointer type can panic even if the types are convertible.
1002+
</p>
1003+
9811004
<p><!-- CL 266197 -->
9821005
The new
9831006
<a href="/pkg/reflect/#StructField.IsExported"><code>StructField.IsExported</code></a>

doc/go_spec.html

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--{
22
"Title": "The Go Programming Language Specification",
3-
"Subtitle": "Version of Jul 1, 2021",
3+
"Subtitle": "Version of Jul 26, 2021",
44
"Path": "/ref/spec"
55
}-->
66

@@ -490,8 +490,8 @@ <h3 id="Rune_literals">Rune literals</h3>
490490
\n U+000A line feed or newline
491491
\r U+000D carriage return
492492
\t U+0009 horizontal tab
493-
\v U+000b vertical tab
494-
\\ U+005c backslash
493+
\v U+000B vertical tab
494+
\\ U+005C backslash
495495
\' U+0027 single quote (valid escape only within rune literals)
496496
\" U+0022 double quote (valid escape only within string literals)
497497
</pre>
@@ -4334,7 +4334,10 @@ <h4 id="Conversions_from_slice_to_array_pointer">Conversions from slice to array
43344334

43354335
var t []string
43364336
t0 := (*[0]string)(t) // t0 == nil
4337-
t1 := (*[1]string)(t) // panics: len([1]string) > len(s)
4337+
t1 := (*[1]string)(t) // panics: len([1]string) > len(t)
4338+
4339+
u := make([]byte, 0)
4340+
u0 = (*[0]byte)(u) // u0 != nil
43384341
</pre>
43394342

43404343
<h3 id="Constant_expressions">Constant expressions</h3>

src/cmd/compile/internal/abi/abiutils.go

+3-18
Original file line numberDiff line numberDiff line change
@@ -446,35 +446,20 @@ func (config *ABIConfig) ABIAnalyze(t *types.Type, setNname bool) *ABIParamResul
446446
return result
447447
}
448448

449-
// parameterUpdateMu protects the Offset field of function/method parameters (a subset of structure Fields)
450-
var parameterUpdateMu sync.Mutex
451-
452-
// FieldOffsetOf returns a concurrency-safe version of f.Offset
453-
func FieldOffsetOf(f *types.Field) int64 {
454-
parameterUpdateMu.Lock()
455-
defer parameterUpdateMu.Unlock()
456-
return f.Offset
457-
}
458-
459449
func (config *ABIConfig) updateOffset(result *ABIParamResultInfo, f *types.Field, a ABIParamAssignment, isReturn, setNname bool) {
460450
// Everything except return values in registers has either a frame home (if not in a register) or a frame spill location.
461451
if !isReturn || len(a.Registers) == 0 {
462452
// The type frame offset DOES NOT show effects of minimum frame size.
463453
// Getting this wrong breaks stackmaps, see liveness/plive.go:WriteFuncMap and typebits/typebits.go:Set
464-
parameterUpdateMu.Lock()
465-
defer parameterUpdateMu.Unlock()
466454
off := a.FrameOffset(result)
467455
fOffset := f.Offset
468456
if fOffset == types.BOGUS_FUNARG_OFFSET {
469-
// Set the Offset the first time. After that, we may recompute it, but it should never change.
470-
f.Offset = off
471-
if f.Nname != nil {
472-
// always set it in this case.
457+
if setNname && f.Nname != nil {
473458
f.Nname.(*ir.Name).SetFrameOffset(off)
474459
f.Nname.(*ir.Name).SetIsOutputParamInRegisters(false)
475460
}
476-
} else if fOffset != off {
477-
base.Fatalf("offset for %s at %s changed from %d to %d", f.Sym.Name, base.FmtPos(f.Pos), fOffset, off)
461+
} else {
462+
base.Fatalf("field offset for %s at %s has been set to %d", f.Sym.Name, base.FmtPos(f.Pos), fOffset)
478463
}
479464
} else {
480465
if setNname && f.Nname != nil {

src/cmd/compile/internal/gc/obj.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func dumpdata() {
148148
if reflectdata.ZeroSize > 0 {
149149
zero := base.PkgLinksym("go.map", "zero", obj.ABI0)
150150
objw.Global(zero, int32(reflectdata.ZeroSize), obj.DUPOK|obj.RODATA)
151-
zero.Set(obj.AttrContentAddressable, true)
151+
zero.Set(obj.AttrStatic, true)
152152
}
153153

154154
staticdata.WriteFuncSyms()

src/cmd/compile/internal/ssagen/ssa.go

+22-32
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ func (s *state) instrumentFields(t *types.Type, addr *ssa.Value, kind instrument
12961296
if f.Sym.IsBlank() {
12971297
continue
12981298
}
1299-
offptr := s.newValue1I(ssa.OpOffPtr, types.NewPtr(f.Type), abi.FieldOffsetOf(f), addr)
1299+
offptr := s.newValue1I(ssa.OpOffPtr, types.NewPtr(f.Type), f.Offset, addr)
13001300
s.instrumentFields(f.Type, offptr, kind)
13011301
}
13021302
}
@@ -5053,19 +5053,23 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
50535053
ft := fn.Type()
50545054
off := t.FieldOff(12) // TODO register args: be sure this isn't a hardcoded param stack offset.
50555055
args := n.Args
5056+
i0 := 0
50565057

50575058
// Set receiver (for interface calls). Always a pointer.
50585059
if rcvr != nil {
50595060
p := s.newValue1I(ssa.OpOffPtr, ft.Recv().Type.PtrTo(), off, addr)
50605061
s.store(types.Types[types.TUINTPTR], p, rcvr)
5062+
i0 = 1
50615063
}
50625064
// Set receiver (for method calls).
50635065
if n.Op() == ir.OCALLMETH {
50645066
base.Fatalf("OCALLMETH missed by walkCall")
50655067
}
50665068
// Set other args.
5067-
for _, f := range ft.Params().Fields().Slice() {
5068-
s.storeArgWithBase(args[0], f.Type, addr, off+abi.FieldOffsetOf(f))
5069+
// This code is only used when RegabiDefer is not enabled, and arguments are always
5070+
// passed on stack.
5071+
for i, f := range ft.Params().Fields().Slice() {
5072+
s.storeArgWithBase(args[0], f.Type, addr, off+params.InParam(i+i0).FrameOffset(params))
50695073
args = args[1:]
50705074
}
50715075

@@ -5078,7 +5082,6 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
50785082
if stksize < int64(types.PtrSize) {
50795083
// We need room for both the call to deferprocStack and the call to
50805084
// the deferred function.
5081-
// TODO(register args) Revisit this if/when we pass args in registers.
50825085
stksize = int64(types.PtrSize)
50835086
}
50845087
call.AuxInt = stksize
@@ -6598,6 +6601,7 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
65986601
x := base.Ctxt.Lookup(fmt.Sprintf("%s.arginfo%d", f.LSym.Name, f.ABI))
65996602

66006603
PtrSize := int64(types.PtrSize)
6604+
uintptrTyp := types.Types[types.TUINTPTR]
66016605

66026606
isAggregate := func(t *types.Type) bool {
66036607
return t.IsStruct() || t.IsArray() || t.IsComplex() || t.IsInterface() || t.IsString() || t.IsSlice()
@@ -6641,31 +6645,28 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
66416645
n := 0
66426646
writebyte := func(o uint8) { wOff = objw.Uint8(x, wOff, o) }
66436647

6644-
// Write one non-aggrgate arg/field/element if there is room.
6645-
// Returns whether to continue.
6646-
write1 := func(sz, offset int64) bool {
6647-
if n >= limit {
6648-
return false
6649-
}
6648+
// Write one non-aggrgate arg/field/element.
6649+
write1 := func(sz, offset int64) {
66506650
if offset >= _special {
66516651
writebyte(_offsetTooLarge)
66526652
} else {
66536653
writebyte(uint8(offset))
66546654
writebyte(uint8(sz))
66556655
}
66566656
n++
6657-
return true
66586657
}
66596658

66606659
// Visit t recursively and write it out.
66616660
// Returns whether to continue visiting.
66626661
var visitType func(baseOffset int64, t *types.Type, depth int) bool
66636662
visitType = func(baseOffset int64, t *types.Type, depth int) bool {
66646663
if n >= limit {
6664+
writebyte(_dotdotdot)
66656665
return false
66666666
}
66676667
if !isAggregate(t) {
6668-
return write1(t.Size(), baseOffset)
6668+
write1(t.Size(), baseOffset)
6669+
return true
66696670
}
66706671
writebyte(_startAgg)
66716672
depth++
@@ -6675,58 +6676,47 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym {
66756676
n++
66766677
return true
66776678
}
6678-
var r bool
66796679
switch {
66806680
case t.IsInterface(), t.IsString():
6681-
r = write1(PtrSize, baseOffset) &&
6682-
write1(PtrSize, baseOffset+PtrSize)
6681+
_ = visitType(baseOffset, uintptrTyp, depth) &&
6682+
visitType(baseOffset+PtrSize, uintptrTyp, depth)
66836683
case t.IsSlice():
6684-
r = write1(PtrSize, baseOffset) &&
6685-
write1(PtrSize, baseOffset+PtrSize) &&
6686-
write1(PtrSize, baseOffset+PtrSize*2)
6684+
_ = visitType(baseOffset, uintptrTyp, depth) &&
6685+
visitType(baseOffset+PtrSize, uintptrTyp, depth) &&
6686+
visitType(baseOffset+PtrSize*2, uintptrTyp, depth)
66876687
case t.IsComplex():
6688-
r = write1(t.Size()/2, baseOffset) &&
6689-
write1(t.Size()/2, baseOffset+t.Size()/2)
6688+
_ = visitType(baseOffset, types.FloatForComplex(t), depth) &&
6689+
visitType(baseOffset+t.Size()/2, types.FloatForComplex(t), depth)
66906690
case t.IsArray():
6691-
r = true
66926691
if t.NumElem() == 0 {
66936692
n++ // {} counts as a component
66946693
break
66956694
}
66966695
for i := int64(0); i < t.NumElem(); i++ {
66976696
if !visitType(baseOffset, t.Elem(), depth) {
6698-
r = false
66996697
break
67006698
}
67016699
baseOffset += t.Elem().Size()
67026700
}
67036701
case t.IsStruct():
6704-
r = true
67056702
if t.NumFields() == 0 {
67066703
n++ // {} counts as a component
67076704
break
67086705
}
67096706
for _, field := range t.Fields().Slice() {
67106707
if !visitType(baseOffset+field.Offset, field.Type, depth) {
6711-
r = false
67126708
break
67136709
}
67146710
}
67156711
}
6716-
if !r {
6717-
writebyte(_dotdotdot)
6718-
}
67196712
writebyte(_endAgg)
6720-
return r
6713+
return true
67216714
}
67226715

6723-
c := true
67246716
for _, a := range abiInfo.InParams() {
6725-
if !c {
6726-
writebyte(_dotdotdot)
6717+
if !visitType(a.FrameOffset(abiInfo), a.Type, 0) {
67276718
break
67286719
}
6729-
c = visitType(a.FrameOffset(abiInfo), a.Type, 0)
67306720
}
67316721
writebyte(_endSeq)
67326722
if wOff > maxLen {

src/cmd/compile/internal/typecheck/dcl.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,17 @@ func Export(n *ir.Name) {
106106
// Redeclared emits a diagnostic about symbol s being redeclared at pos.
107107
func Redeclared(pos src.XPos, s *types.Sym, where string) {
108108
if !s.Lastlineno.IsKnown() {
109-
pkgName := DotImportRefs[s.Def.(*ir.Ident)]
109+
var pkgName *ir.PkgName
110+
if s.Def == nil {
111+
for id, pkg := range DotImportRefs {
112+
if id.Sym().Name == s.Name {
113+
pkgName = pkg
114+
break
115+
}
116+
}
117+
} else {
118+
pkgName = DotImportRefs[s.Def.(*ir.Ident)]
119+
}
110120
base.ErrorfAt(pos, "%v redeclared %s\n"+
111121
"\t%v: previous declaration during import %q", s, where, base.FmtPos(pkgName.Pos()), pkgName.Pkg.Path)
112122
} else {

src/cmd/compile/internal/typecheck/iimport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ func (r *importReader) exprsOrNil() (a, b ir.Node) {
15401540
func builtinCall(pos src.XPos, op ir.Op) *ir.CallExpr {
15411541
if go117ExportTypes {
15421542
// These should all be encoded as direct ops, not OCALL.
1543-
base.Fatalf("builtinCall should not be invoked when types are included in inport/export")
1543+
base.Fatalf("builtinCall should not be invoked when types are included in import/export")
15441544
}
15451545
return ir.NewCallExpr(pos, ir.OCALL, ir.NewIdent(base.Pos, types.BuiltinPkg.Lookup(ir.OpNames[op])), nil)
15461546
}

src/cmd/go/alldocs.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/go/go_test.go

+32
Original file line numberDiff line numberDiff line change
@@ -2848,3 +2848,35 @@ func TestExecInDeletedDir(t *testing.T) {
28482848
// `go version` should not fail
28492849
tg.run("version")
28502850
}
2851+
2852+
// A missing C compiler should not force the net package to be stale.
2853+
// Issue 47215.
2854+
func TestMissingCC(t *testing.T) {
2855+
if !canCgo {
2856+
t.Skip("test is only meaningful on systems with cgo")
2857+
}
2858+
cc := os.Getenv("CC")
2859+
if cc == "" {
2860+
cc = "gcc"
2861+
}
2862+
if filepath.IsAbs(cc) {
2863+
t.Skipf(`"CC" (%s) is an absolute path`, cc)
2864+
}
2865+
_, err := exec.LookPath(cc)
2866+
if err != nil {
2867+
t.Skipf(`"CC" (%s) not on PATH`, cc)
2868+
}
2869+
2870+
tg := testgo(t)
2871+
defer tg.cleanup()
2872+
netStale, _ := tg.isStale("net")
2873+
if netStale {
2874+
t.Skip(`skipping test because "net" package is currently stale`)
2875+
}
2876+
2877+
tg.setenv("PATH", "") // No C compiler on PATH.
2878+
netStale, _ = tg.isStale("net")
2879+
if netStale {
2880+
t.Error(`clearing "PATH" causes "net" to be stale`)
2881+
}
2882+
}

src/cmd/go/internal/modcmd/edit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
var cmdEdit = &base.Command{
28-
UsageLine: "go mod edit [editing flags] [go.mod]",
28+
UsageLine: "go mod edit [editing flags] [-fmt|-print|-json] [go.mod]",
2929
Short: "edit go.mod from tools or scripts",
3030
Long: `
3131
Edit provides a command-line interface for editing go.mod,

src/cmd/go/internal/modcmd/graph.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ in text form. Each line in the output has two space-separated fields: a module
2626
and one of its requirements. Each module is identified as a string of the form
2727
path@version, except for the main module, which has no @version suffix.
2828
29-
The -go flag causes graph to report the module graph as loaded by by the
29+
The -go flag causes graph to report the module graph as loaded by the
3030
given Go version, instead of the version indicated by the 'go' directive
3131
in the go.mod file.
3232

0 commit comments

Comments
 (0)