Skip to content

Commit 9a3ef86

Browse files
rscgopherbot
authored andcommitted
all: document legacy //go:linkname for modules with ≥5,000 dependents
For #67401. Change-Id: Ifea84af92017b405466937f50fb8f28e6893c8cb Reviewed-on: https://go-review.googlesource.com/c/go/+/587220 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Russ Cox <[email protected]>
1 parent 50c298a commit 9a3ef86

File tree

10 files changed

+111
-27
lines changed

10 files changed

+111
-27
lines changed

src/crypto/tls/badlinkname.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ import _ "unsafe"
1414

1515
//go:linkname aeadAESGCMTLS13
1616
//go:linkname cipherSuiteTLS13ByID
17-
//go:linkname cipherSuitesTLS13
18-
//go:linkname defaultCipherSuitesTLS13
19-
//go:linkname defaultCipherSuitesTLS13NoAES
2017
//go:linkname errShutdown
2118

2219
// The compiler doesn't allow linknames on methods, for good reasons.

src/crypto/tls/cipher_suites.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"hash"
1919
"internal/cpu"
2020
"runtime"
21+
_ "unsafe" // for linkname
2122

2223
"golang.org/x/crypto/chacha20poly1305"
2324
)
@@ -197,6 +198,15 @@ type cipherSuiteTLS13 struct {
197198
hash crypto.Hash
198199
}
199200

