Skip to content

Commit eb5a7b5

Browse files
committed
[release-branch.go1.17] all: merge master (5805efc) into release-branch.go1.17
Merge List: + 2021-08-12 5805efc doc/go1.17: remove draft notice + 2021-08-12 39634e7 CONTRIBUTORS: update for the Go 1.17 release + 2021-08-12 095bb79 os/exec: re-enable LookPathTest/16 + 2021-08-11 dea23e9 src/make.*: make --no-clean flag a no-op that prints a warning + 2021-08-11 d4c0ed2 doc/go1.17: linker passes -I to extld as -Wl,--dynamic-linker + 2021-08-10 1f9c9d8 doc: use "high address/low address" instead of "top/bottom" + 2021-08-09 f1dce31 cmd/go: with -mod=vendor, don't panic if there are duplicate requirements + 2021-08-09 7aeaad5 runtime/cgo: when using msan explicitly unpoison cgoCallers + 2021-08-08 507cc34 doc: add example for conversion from slice expressions to array ptr + 2021-08-07 891547e doc/go1.17: fix a typo introduced in CL 335135 + 2021-08-06 8eaf4d1 make.bash: do not overwrite GO_LDSO if already set + 2021-08-06 63b968f doc/go1.17: clarify Modules changes + 2021-08-06 70546f6 runtime: allow arm64 SEH to be called if illegal instruction + 2021-08-05 fd45e26 runtime: warn that KeepAlive is not an unsafe.Pointer workaround + 2021-08-04 6e73886 net/http: speed up and deflake TestCancelRequestWhenSharingConnection + 2021-08-02 8a7ee4c io/fs: don't use absolute path in DirEntry.Name doc Change-Id: Ie9ce48bf4e99457cde966c5f972b04140468fcf0
2 parents 72ab3ff + 5805efc commit eb5a7b5

22 files changed

+492
-127
lines changed

CONTRIBUTORS

+135-1
Large diffs are not rendered by default.

doc/asm.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ <h3 id="symbols">Symbols</h3>
166166
</li>
167167

168168
<li>
169-
<code>SP</code>: Stack pointer: top of stack.
169+
<code>SP</code>: Stack pointer: the highest address within the local stack frame.
170170
</li>
171171

172172
</ul>
@@ -216,7 +216,7 @@ <h3 id="symbols">Symbols</h3>
216216
The <code>SP</code> pseudo-register is a virtual stack pointer
217217
used to refer to frame-local variables and the arguments being
218218
prepared for function calls.
219-
It points to the top of the local stack frame, so references should use negative offsets
219+
It points to the highest address within the local stack frame, so references should use negative offsets
220220
in the range [−framesize, 0):
221221
<code>x-8(SP)</code>, <code>y-4(SP)</code>, and so on.
222222
</p>
@@ -409,7 +409,7 @@ <h3 id="directives">Directives</h3>
409409
(For <code>TEXT</code> items.)
410410
Don't insert the preamble to check if the stack must be split.
411411
The frame for the routine, plus anything it calls, must fit in the
412-
spare space at the top of the stack segment.
412+
spare space remaining in the current stack segment.
413413
Used to protect routines such as the stack splitting code itself.
414414
</li>
415415
<li>
@@ -460,7 +460,7 @@ <h3 id="directives">Directives</h3>
460460
<code>TOPFRAME</code> = 2048
461461
<br>
462462
(For <code>TEXT</code> items.)
463-
Function is the top of the call stack. Traceback should stop at this function.
463+
Function is the outermost frame of the call stack. Traceback should stop at this function.
464464
</li>
465465
</ul>
466466

doc/go1.17.html

+59-30
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
main ul li { margin: 0.5em 0; }
1515
</style>
1616

17-
<h2 id="introduction">DRAFT RELEASE NOTES — Introduction to Go 1.17</h2>
17+
<h2 id="introduction">Introduction to Go 1.17</h2>
1818

1919
<p>
20-
<strong>
21-
Go 1.17 is not yet released. These are work-in-progress
22-
release notes. Go 1.17 is expected to be released in August 2021.
23-
</strong>
20+
The latest Go release, version 1.17, arrives six months after <a href="/doc/go1.16">Go 1.16</a>.
21+
Most of its changes are in the implementation of the toolchain, runtime, and libraries.
22+
As always, the release maintains the Go 1 <a href="/doc/go1compat">promise of compatibility</a>.
23+
We expect almost all Go programs to continue to compile and run as before.
2424
</p>
2525

