mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
This CL introduces a 'checklinkname' analyzer, which provides rudimentary type-checking that verifies that function signatures on the local and remote sides of //go:linkname directives match expected values. If the Go standard library changes the definitions of any of these function, checklinkname will flag the change as a finding, providing an error informing the gVisor team to adapt to the upstream changes. This allows us to eliminate the majority of gVisor's forward-looking negative build tags, as we can catch mismatches in testing [1]. The remaining forward-looking negative build tags are covering shared struct definitions, which I hope to add to checklinkname in a future CL. [1] Of course, semantics/requirements can change without the signature changing, so we still must be careful, but this covers the common case. PiperOrigin-RevId: 387873847
21 lines
499 B
Go
21 lines
499 B
Go
// Copyright 2020 The gVisor Authors.
|
|
//
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
//go:build go1.14
|
|
// +build go1.14
|
|
|
|
// //go:linkname directives type-checked by checklinkname. Any other
|
|
// non-linkname assumptions outside the Go 1 compatibility guarantee should
|
|
// have an accompanied vet check or version guard build tag.
|
|
|
|
package sync
|
|
|
|
import (
|
|
_ "unsafe" // for go:linkname
|
|
)
|
|
|
|
//go:linkname goyield runtime.goyield
|
|
func goyield()
|