201+
// cipherSuitesTLS13 should be an internal detail,
202+
// but widely used packages access it using linkname.
203+
// Notable members of the hall of shame include:
204+
// - github.com/quic-go/quic-go
205+
//
206+
// Do not remove or change the type signature.
207+
// See go.dev/issue/67401.
208+
//
209+
//go:linkname cipherSuitesTLS13
200210
var cipherSuitesTLS13 = []*cipherSuiteTLS13{ // TODO: replace with a map.
201211
{TLS_AES_128_GCM_SHA256, 16, aeadAESGCMTLS13, crypto.SHA256},
202212
{TLS_CHACHA20_POLY1305_SHA256, 32, aeadChaCha20Poly1305, crypto.SHA256},

src/math/big/arith_decl.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,93 @@
66

77
package big
88

9+
import _ "unsafe" // for linkname
10+
911
// implemented in arith_$GOARCH.s
1012

13+
// addVV should be an internal detail,
14+
// but widely used packages access it using linkname.
15+
// Notable members of the hall of shame include:
16+
// - github.com/remyoudompheng/bigfft
17+
//
18+
// Do not remove or change the type signature.
19+
// See go.dev/issue/67401.
20+
//
21+
//go:linkname addVV
1122
//go:noescape
1223
func addVV(z, x, y []Word) (c Word)
1324

25+
// subVV should be an internal detail,
26+
// but widely used packages access it using linkname.
27+
// Notable members of the hall of shame include:
28+
// - github.com/remyoudompheng/bigfft
29+
//
30+
// Do not remove or change the type signature.
31+
// See go.dev/issue/67401.
32+
//
33+
//go:linkname subVV
1434
//go:noescape
1535
func subVV(z, x, y []Word) (c Word)
1636

37+
// addVW should be an internal detail,
38+
// but widely used packages access it using linkname.
39+
// Notable members of the hall of shame include:
40+
// - github.com/remyoudompheng/bigfft
41+
//
42+
// Do not remove or change the type signature.
43+
// See go.dev/issue/67401.
44+
//
45+
//go:linkname addVW
1746
//go:noescape
1847
func addVW(z, x []Word, y Word) (c Word)
1948

49+
// subVW should be an internal detail,
50+
// but widely used packages access it using linkname.
51+
// Notable members of the hall of shame include:
52+
// - github.com/remyoudompheng/bigfft
53+
//
54+
// Do not remove or change the type signature.
55+
// See go.dev/issue/67401.
56+
//
57+
//go:linkname subVW
2058
//go:noescape
2159
func subVW(z, x []Word, y Word) (c Word)
2260

61+
// shlVU should be an internal detail,
62+
// but widely used packages access it using linkname.
63+
// Notable members of the hall of shame include:
64+
// - github.com/remyoudompheng/bigfft
65+
//
66+
// Do not remove or change the type signature.
67+
// See go.dev/issue/67401.
68+
//
69+
//go:linkname shlVU
2370
//go:noescape
2471
func shlVU(z, x []Word, s uint) (c Word)
2572

2673
//go:noescape
2774
func shrVU(z, x []Word, s uint) (c Word)
2875

76+
// mulAddVWW should be an internal detail,
77+
// but widely used packages access it using linkname.
78+
// Notable members of the hall of shame include:
79+
// - github.com/remyoudompheng/bigfft
80+
//
81+
// Do not remove or change the type signature.
82+
// See go.dev/issue/67401.
83+
//
84+
//go:linkname mulAddVWW
2985
//go:noescape
3086
func mulAddVWW(z, x []Word, y, r Word) (c Word)
3187

88+
// addMulVVW should be an internal detail,
89+
// but widely used packages access it using linkname.
90+
// Notable members of the hall of shame include:
91+
// - github.com/remyoudompheng/bigfft
92+
//
93+
// Do not remove or change the type signature.
94+
// See go.dev/issue/67401.
95+
//
96+
//go:linkname addMulVVW
3297
//go:noescape
3398
func addMulVVW(z, x []Word, y Word) (c Word)

src/math/big/badlinkname.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/runtime/linkname.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ package runtime
66

77
import _ "unsafe"
88

9-
// used in time and internal/poll
10-
//go:linkname nanotime
11-
129
// used in internal/godebug and syscall
1310
//go:linkname write
1411

src/runtime/map.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ func mapiterinit(t *maptype, h *hmap, it *hiter) {
917917
// Notable members of the hall of shame include:
918918
// - github.com/bytedance/sonic
919919
// - github.com/ugorji/go/codec
920+
// - gonum.org/v1/gonum
920921
//
921922
// Do not remove or change the type signature.
922923
// See go.dev/issue/67401.
@@ -1493,6 +1494,7 @@ func reflect_mapiternext(it *hiter) {
14931494
// but widely used packages access it using linkname.
14941495
// Notable members of the hall of shame include:
14951496
// - github.com/goccy/go-json
1497+
// - gonum.org/v1/gonum
14961498
//
14971499
// Do not remove or change the type signature.
14981500
// See go.dev/issue/67401.
@@ -1506,6 +1508,7 @@ func reflect_mapiterkey(it *hiter) unsafe.Pointer {
15061508
// but widely used packages access it using linkname.
15071509
// Notable members of the hall of shame include:
15081510
// - github.com/goccy/go-json
1511+
// - gonum.org/v1/gonum
15091512
//
15101513
// Do not remove or change the type signature.
15111514
// See go.dev/issue/67401.

src/runtime/time_fake.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var faketimeState struct {
3131
lastfd uintptr
3232
}
3333

34+
//go:linkname nanotime
3435
//go:nosplit
3536
func nanotime() int64 {
3637
return faketime

src/runtime/time_nofake.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ import "unsafe"
1414
// Zero means not to use faketime.
1515
var faketime int64
1616

17+
// Many external packages linkname nanotime to get a fast monotonic time.
18+
// Such code should be updated to use:
19+
//
20+
// var start = time.Now() // at init time
21+
//
22+
// and then replace nanotime() with time.Since(start), which is equally fast.
23+
//
24+
// However, all the code linknaming nanotime is never going to go away.
25+
// Do not remove or change the type signature.
26+
// See go.dev/issue/67401.
27+
//
28+
//go:linkname nanotime
1729
//go:nosplit
1830
func nanotime() int64 {
1931
return nanotime1()

src/syscall/linkname_darwin.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,13 @@ import _ "unsafe"
2121
// used by cmd/link
2222
//go:linkname msync
2323
//go:linkname fcntl
24+
25+
// mmap should be an internal detail,
26+
// but widely used packages access it using linkname.
27+
// Notable members of the hall of shame include:
28+
// - modernc.org/memory
29+
//
30+
// Do not remove or change the type signature.
31+
// See go.dev/issue/67401.
32+
//
33+
//go:linkname mmap

src/syscall/linkname_openbsd.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ import _ "unsafe"
1313
//go:linkname openat
1414
//go:linkname fstatat
1515
//go:linkname getentropy
16+
17+
// mmap should be an internal detail,
18+
// but widely used packages access it using linkname.
19+
// Notable members of the hall of shame include:
20+
// - modernc.org/memory
21+
//
22+
// Do not remove or change the type signature.
23+
// See go.dev/issue/67401.
24+
//
25+
//go:linkname mmap

0 commit comments

Comments
 (0)