]> Cypherpunks repositories - gostls13.git/commitdiff
all: document legacy //go:linkname for modules with ≥100 dependents
authorRuss Cox <rsc@golang.org>
Wed, 22 May 2024 21:09:02 +0000 (17:09 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 29 May 2024 16:25:21 +0000 (16:25 +0000)
For #67401.

Change-Id: I015408a3f437c1733d97160ef2fb5da6d4efcc5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/587598
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>

30 files changed:
src/go/build/build.go
src/go/build/read.go
src/go/types/badlinkname.go
src/internal/bytealg/compare_generic.go
src/internal/cpu/cpu_arm64_darwin.go
src/reflect/badlinkname.go
src/reflect/type.go
src/runtime/alg.go
src/runtime/atomic_pointer.go
src/runtime/badlinkname.go
src/runtime/cpuprof.go
src/runtime/linkname.go
src/runtime/malloc.go
src/runtime/map.go
src/runtime/mbarrier.go
src/runtime/mgc.go
src/runtime/panic.go
src/runtime/pprof/pprof.go
src/runtime/proc.go
src/runtime/proflabel.go
src/runtime/rand.go
src/runtime/slice.go
src/runtime/stubs.go
src/runtime/symtab.go
src/runtime/symtabinl.go
src/runtime/timestub.go
src/runtime/traceback.go
src/sync/pool.go
src/time/badlinkname.go [deleted file]
src/time/time.go

index 297384d84c077542c4f872675995fa4ea2f209ac..000db9fb652e957e6c29e1eb0fc7443bb4adf83e 100644 (file)
@@ -1626,6 +1626,15 @@ func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool) (shoul
        return shouldBuild, sawBinaryOnly, nil
 }
 