2626
<h2 id="language">Changes to the language</h2>
@@ -134,35 +134,54 @@ <h2 id="tools">Tools</h2>
134134

135135
<h3 id="go-command">Go command</h3>
136136

137-
<h4 id="lazy-loading">Lazy module loading</h4>
137+
<a id="lazy-loading"><!-- for existing links only --></a>
138+
<h4 id="graph-pruning">Pruned module graphs in <code>go 1.17</code> modules</h4>
138139

139140
<p><!-- golang.org/issue/36460 -->
141+
If a module specifies <code>go</code> <code>1.17</code> or higher, the module
142+
graph includes only the <em>immediate</em> dependencies of
143+
other <code>go</code> <code>1.17</code> modules, not their full transitive
144+
dependencies. (See <a href="/ref/mod#graph-pruning">Module graph pruning</a>
145+
for more detail.)
146+
</p>
147+
148+
<p>
149+
For the <code>go</code> command to correctly resolve transitive imports using
150+
the pruned module graph, the <code>go.mod</code> file for each module needs to
151+
include more detail about the transitive dependencies relevant to that module.
140152
If a module specifies <code>go</code> <code>1.17</code> or higher in its
141-
<code>go.mod</code> file, its transitive requirements are now loaded lazily,
142-
avoiding the need to download or read <code>go.mod</code> files for
143-
otherwise-irrelevant dependencies. To support lazy loading, in Go 1.17 modules
144-
the <code>go</code> command maintains <em>explicit</em> requirements in
145-
the <code>go.mod</code> file for every dependency that provides any package
146-
transitively imported by any package or test within the module.
147-
See <a href="https://golang.org/design/36460-lazy-module-loading">the design
148-
document</a> for more detail.
149-
<!-- TODO(bcmills): replace the design-doc link with proper documentation. -->
153+
<code>go.mod</code> file, its <code>go.mod</code> file now contains an
154+
explicit <a href="/ref/mod#go-mod-file-require"><code>require</code>
155+
directive</a> for every module that provides a transitively-imported package.
156+
(In previous versions, the <code>go.mod</code> file typically only included
157+
explicit requirements for <em>directly</em>-imported packages.)
158+
<p>
159+
160+
<p>
161+
Since the expanded <code>go.mod</code> file needed for module graph pruning
162+
includes all of the dependencies needed to load the imports of any package in
163+
the main module, if the main module specifies
164+
<code>go</code> <code>1.17</code> or higher the <code>go</code> tool no longer
165+
reads (or even downloads) <code>go.mod</code> files for dependencies if they
166+
are not needed in order to complete the requested command.
167+
(See <a href="/ref/mod#lazy-loading">Lazy loading</a>.)
150168
</p>
151169

152170
<p><!-- golang.org/issue/45965 -->
153-
Because the number of additional explicit requirements in the go.mod file may
154-
be substantial, in a Go 1.17 module the newly-added requirements
155-
on <em>indirect</em> dependencies are maintained in a
156-
separate <code>require</code> block from the block containing direct
157-
dependencies.
171+
Because the number of explicit requirements may be substantially larger in an
172+
expanded Go 1.17 <code>go.mod</code> file, the newly-added requirements
173+
on <em>indirect</em> dependencies in a <code>go</code> <code>1.17</code>
174+
module are maintained in a separate <code>require</code> block from the block
175+
containing direct dependencies.
158176
</p>
159177

160178
<p><!-- golang.org/issue/45094 -->
161-
To facilitate the upgrade to lazy loading, the
162-
<code>go</code> <code>mod</code> <code>tidy</code> subcommand now supports
163-
a <code>-go</code> flag to set or change the <code>go</code> version in
164-
the <code>go.mod</code> file. To enable lazy loading for an existing module
165-
without changing the selected versions of its dependencies, run:
179+
To facilitate the upgrade to Go 1.17 pruned module graphs, the
180+
<a href="/ref/mod#go-mod-tidy"><code>go</code> <code>mod</code> <code>tidy</code></a>
181+
subcommand now supports a <code>-go</code> flag to set or change
182+
the <code>go</code> version in the <code>go.mod</code> file. To convert
183+
the <code>go.mod</code> file for an existing module to Go 1.17 without
184+
changing the selected versions of its dependencies, run:
166185
</p>
167186

168187
<pre>
@@ -199,10 +218,10 @@ <h4 id="lazy-loading">Lazy module loading</h4>
199218
</p>
200219

