Move from facts render to facts validation.

This allows fact information to be validated in the underlying source files,
but requires us to explicitly maintain this in appropriate version-tagged, and
architecture-tagged files. This is more explicit and safer.

This mechanism uses a special regular expression for matching a +checkconst
stanza to validate constant values, sizes and offsets. This applies to both Go
source files and assembly files.

PiperOrigin-RevId: 511867507
This commit is contained in:
Adin Scannell
2023-02-23 13:17:49 -08:00
committed by gVisor bot
parent 5817f4cc64
commit bd561fd3f9
33 changed files with 646 additions and 952 deletions
+2 -19
View File
@@ -1,30 +1,13 @@
load("//tools:arch.bzl", "arch_genrule", "select_arch")
load("//tools:defs.bzl", "go_library", "go_test")
load("//tools/nogo:defs.bzl", "nogo_facts")
package(licenses = ["notice"])
nogo_facts(
name = "goid_impl",
srcs = ["goid.go"],
output = "goid_impl.s",
template = select_arch(
amd64 = "goid_amd64.s",
arm64 = "goid_arm64.s",
),
)
arch_genrule(
name = "goid_impl_arch",
src = ":goid_impl",
template = "goid_impl_%s.s",
)
go_library(
name = "goid",
srcs = [
"goid.go",
":goid_impl_arch",
"goid_amd64.s",
"goid_arm64.s",
],
stateify = False,
visibility = ["//visibility:public"],
+1 -4
View File
@@ -16,12 +16,9 @@
package goid
import (
"runtime"
_ "runtime" // For facts in assembly files.
)
// Dummy references for facts.
const _ = runtime.Compiler
// goid returns the current goid, it is defined in assembly.
func goid() int64
+1 -1
View File
@@ -14,7 +14,7 @@
#include "textflag.h"
#define GOID_OFFSET {{ .import.runtime.g.goid.Offset }}
#define GOID_OFFSET 152 // +checkoffset runtime g.goid
// func goid() int64
TEXT ·goid(SB),NOSPLIT,$0-8
+1 -1
View File
@@ -14,7 +14,7 @@
#include "textflag.h"
#define GOID_OFFSET {{ .import.runtime.g.goid.Offset }}
#define GOID_OFFSET 152 // +checkoffset runtime g.goid
// func goid() int64
TEXT ·goid(SB),NOSPLIT,$0-8