+// parseFileHeader should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/bazelbuild/bazel-gazelle
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname parseFileHeader
 func parseFileHeader(content []byte) (trimmed, goBuild []byte, sawBinaryOnly bool, err error) {
        end := 0
        p := content
index 52891975c1d1290803bf32cede9def76ff5ece4a..1273066dbc77c9e4b41da8f60439e76e3ee75108 100644 (file)
@@ -18,6 +18,7 @@ import (
        "strings"
        "unicode"
        "unicode/utf8"
+       _ "unsafe" // for linkname
 )
 
 type importReader struct {
@@ -378,6 +379,16 @@ func (r *importReader) readImport() {
 
 // readComments is like io.ReadAll, except that it only reads the leading
 // block of comments in the file.
+//
+// readComments should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/bazelbuild/bazel-gazelle
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname readComments
 func readComments(f io.Reader) ([]byte, error) {
        r := newImportReader("", f)
        r.peekByte(true)
index 38b6a103a935078f6d4ddf260841b881879b6927..432322ad90013248f960d322ade0d703de9332d1 100644 (file)
@@ -6,15 +6,15 @@ package types
 
 import _ "unsafe"
 
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-// The compiler doesn't allow linknames on methods, for good reasons.
-// We use this trick to push linknames of the methods.
-// Do not call them in this package.
+// This should properly be in infer.go, but that file is auto-generated.
 
+// infer should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/goplus/gox
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
 //go:linkname badlinkname_Checker_infer go/types.(*Checker).infer
 func badlinkname_Checker_infer(*Checker, positioner, []*TypeParam, []Type, *Tuple, []*operand, bool, *error_) []Type
index 74126ae8051d17576ae96e4a1071c556d9d28664..204b9a9b1a38c8bafd997cb092dad62c58e7207c 100644 (file)
@@ -45,6 +45,7 @@ func CompareString(a, b string) int {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/gopkg
+//   - github.com/songzhibin97/gkit
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index fad66c6c9062ffbb5dd502263ac67405fc96f497..2507780e5f1ba70561940c2daf00802284b2cff1 100644 (file)
@@ -30,6 +30,7 @@ func getsysctlbyname(name []byte) (int32, int32)
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/gopkg
+//   - github.com/songzhibin97/gkit
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index e2e1d4abc93d5e22219292d4133737fa724cee10..62c5675158abc684e36f7d7619445f4a60e7e4f9 100644 (file)
@@ -12,6 +12,7 @@ import (
 // Widely used packages access these symbols using linkname,
 // most notably:
 //     - github.com/goccy/go-json
+//     - github.com/goccy/go-reflect
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401
index 1c9260124f5301be8e2bc5fa47236b1a49d53c2d..af2d8ecf256a4e209fb3983b439482db565668c4 100644 (file)
@@ -1664,6 +1664,7 @@ func rtypeOff(section unsafe.Pointer, off int32) *abi.Type {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/aristanetworks/goarista
+//   - fortio.org/log
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -2920,7 +2921,9 @@ func appendVarint(x []byte, v uintptr) []byte {
 // toType should be an internal detail,
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
+//   - fortio.org/log
 //   - github.com/goccy/go-json
+//   - github.com/goccy/go-reflect
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index c11ef4c6efd3b1bbae6e01368e2716eb2f8453fb..c55f916a7a44b6073ae870436d4f648551199887 100644 (file)
@@ -51,10 +51,12 @@ var useAeshash bool
 // Notable members of the hall of shame include:
 //   - github.com/aacfactory/fns
 //   - github.com/dgraph-io/ristretto
+//   - github.com/minio/simdjson-go
 //   - github.com/nbd-wtf/go-nostr
 //   - github.com/outcaste-io/ristretto
 //   - github.com/puzpuzpuz/xsync/v2
 //   - github.com/puzpuzpuz/xsync/v3
+//   - github.com/segmentio/parquet-go
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -62,7 +64,26 @@ var useAeshash bool
 //go:linkname memhash
 func memhash(p unsafe.Pointer, h, s uintptr) uintptr
 
+// memhash32 should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/segmentio/parquet-go
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname memhash32
 func memhash32(p unsafe.Pointer, h uintptr) uintptr
+
+// memhash64 should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/segmentio/parquet-go
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname memhash64
 func memhash64(p unsafe.Pointer, h uintptr) uintptr
 
 // strhash should be an internal detail,
@@ -72,6 +93,7 @@ func memhash64(p unsafe.Pointer, h uintptr) uintptr
 //   - github.com/bytedance/sonic
 //   - github.com/bytedance/go-tagexpr/v2
 //   - github.com/cloudwego/frugal
+//   - github.com/cloudwego/dynamicgo
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 9711fb208bbb3de8234a646bc6c4644fd911c1ca..df067ede77f8eb8ac3b378142761aeeda003cc30 100644 (file)
@@ -22,6 +22,7 @@ import (
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/gopkg
+//   - github.com/songzhibin97/gkit
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index a0bdab2ca6274e8c0282b0cc51ec1072f873f93d..4094e0b9b2abe6fff7e95c05f449c611fe36f223 100644 (file)
@@ -17,8 +17,6 @@ import _ "unsafe"
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
 
-//go:linkname add
-//go:linkname callers
 //go:linkname fastexprand
 //go:linkname gopanic
 //go:linkname sched
index 80490aa585ca2a66864176201152296cd4505bc1..997a949a30839a237ec6234f49636894cc8164d3 100644 (file)
@@ -209,7 +209,15 @@ func CPUProfile() []byte {
        panic("CPUProfile no longer available")
 }
 
-//go:linkname pprof_cyclesPerSecond
+// runtime/pprof.runtime_cyclesPerSecond should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/grafana/pyroscope-go/godeltaprof
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname pprof_cyclesPerSecond runtime/pprof.runtime_cyclesPerSecond
 func pprof_cyclesPerSecond() int64 {
        return ticksPerSecond()
 }
index 19318cd9a9bc7a897f13daa9da9bb27dce86ea01..39217b68a4fd2d58ef1a8c1f07622779195da146 100644 (file)
@@ -31,7 +31,6 @@ import _ "unsafe"
 
 // used in tests
 //go:linkname extraMInUse
-//go:linkname getm
 //go:linkname blockevent
 //go:linkname haveHighResSleep
 //go:linkname blockUntilEmptyFinalizerQueue
index 70a198a81c905f8627db5d2a7fbf57a3cbe06f91..810841952930b545ada1cd1a52f4d8f2baac9b75 100644 (file)
@@ -1411,6 +1411,7 @@ func reflectlite_unsafe_New(typ *_type) unsafe.Pointer {
 // newarray should be an internal detail,
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
+//   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
 //   - github.com/ugorji/go/codec
 //
index 5b13fda3047abb503395cf284c6c874ba6e799b2..8757f18b3bfb2f370587911ab827cca7b960d410 100644 (file)
@@ -604,6 +604,7 @@ func mapaccess2_fat(t *maptype, h *hmap, key, zero unsafe.Pointer) (unsafe.Point
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/sonic
 //   - github.com/cloudwego/frugal
+//   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
 //   - github.com/ugorji/go/codec
 //
@@ -864,6 +865,7 @@ search:
 //   - github.com/bytedance/sonic
 //   - github.com/cloudwego/frugal
 //   - github.com/goccy/go-json
+//   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
 //   - github.com/ugorji/go/codec
 //
@@ -922,6 +924,7 @@ func mapiterinit(t *maptype, h *hmap, it *hiter) {
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/sonic
 //   - github.com/cloudwego/frugal
+//   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
 //   - github.com/ugorji/go/codec
 //   - gonum.org/v1/gonum
@@ -1389,6 +1392,7 @@ func advanceEvacuationMark(h *hmap, t *maptype, newbit uintptr) {
 //   - gitee.com/quant1x/gox
 //   - github.com/modern-go/reflect2
 //   - github.com/goccy/go-json
+//   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
 //
 // Do not remove or change the type signature.
index c83e5c6fcdc1d0191bc5fba571378863bdfcb165..b4fc48977f3f75aebb923eb68a63285be8bb0edb 100644 (file)
@@ -151,6 +151,7 @@ import (
 // typedmemmove should be an internal detail,
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
+//   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
 //
 // Do not remove or change the type signature.
@@ -337,6 +338,7 @@ func typedslicecopy(typ *_type, dstPtr unsafe.Pointer, dstLen int, srcPtr unsafe
 // Notable members of the hall of shame include:
 //   - gitee.com/quant1x/gox
 //   - github.com/modern-go/reflect2
+//   - github.com/RomiChan/protobuf
 //   - github.com/segmentio/encoding
 //
 // Do not remove or change the type signature.
index 9874a9afde9e61e8ba164cf4941fa6f56948a39a..2654c6965822110eabc8fb31ddf74b17d27afde9 100644 (file)
@@ -1708,6 +1708,7 @@ var uniqueMapCleanup chan struct{} // for unique
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/gopkg
+//   - github.com/songzhibin97/gkit
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 2e15649092a5eb67384fe67f9ab9768643aedc69..6929862a7dbffd20958358aef2e988bf38f32fbb 100644 (file)
@@ -1034,6 +1034,7 @@ func sync_fatal(s string) {
 //   - github.com/cockroachdb/pebble
 //   - github.com/dgraph-io/ristretto
 //   - github.com/outcaste-io/ristretto
+//   - github.com/pingcap/br
 //   - gvisor.dev/gvisor
 //
 // Do not remove or change the type signature.
index b387397d42cd9aff58a198fe42800c56d14dd6de..43ef66f0b03fe571c29737b475f654d0b8279ed6 100644 (file)
@@ -948,7 +948,7 @@ func writeProfileInternal(w io.Writer, debug int, name string, runtimeProfile fu
 //go:linkname pprof_goroutineProfileWithLabels runtime.pprof_goroutineProfileWithLabels
 func pprof_goroutineProfileWithLabels(p []profilerecord.StackRecord, labels []unsafe.Pointer) (n int, ok bool)
 
-//go:linkname pprof_cyclesPerSecond runtime.pprof_cyclesPerSecond
+//go:linkname pprof_cyclesPerSecond runtime/pprof.runtime_cyclesPerSecond
 func pprof_cyclesPerSecond() int64
 
 //go:linkname pprof_memProfileInternal runtime.pprof_memProfileInternal
index 17b2e4d9c21668eede3a81a77928ace0635ef980..9574628ee20ed051f27907854c6e29aaf7973213 100644 (file)
@@ -2577,6 +2577,16 @@ func cgoBindM() {
 }
 
 // A helper function for EnsureDropM.
+//
+// getm should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - fortio.org/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname getm
 func getm() uintptr {
        return uintptr(unsafe.Pointer(getg().m))
 }
@@ -7051,6 +7061,7 @@ func setMaxThreads(in int) (out int) {
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/gopkg
 //   - github.com/choleraehyq/pid
+//   - github.com/songzhibin97/gkit
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -7070,6 +7081,7 @@ func procPin() int {
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/gopkg
 //   - github.com/choleraehyq/pid
+//   - github.com/songzhibin97/gkit
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 7c29c0ef836ac55609f1313670b47982b6b89d99..1a5e7e5e2f14a002a4a8b83fc4ae5e20a00a6fdc 100644 (file)
@@ -11,6 +11,7 @@ var labelSync uintptr
 // runtime_setProfLabel should be an internal detail,
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
+//   - github.com/cloudwego/localsession
 //   - github.com/DataDog/datadog-agent
 //
 // Do not remove or change the type signature.
@@ -45,6 +46,7 @@ func runtime_setProfLabel(labels unsafe.Pointer) {
 // runtime_getProfLabel should be an internal detail,
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
+//   - github.com/cloudwego/localsession
 //   - github.com/DataDog/datadog-agent
 //
 // Do not remove or change the type signature.
index 827d182d12f5e1d208704bd91088c40a189728f0..7e313c19bde91158eff3e323d0bf612de36f0676 100644 (file)
@@ -233,6 +233,15 @@ func cheaprand64() int64 {
 // the rule is that other packages using runtime-provided
 // randomness must always use randn.
 //
+// cheaprandn should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/phuslu/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname cheaprandn
 //go:nosplit
 func cheaprandn(n uint32) uint32 {
        // See https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
index b91caf0dfe885b979067e3a12a298bd924f22ddd..78475735af3d5788bb36d41bda2996cb6286e0f1 100644 (file)
@@ -167,6 +167,7 @@ func makeslice64(et *_type, len64, cap64 int64) unsafe.Pointer {
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/sonic
 //   - github.com/chenzhuoyu/iasm
+//   - github.com/cloudwego/dynamicgo
 //   - github.com/ugorji/go/codec
 //
 // Do not remove or change the type signature.
@@ -319,6 +320,14 @@ func nextslicecap(newLen, oldCap int) int {
        return newcap
 }
 
+// reflect_growslice should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/cloudwego/dynamicgo
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
 //go:linkname reflect_growslice reflect.growslice
 func reflect_growslice(et *_type, old slice, num int) slice {
        // Semantically equivalent to slices.Grow, except that the caller
index ff4fe5eafd3aa27edc603b3e3c2c6f7fdc3c6825..d3f75bfcac669429d722a8ba581b8535b06e9ec1 100644 (file)
@@ -11,6 +11,15 @@ import (
 
 // Should be a built-in for unsafe.Pointer?
 //
+// add should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - fortio.org/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname add
 //go:nosplit
 func add(p unsafe.Pointer, x uintptr) unsafe.Pointer {
        return unsafe.Pointer(uintptr(p) + x)
@@ -122,6 +131,7 @@ func reflect_memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/sonic
+//   - github.com/cloudwego/dynamicgo
 //   - github.com/cloudwego/frugal
 //   - github.com/ebitengine/purego
 //   - github.com/tetratelabs/wazero
@@ -168,7 +178,9 @@ func memequal(a, b unsafe.Pointer, size uintptr) bool
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/gopkg
 //   - github.com/ebitengine/purego
+//   - github.com/hamba/avro/v2
 //   - github.com/puzpuzpuz/xsync/v3
+//   - github.com/songzhibin97/gkit
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -255,7 +267,9 @@ func reflectcall(stackArgsType *_type, fn, stackArgs unsafe.Pointer, stackArgsSi
 // procyield should be an internal detail,
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
+//   - github.com/sagernet/sing-tun
 //   - github.com/slackhq/nebula
+//   - github.com/tailscale/wireguard-go
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
index 40f0be65428e43fb6417d604447bbec4bfc09952..993b29d5c041787c356a0242a99b47eaa62787b2 100644 (file)
@@ -196,6 +196,14 @@ func (ci *Frames) Next() (frame Frame, more bool) {
 
 // runtime_FrameStartLine returns the start line of the function in a Frame.
 //
+// runtime_FrameStartLine should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/grafana/pyroscope-go/godeltaprof
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
 //go:linkname runtime_FrameStartLine runtime/pprof.runtime_FrameStartLine
 func runtime_FrameStartLine(f *Frame) int {
        return f.startLine
@@ -205,6 +213,14 @@ func runtime_FrameStartLine(f *Frame) int {
 // For generic functions this differs from f.Function in that this doesn't replace
 // the shape name to "...".
 //
+// runtime_FrameSymbolName should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/grafana/pyroscope-go/godeltaprof
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
 //go:linkname runtime_FrameSymbolName runtime/pprof.runtime_FrameSymbolName
 func runtime_FrameSymbolName(f *Frame) string {
        if !f.funcInfo.valid() {
@@ -218,6 +234,14 @@ func runtime_FrameSymbolName(f *Frame) string {
 // runtime_expandFinalInlineFrame expands the final pc in stk to include all
 // "callers" if pc is inline.
 //
+// runtime_expandFinalInlineFrame should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/grafana/pyroscope-go/godeltaprof
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
 //go:linkname runtime_expandFinalInlineFrame runtime/pprof.runtime_expandFinalInlineFrame
 func runtime_expandFinalInlineFrame(stk []uintptr) []uintptr {
        // TODO: It would be more efficient to report only physical PCs to pprof and
@@ -814,10 +838,21 @@ func (f *_func) isInlined() bool {
 }
 
 // entry returns the entry PC for f.
+//
+// entry should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/phuslu/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
 func (f funcInfo) entry() uintptr {
        return f.datap.textAddr(f.entryOff)
 }
 
+//go:linkname badFuncInfoEntry runtime.funcInfo.entry
+func badFuncInfoEntry(funcInfo) uintptr
+
 // findfunc looks up function metadata for a PC.
 //
 // It is nosplit because it's part of the isgoexception
@@ -827,6 +862,7 @@ func (f funcInfo) entry() uintptr {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/cloudwego/frugal
+//   - github.com/phuslu/log
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
@@ -878,6 +914,13 @@ func (f funcInfo) srcFunc() srcFunc {
        return srcFunc{f.datap, f.nameOff, f.startLine, f.funcID}
 }
 
+// name should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/phuslu/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
 func (s srcFunc) name() string {
        if s.datap == nil {
                return ""
@@ -885,6 +928,9 @@ func (s srcFunc) name() string {
        return s.datap.funcName(s.nameOff)
 }
 
+//go:linkname badSrcFuncName runtime.srcFunc.name
+func badSrcFuncName(srcFunc) string
+
 type pcvalueCache struct {
        entries [2][8]pcvalueCacheEnt
        inUse   int
@@ -1074,6 +1120,15 @@ func funcfile(f funcInfo, fileno int32) string {
        return "?"
 }
 
+// funcline1 should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/phuslu/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname funcline1
 func funcline1(f funcInfo, targetpc uintptr, strict bool) (file string, line int32) {
        datap := f.datap
        if !f.valid() {
@@ -1159,16 +1214,6 @@ func pcdatavalue2(f funcInfo, table uint32, targetpc uintptr) (int32, uintptr) {
 
 // funcdata returns a pointer to the ith funcdata for f.
 // funcdata should be kept in sync with cmd/link:writeFuncs.
-//
-// funcdata should be an internal detail,
-// but widely used packages access it using linkname.
-// Notable members of the hall of shame include:
-//   - github.com/cloudwego/frugal
-//
-// Do not remove or change the type signature.
-// See go.dev/issue/67401.
-//
-//go:linkname funcdata
 func funcdata(f funcInfo, i uint8) unsafe.Pointer {
        if i < 0 || i >= f.nfuncdata {
                return nil
index 9273b49b11e51f4a6e6e63d29d9588b769df514c..faa01decb9f70ef194b23964d79a0676cad279b5 100644 (file)
@@ -4,7 +4,10 @@
 
 package runtime
 
-import "internal/abi"
+import (
+       "internal/abi"
+       _ "unsafe" // for linkname
+)
 
 // inlinedCall is the encoding of entries in the FUNCDATA_InlTree table.
 type inlinedCall struct {
@@ -51,6 +54,16 @@ type inlineFrame struct {
 // This unwinder uses non-strict handling of PC because it's assumed this is
 // only ever used for symbolic debugging. If things go really wrong, it'll just
 // fall back to the outermost frame.
+//
+// newInlineUnwinder should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/phuslu/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname newInlineUnwinder
 func newInlineUnwinder(f funcInfo, pc uintptr) (inlineUnwinder, inlineFrame) {
        inldata := funcdata(f, abi.FUNCDATA_InlTree)
        if inldata == nil {
@@ -90,6 +103,16 @@ func (u *inlineUnwinder) isInlined(uf inlineFrame) bool {
 }
 
 // srcFunc returns the srcFunc representing the given frame.
+//
+// srcFunc should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/phuslu/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+// The go:linkname is below.
 func (u *inlineUnwinder) srcFunc(uf inlineFrame) srcFunc {
        if uf.index < 0 {
                return u.f.srcFunc()
@@ -103,6 +126,9 @@ func (u *inlineUnwinder) srcFunc(uf inlineFrame) srcFunc {
        }
 }
 
+//go:linkname badSrcFunc runtime.(*inlineUnwinder).srcFunc
+func badSrcFunc(*inlineUnwinder, inlineFrame) srcFunc
+
 // fileLine returns the file name and line number of the call within the given
 // frame. As a convenience, for the innermost frame, it returns the file and
 // line of the PC this unwinder was started at (often this is a call to another
index a9d71c1fd4042ff1327c1519569c5e6300a1a0f3..da8699b5ee60dafc2827dc16156576561d29f576 100644 (file)
@@ -15,6 +15,7 @@ import _ "unsafe" // for go:linkname
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - gitee.com/quant1x/gox
+//   - github.com/phuslu/log
 //   - github.com/sethvargo/go-limiter
 //   - github.com/ulule/limiter/v3
 //
index ebee16c6a738ab49ee6eebd2636fbafa05f68052..03c02f77713af7c5c71c8c61ece46b0ff63cab52 100644 (file)
@@ -1079,6 +1079,16 @@ func printAncestorTracebackFuncInfo(f funcInfo, pc uintptr) {
        print("\n")
 }
 
+// callers should be an internal detail,
+// (and is almost identical to Callers),
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/phuslu/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname callers
 func callers(skip int, pcbuf []uintptr) int {
        sp := getcallersp()
        pc := getcallerpc()
index 881cd1f4c25e5062476d650af87b51dda22eea9c..4b586d6fb9fc3fd55da509c95f2e5aed132360b2 100644 (file)
@@ -246,6 +246,7 @@ func (p *Pool) pinSlow() (*poolLocal, int) {
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
 //   - github.com/bytedance/gopkg
+//   - github.com/songzhibin97/gkit
 //
 // Do not remove or change the type signature.
 // See go.dev/issue/67401.
diff --git a/src/time/badlinkname.go b/src/time/badlinkname.go
deleted file mode 100644 (file)
index 097a823..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package time
-
-import _ "unsafe"
-
-// As of Go 1.22, the symbols below are found to be pulled via
-// linkname in the wild. We provide a push linkname here, to
-// keep them accessible with pull linknames.
-// This may change in the future. Please do not depend on them
-// in new code.
-
-//go:linkname absClock
index 63ee6f6f94c0904611f18b109ef3119fb9814815..27ff975784a2702926fb6ff26a9da8995559ae11 100644 (file)
@@ -579,6 +579,16 @@ func (t Time) Clock() (hour, min, sec int) {
 }
 
 // absClock is like clock but operates on an absolute time.
+//
+// absClock should be an internal detail,
+// but widely used packages access it using linkname.
+// Notable members of the hall of shame include:
+//   - github.com/phuslu/log
+//
+// Do not remove or change the type signature.
+// See go.dev/issue/67401.
+//
+//go:linkname absClock
 func absClock(abs uint64) (hour, min, sec int) {
        sec = int(abs % secondsPerDay)
        hour = sec / secondsPerHour
@@ -992,6 +1002,7 @@ func (t Time) date(full bool) (year int, month Month, day int, yday int) {
 // absDate should be an internal detail,
 // but widely used packages access it using linkname.
 // Notable members of the hall of shame include:
+//   - github.com/phuslu/log
 //   - gitee.com/quant1x/gox
 //
 // Do not remove or change the type signature.