201220
<p><!-- golang.org/issue/46366 -->
202-
The <code>go</code> <code>mod</code> <code>graph</code> subcommand also
203-
supports the <code>-go</code> flag, which causes it to report the graph as
204-
seen by the indicated Go version, showing dependencies that may otherwise be
205-
pruned out by lazy loading.
221+
The <a href="/ref/mod#go-mod-graph"><code>go</code> <code>mod</code> <code>graph</code></a>
222+
subcommand also supports the <code>-go</code> flag, which causes it to report
223+
the graph as seen by the indicated Go version, showing dependencies that may
224+
otherwise be pruned out.
206225
</p>
207226

208227
<h4 id="module-deprecation-comments">Module deprecation comments</h4>
@@ -270,7 +289,8 @@ <h4 id="vendor"><code>vendor</code> contents</h4>
270289

271290
<p><!-- golang.org/issue/36876 -->
272291
If the main module specifies <code>go</code> <code>1.17</code> or higher,
273-
<code>go</code> <code>mod</code> <code>vendor</code> now annotates
292+
<a href="/ref/mod#go-mod-vendor"><code>go</code> <code>mod</code> <code>vendor</code></a>
293+
now annotates
274294
<code>vendor/modules.txt</code> with the <code>go</code> version indicated by
275295
each vendored module in its own <code>go.mod</code> file. The annotated
276296
version is used when building the module's packages from vendored source code.
@@ -468,6 +488,15 @@ <h2 id="compiler">Compiler</h2>
468488
and compare functions by code pointer.
469489
</p>
470490

491+
<h3 id="link">Linker</h3>
492+
493+
<p><!-- CL 310349 -->
494+
When the linker uses external linking mode, which is the default
495+
when linking a program that uses cgo, and the linker is invoked
496+
with a <code>-I</code> option, the option will now be passed to the
497+
external linker as a <code>-Wl,--dynamic-linker</code> option.
498+
</p>
499+
471500
<h2 id="library">Core library</h2>
472501

473502
<h3 id="runtime/cgo"><a href="/pkg/runtime/cgo">Cgo</a></h3>

doc/go_spec.html

+1
Original file line numberDiff line numberDiff line change
@@ -4329,6 +4329,7 @@ <h4 id="Conversions_from_slice_to_array_pointer">Conversions from slice to array
43294329
<pre>
43304330
s := make([]byte, 2, 4)
43314331
s0 := (*[0]byte)(s) // s0 != nil
4332+
s1 := (*[1]byte)(s[1:]) // &amp;s1[0] == &amp;s[1]
43324333
s2 := (*[2]byte)(s) // &amp;s2[0] == &amp;s[0]
43334334
s4 := (*[4]byte)(s) // panics: len([4]byte) > len(s)
43344335

misc/cgo/testsanitizers/msan_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func TestMSAN(t *testing.T) {
4242
{src: "msan5.go"},
4343
{src: "msan6.go"},
4444
{src: "msan7.go"},
45+
{src: "msan8.go"},
4546
{src: "msan_fail.go", wantErr: true},
4647
}
4748
for _, tc := range cases {
+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
/*
8+
#include <pthread.h>
9+
#include <signal.h>
10+
#include <stdint.h>
11+
12+
#include <sanitizer/msan_interface.h>
13+
14+
// cgoTracebackArg is the type of the argument passed to msanGoTraceback.
15+
struct cgoTracebackArg {
16+
uintptr_t context;
17+
uintptr_t sigContext;
18+
uintptr_t* buf;
19+
uintptr_t max;
20+
};
21+
22+
// msanGoTraceback is registered as the cgo traceback function.
23+
// This will be called when a signal occurs.
24+
void msanGoTraceback(void* parg) {
25+
struct cgoTracebackArg* arg = (struct cgoTracebackArg*)(parg);
26+
arg->buf[0] = 0;
27+
}
28+
29+
// msanGoWait will be called with all registers undefined as far as
30+
// msan is concerned. It just waits for a signal.
31+
// Because the registers are msan-undefined, the signal handler will
32+
// be invoked with all registers msan-undefined.
33+
__attribute__((noinline))
34+
void msanGoWait(unsigned long a1, unsigned long a2, unsigned long a3, unsigned long a4, unsigned long a5, unsigned long a6) {
35+
sigset_t mask;
36+
37+
sigemptyset(&mask);
38+
sigsuspend(&mask);
39+
}
40+
41+
// msanGoSignalThread is the thread ID of the msanGoLoop thread.
42+
static pthread_t msanGoSignalThread;
43+
44+
// msanGoSignalThreadSet is used to record that msanGoSignalThread
45+
// has been initialized. This is accessed atomically.
46+
static int32_t msanGoSignalThreadSet;
47+
48+
// uninit is explicitly poisoned, so that we can make all registers
49+
// undefined by calling msanGoWait.
50+
static unsigned long uninit;
51+
52+
// msanGoLoop loops calling msanGoWait, with the arguments passed
53+
// such that msan thinks that they are undefined. msan permits
54+
// undefined values to be used as long as they are not used to
55+
// for conditionals or for memory access.
56+
void msanGoLoop() {
57+
int i;
58+
59+
msanGoSignalThread = pthread_self();
60+
__atomic_store_n(&msanGoSignalThreadSet, 1, __ATOMIC_SEQ_CST);
61+
62+
// Force uninit to be undefined for msan.
63+
__msan_poison(&uninit, sizeof uninit);
64+
for (i = 0; i < 100; i++) {
65+
msanGoWait(uninit, uninit, uninit, uninit, uninit, uninit);
66+
}
67+
}
68+
69+
// msanGoReady returns whether msanGoSignalThread is set.
70+
int msanGoReady() {
71+
return __atomic_load_n(&msanGoSignalThreadSet, __ATOMIC_SEQ_CST) != 0;
72+
}
73+
74+
// msanGoSendSignal sends a signal to the msanGoLoop thread.
75+
void msanGoSendSignal() {
76+
pthread_kill(msanGoSignalThread, SIGWINCH);
77+
}
78+
*/
79+
import "C"
80+
81+
import (
82+
"runtime"
83+
"time"
84+
)
85+
86+
func main() {
87+
runtime.SetCgoTraceback(0, C.msanGoTraceback, nil, nil)
88+
89+
c := make(chan bool)
90+
go func() {
91+
defer func() { c <- true }()
92+
C.msanGoLoop()
93+
}()
94+
95+
for C.msanGoReady() == 0 {
96+
time.Sleep(time.Microsecond)
97+
}
98+
99+
loop:
100+
for {
101+
select {
102+
case <-c:
103+
break loop
104+
default:
105+
C.msanGoSendSignal()
106+
time.Sleep(time.Microsecond)
107+
}
108+
}
109+
}

src/cmd/dist/build.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -1263,14 +1263,19 @@ func cmdbootstrap() {
12631263
timelog("start", "dist bootstrap")
12641264
defer timelog("end", "dist bootstrap")
12651265

1266-
var noBanner bool
1266+
var noBanner, noClean bool
12671267
var debug bool
12681268
flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all")
12691269
flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process")
12701270
flag.BoolVar(&noBanner, "no-banner", noBanner, "do not print banner")
1271+
flag.BoolVar(&noClean, "no-clean", noClean, "print deprecation warning")
12711272

12721273
xflagparse(0)
12731274

1275+
if noClean {
1276+
xprintf("warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead\n")
1277+
}
1278+
12741279
// Set GOPATH to an internal directory. We shouldn't actually
12751280
// need to store files here, since the toolchain won't
12761281
// depend on modules outside of vendor directories, but if

src/cmd/go/internal/modload/buildlist.go

+19
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,19 @@ func (rs *Requirements) rootSelected(path string) (version string, ok bool) {
191191
return "", false
192192
}
193193

194+
// hasRedundantRoot returns true if the root list contains multiple requirements
195+
// of the same module or a requirement on any version of the main module.
196+
// Redundant requirements should be pruned, but they may influence version
197+
// selection.
198+
func (rs *Requirements) hasRedundantRoot() bool {
199+
for i, m := range rs.rootModules {
200+
if m.Path == Target.Path || (i > 0 && m.Path == rs.rootModules[i-1].Path) {
201+
return true
202+
}
203+
}
204+
return false
205+
}
206+
194207
// Graph returns the graph of module requirements loaded from the current
195208
// root modules (as reported by RootModules).
196209
//
@@ -882,6 +895,12 @@ func updateLazyRoots(ctx context.Context, direct map[string]bool, rs *Requiremen
882895
// and (trivially) version.
883896

884897
if !rootsUpgraded {
898+
if cfg.BuildMod != "mod" {
899+
// The only changes to the root set (if any) were to remove duplicates.
900+
// The requirements are consistent (if perhaps redundant), so keep the
901+
// original rs to preserve its ModuleGraph.
902+
return rs, nil
903+
}
885904
// The root set has converged: every root going into this iteration was
886905
// already at its selected version, although we have have removed other
887906
// (redundant) roots for the same path.

0 commit comments

Comments
 (0)