summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--pkg/abi/BUILD3
-rw-r--r--pkg/abi/linux/BUILD3
-rw-r--r--pkg/amutex/BUILD2
-rw-r--r--pkg/atomicbitops/BUILD2
-rw-r--r--pkg/binary/BUILD2
-rw-r--r--pkg/bits/BUILD2
-rw-r--r--pkg/bpf/BUILD3
-rw-r--r--pkg/compressio/BUILD2
-rw-r--r--pkg/control/client/BUILD2
-rw-r--r--pkg/control/server/BUILD2
-rw-r--r--pkg/cpuid/BUILD3
-rw-r--r--pkg/dhcp/BUILD2
-rw-r--r--pkg/eventchannel/BUILD2
-rw-r--r--pkg/fd/BUILD2
-rw-r--r--pkg/gate/BUILD2
-rw-r--r--pkg/hashio/BUILD2
-rw-r--r--pkg/ilist/BUILD3
-rw-r--r--pkg/linewriter/BUILD2
-rw-r--r--pkg/log/BUILD2
-rw-r--r--pkg/metric/BUILD2
-rw-r--r--pkg/p9/BUILD2
-rw-r--r--pkg/p9/p9test/BUILD2
-rw-r--r--pkg/rand/BUILD2
-rw-r--r--pkg/refs/BUILD20
-rw-r--r--pkg/refs/refcounter.go4
-rw-r--r--pkg/refs/refcounter_state.go1
-rw-r--r--pkg/seccomp/BUILD3
-rw-r--r--pkg/secio/BUILD2
-rw-r--r--pkg/segment/test/BUILD2
-rw-r--r--pkg/sentry/arch/BUILD3
-rw-r--r--pkg/sentry/context/BUILD2
-rw-r--r--pkg/sentry/context/contexttest/BUILD3
-rw-r--r--pkg/sentry/control/BUILD2
-rw-r--r--pkg/sentry/device/BUILD2
-rw-r--r--pkg/sentry/fs/BUILD3
-rw-r--r--pkg/sentry/fs/anon/BUILD2
-rw-r--r--pkg/sentry/fs/ashmem/BUILD3
-rw-r--r--pkg/sentry/fs/binder/BUILD3
-rw-r--r--pkg/sentry/fs/dev/BUILD3
-rw-r--r--pkg/sentry/fs/fdpipe/BUILD3
-rw-r--r--pkg/sentry/fs/filetest/BUILD3
-rw-r--r--pkg/sentry/fs/fsutil/BUILD3
-rw-r--r--pkg/sentry/fs/gofer/BUILD3
-rw-r--r--pkg/sentry/fs/host/BUILD3
-rw-r--r--pkg/sentry/fs/lock/BUILD3
-rw-r--r--pkg/sentry/fs/proc/BUILD3
-rw-r--r--pkg/sentry/fs/proc/device/BUILD2
-rw-r--r--pkg/sentry/fs/proc/seqfile/BUILD3
-rw-r--r--pkg/sentry/fs/ramfs/BUILD3
-rw-r--r--pkg/sentry/fs/ramfs/test/BUILD3
-rw-r--r--pkg/sentry/fs/sys/BUILD3
-rw-r--r--pkg/sentry/fs/timerfd/BUILD3
-rw-r--r--pkg/sentry/fs/tmpfs/BUILD3
-rw-r--r--pkg/sentry/fs/tty/BUILD3
-rw-r--r--pkg/sentry/hostcpu/BUILD2
-rw-r--r--pkg/sentry/inet/BUILD4
-rw-r--r--pkg/sentry/kernel/BUILD3
-rw-r--r--pkg/sentry/kernel/auth/BUILD3
-rw-r--r--pkg/sentry/kernel/epoll/BUILD3
-rw-r--r--pkg/sentry/kernel/eventfd/BUILD3
-rw-r--r--pkg/sentry/kernel/fasync/BUILD2
-rw-r--r--pkg/sentry/kernel/futex/BUILD3
-rw-r--r--pkg/sentry/kernel/kdefs/BUILD2
-rw-r--r--pkg/sentry/kernel/memevent/BUILD2
-rw-r--r--pkg/sentry/kernel/pipe/BUILD3
-rw-r--r--pkg/sentry/kernel/sched/BUILD2
-rw-r--r--pkg/sentry/kernel/semaphore/BUILD3
-rw-r--r--pkg/sentry/kernel/shm/BUILD3
-rw-r--r--pkg/sentry/kernel/time/BUILD3
-rw-r--r--pkg/sentry/limits/BUILD3
-rw-r--r--pkg/sentry/loader/BUILD4
-rw-r--r--pkg/sentry/memmap/BUILD3
-rw-r--r--pkg/sentry/memutil/BUILD2
-rw-r--r--pkg/sentry/mm/BUILD3
-rw-r--r--pkg/sentry/platform/BUILD3
-rw-r--r--pkg/sentry/platform/filemem/BUILD3
-rw-r--r--pkg/sentry/platform/interrupt/BUILD2
-rw-r--r--pkg/sentry/platform/kvm/BUILD2
-rw-r--r--pkg/sentry/platform/kvm/testutil/BUILD2
-rw-r--r--pkg/sentry/platform/procid/BUILD2
-rw-r--r--pkg/sentry/platform/ptrace/BUILD2
-rw-r--r--pkg/sentry/platform/ring0/BUILD2
-rw-r--r--pkg/sentry/platform/ring0/pagetables/BUILD2
-rw-r--r--pkg/sentry/platform/safecopy/BUILD2
-rw-r--r--pkg/sentry/safemem/BUILD2
-rw-r--r--pkg/sentry/sighandling/BUILD2
-rw-r--r--pkg/sentry/socket/BUILD3
-rw-r--r--pkg/sentry/socket/control/BUILD3
-rw-r--r--pkg/sentry/socket/epsocket/BUILD3
-rw-r--r--pkg/sentry/socket/hostinet/BUILD3
-rw-r--r--pkg/sentry/socket/netlink/BUILD3
-rw-r--r--pkg/sentry/socket/netlink/port/BUILD3
-rw-r--r--pkg/sentry/socket/netlink/route/BUILD3
-rw-r--r--pkg/sentry/socket/rpcinet/BUILD2
-rw-r--r--pkg/sentry/socket/rpcinet/conn/BUILD2
-rw-r--r--pkg/sentry/socket/rpcinet/notifier/BUILD2
-rw-r--r--pkg/sentry/socket/unix/BUILD3
-rw-r--r--pkg/sentry/state/BUILD2
-rw-r--r--pkg/sentry/strace/BUILD2
-rw-r--r--pkg/sentry/syscalls/BUILD2
-rw-r--r--pkg/sentry/syscalls/linux/BUILD3
-rw-r--r--pkg/sentry/time/BUILD2
-rw-r--r--pkg/sentry/uniqueid/BUILD2
-rw-r--r--pkg/sentry/usage/BUILD3
-rw-r--r--pkg/sentry/usermem/BUILD3
-rw-r--r--pkg/sentry/watchdog/BUILD2
-rw-r--r--pkg/sleep/BUILD2
-rw-r--r--pkg/state/BUILD2
-rw-r--r--pkg/state/statefile/BUILD2
-rw-r--r--pkg/sync/BUILD2
-rw-r--r--pkg/sync/seqatomictest/BUILD2
-rw-r--r--pkg/syserr/BUILD2
-rw-r--r--pkg/syserror/BUILD2
-rw-r--r--pkg/tcpip/BUILD3
-rw-r--r--pkg/tcpip/adapters/gonet/BUILD2
-rw-r--r--pkg/tcpip/buffer/BUILD3
-rw-r--r--pkg/tcpip/checker/BUILD2
-rw-r--r--pkg/tcpip/header/BUILD3
-rw-r--r--pkg/tcpip/link/channel/BUILD2
-rw-r--r--pkg/tcpip/link/fdbased/BUILD2
-rw-r--r--pkg/tcpip/link/loopback/BUILD2
-rw-r--r--pkg/tcpip/link/rawfile/BUILD2
-rw-r--r--pkg/tcpip/link/sharedmem/BUILD2
-rw-r--r--pkg/tcpip/link/sharedmem/pipe/BUILD2
-rw-r--r--pkg/tcpip/link/sharedmem/queue/BUILD2
-rw-r--r--pkg/tcpip/link/sniffer/BUILD2
-rw-r--r--pkg/tcpip/link/tun/BUILD2
-rw-r--r--pkg/tcpip/link/waitable/BUILD2
-rw-r--r--pkg/tcpip/network/BUILD2
-rw-r--r--pkg/tcpip/network/arp/BUILD2
-rw-r--r--pkg/tcpip/network/fragmentation/BUILD3
-rw-r--r--pkg/tcpip/network/hash/BUILD2
-rw-r--r--pkg/tcpip/network/ipv4/BUILD2
-rw-r--r--pkg/tcpip/network/ipv6/BUILD2
-rw-r--r--pkg/tcpip/ports/BUILD2
-rw-r--r--pkg/tcpip/seqnum/BUILD3
-rw-r--r--pkg/tcpip/stack/BUILD15
-rw-r--r--pkg/tcpip/stack/registration.go2
-rw-r--r--pkg/tcpip/transport/ping/BUILD3
-rw-r--r--pkg/tcpip/transport/queue/BUILD3
-rw-r--r--pkg/tcpip/transport/tcp/BUILD3
-rw-r--r--pkg/tcpip/transport/tcp/testing/context/BUILD2
-rw-r--r--pkg/tcpip/transport/tcpconntrack/BUILD2
-rw-r--r--pkg/tcpip/transport/udp/BUILD3
-rw-r--r--pkg/tcpip/transport/unix/BUILD3
-rw-r--r--pkg/tmutex/BUILD2
-rw-r--r--pkg/unet/BUILD2
-rw-r--r--pkg/urpc/BUILD2
-rw-r--r--pkg/waiter/BUILD3
-rw-r--r--pkg/waiter/fdnotifier/BUILD2
-rw-r--r--tools/go_stateify/defs.bzl58
-rw-r--r--tools/go_stateify/main.go66
152 files changed, 255 insertions, 267 deletions
diff --git a/pkg/abi/BUILD b/pkg/abi/BUILD
index 4d507161f..f1e6bac67 100644
--- a/pkg/abi/BUILD
+++ b/pkg/abi/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "abi_state",
diff --git a/pkg/abi/linux/BUILD b/pkg/abi/linux/BUILD
index ae7e4378c..38b4829c9 100644
--- a/pkg/abi/linux/BUILD
+++ b/pkg/abi/linux/BUILD
@@ -4,8 +4,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "linux_state",
diff --git a/pkg/amutex/BUILD b/pkg/amutex/BUILD
index 442096319..84e6b79a5 100644
--- a/pkg/amutex/BUILD
+++ b/pkg/amutex/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "amutex",
diff --git a/pkg/atomicbitops/BUILD b/pkg/atomicbitops/BUILD
index f20a9f855..a8dd17825 100644
--- a/pkg/atomicbitops/BUILD
+++ b/pkg/atomicbitops/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "atomicbitops",
diff --git a/pkg/binary/BUILD b/pkg/binary/BUILD
index 16f08b13f..586d05634 100644
--- a/pkg/binary/BUILD
+++ b/pkg/binary/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "binary",
diff --git a/pkg/bits/BUILD b/pkg/bits/BUILD
index 9897e5dc3..8c943b615 100644
--- a/pkg/bits/BUILD
+++ b/pkg/bits/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance")
go_library(
diff --git a/pkg/bpf/BUILD b/pkg/bpf/BUILD
index d4f12f13a..403270049 100644
--- a/pkg/bpf/BUILD
+++ b/pkg/bpf/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "bpf_state",
diff --git a/pkg/compressio/BUILD b/pkg/compressio/BUILD
index 721b2d983..d70f982c1 100644
--- a/pkg/compressio/BUILD
+++ b/pkg/compressio/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "compressio",
diff --git a/pkg/control/client/BUILD b/pkg/control/client/BUILD
index 9e1c058e4..d58cd1b71 100644
--- a/pkg/control/client/BUILD
+++ b/pkg/control/client/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "client",
diff --git a/pkg/control/server/BUILD b/pkg/control/server/BUILD
index 2d0fdd8b8..c3f74a532 100644
--- a/pkg/control/server/BUILD
+++ b/pkg/control/server/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "server",
diff --git a/pkg/cpuid/BUILD b/pkg/cpuid/BUILD
index a503b7ae8..9a0ca1b33 100644
--- a/pkg/cpuid/BUILD
+++ b/pkg/cpuid/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "cpuid_state",
diff --git a/pkg/dhcp/BUILD b/pkg/dhcp/BUILD
index f56969ad8..bd9f592b4 100644
--- a/pkg/dhcp/BUILD
+++ b/pkg/dhcp/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "dhcp",
diff --git a/pkg/eventchannel/BUILD b/pkg/eventchannel/BUILD
index ea0c587be..ac2ea869d 100644
--- a/pkg/eventchannel/BUILD
+++ b/pkg/eventchannel/BUILD
@@ -1,7 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
+load("//tools/go_stateify:defs.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "eventchannel",
diff --git a/pkg/fd/BUILD b/pkg/fd/BUILD
index e69d83d06..435b6fa34 100644
--- a/pkg/fd/BUILD
+++ b/pkg/fd/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "fd",
diff --git a/pkg/gate/BUILD b/pkg/gate/BUILD
index 0b8b01da8..872eff531 100644
--- a/pkg/gate/BUILD
+++ b/pkg/gate/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "gate",
diff --git a/pkg/hashio/BUILD b/pkg/hashio/BUILD
index aaa58b58f..5736e2e73 100644
--- a/pkg/hashio/BUILD
+++ b/pkg/hashio/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "hashio",
diff --git a/pkg/ilist/BUILD b/pkg/ilist/BUILD
index 16a738e89..e32f26ffa 100644
--- a/pkg/ilist/BUILD
+++ b/pkg/ilist/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "list_state",
diff --git a/pkg/linewriter/BUILD b/pkg/linewriter/BUILD
index 4a96c6f1d..6c3795432 100644
--- a/pkg/linewriter/BUILD
+++ b/pkg/linewriter/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "linewriter",
diff --git a/pkg/log/BUILD b/pkg/log/BUILD
index 2530cfd18..fc9281079 100644
--- a/pkg/log/BUILD
+++ b/pkg/log/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "log",
diff --git a/pkg/metric/BUILD b/pkg/metric/BUILD
index e3f50d528..c0cd40c7b 100644
--- a/pkg/metric/BUILD
+++ b/pkg/metric/BUILD
@@ -1,7 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "metric",
diff --git a/pkg/p9/BUILD b/pkg/p9/BUILD
index f348ff2e9..1cf5c6458 100644
--- a/pkg/p9/BUILD
+++ b/pkg/p9/BUILD
@@ -1,4 +1,4 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
package(
default_visibility = ["//visibility:public"],
diff --git a/pkg/p9/p9test/BUILD b/pkg/p9/p9test/BUILD
index 339c86089..d6f428e11 100644
--- a/pkg/p9/p9test/BUILD
+++ b/pkg/p9/p9test/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_test(
name = "p9test_test",
diff --git a/pkg/rand/BUILD b/pkg/rand/BUILD
index 2bb59f895..12e6cf25a 100644
--- a/pkg/rand/BUILD
+++ b/pkg/rand/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "rand",
diff --git a/pkg/refs/BUILD b/pkg/refs/BUILD
index 4b7c9345d..3ea877ccf 100644
--- a/pkg/refs/BUILD
+++ b/pkg/refs/BUILD
@@ -1,32 +1,16 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
-
-go_stateify(
- name = "refs_state",
- srcs = [
- "refcounter.go",
- "refcounter_state.go",
- ],
- out = "refs_state.go",
- package = "refs",
-)
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "refs",
srcs = [
"refcounter.go",
"refcounter_state.go",
- "refs_state.go",
],
importpath = "gvisor.googlesource.com/gvisor/pkg/refs",
visibility = ["//:sandbox"],
- deps = [
- "//pkg/ilist",
- "//pkg/log",
- "//pkg/state",
- ],
+ deps = ["//pkg/ilist"],
)
go_test(
diff --git a/pkg/refs/refcounter.go b/pkg/refs/refcounter.go
index 3162001e1..0d44c2499 100644
--- a/pkg/refs/refcounter.go
+++ b/pkg/refs/refcounter.go
@@ -58,6 +58,8 @@ type WeakRefUser interface {
}
// WeakRef is a weak reference.
+//
+// +stateify savable
type WeakRef struct {
ilist.Entry `state:"nosave"`
@@ -177,6 +179,8 @@ func (w *WeakRef) zap() {
//
// N.B. To allow the zero-object to be initialized, the count is offset by
// 1, that is, when refCount is n, there are really n+1 references.
+//
+// +stateify savable
type AtomicRefCount struct {
// refCount is composed of two fields:
//
diff --git a/pkg/refs/refcounter_state.go b/pkg/refs/refcounter_state.go
index 1be67f951..093eae785 100644
--- a/pkg/refs/refcounter_state.go
+++ b/pkg/refs/refcounter_state.go
@@ -14,6 +14,7 @@
package refs
+// +stateify savable
type savedReference struct {
obj interface{}
}
diff --git a/pkg/seccomp/BUILD b/pkg/seccomp/BUILD
index cadd24505..b3e2f0b38 100644
--- a/pkg/seccomp/BUILD
+++ b/pkg/seccomp/BUILD
@@ -1,6 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_embed_data", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_embed_data")
go_binary(
name = "victim",
diff --git a/pkg/secio/BUILD b/pkg/secio/BUILD
index 9a28d2c1f..0ed38c64a 100644
--- a/pkg/secio/BUILD
+++ b/pkg/secio/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "secio",
diff --git a/pkg/segment/test/BUILD b/pkg/segment/test/BUILD
index 9d398d71a..bdf53e24e 100644
--- a/pkg/segment/test/BUILD
+++ b/pkg/segment/test/BUILD
@@ -1,4 +1,4 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
package(
default_visibility = ["//visibility:private"],
diff --git a/pkg/sentry/arch/BUILD b/pkg/sentry/arch/BUILD
index a88f57ac7..0a2a35400 100644
--- a/pkg/sentry/arch/BUILD
+++ b/pkg/sentry/arch/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "arch_state",
diff --git a/pkg/sentry/context/BUILD b/pkg/sentry/context/BUILD
index ff39f94ba..2a7a6df23 100644
--- a/pkg/sentry/context/BUILD
+++ b/pkg/sentry/context/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "context",
diff --git a/pkg/sentry/context/contexttest/BUILD b/pkg/sentry/context/contexttest/BUILD
index 5977344de..591b11a4d 100644
--- a/pkg/sentry/context/contexttest/BUILD
+++ b/pkg/sentry/context/contexttest/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "contexttest_state",
diff --git a/pkg/sentry/control/BUILD b/pkg/sentry/control/BUILD
index 6169891f7..fbdde0721 100644
--- a/pkg/sentry/control/BUILD
+++ b/pkg/sentry/control/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "control",
diff --git a/pkg/sentry/device/BUILD b/pkg/sentry/device/BUILD
index 1a8b461ba..69c99b0b3 100644
--- a/pkg/sentry/device/BUILD
+++ b/pkg/sentry/device/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "device",
diff --git a/pkg/sentry/fs/BUILD b/pkg/sentry/fs/BUILD
index 9b7264753..e3c9a9b70 100644
--- a/pkg/sentry/fs/BUILD
+++ b/pkg/sentry/fs/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "fs_state",
diff --git a/pkg/sentry/fs/anon/BUILD b/pkg/sentry/fs/anon/BUILD
index 6b18aee47..ff4ab850a 100644
--- a/pkg/sentry/fs/anon/BUILD
+++ b/pkg/sentry/fs/anon/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "anon",
diff --git a/pkg/sentry/fs/ashmem/BUILD b/pkg/sentry/fs/ashmem/BUILD
index e20e22a0f..9f166799a 100644
--- a/pkg/sentry/fs/ashmem/BUILD
+++ b/pkg/sentry/fs/ashmem/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
go_stateify(
diff --git a/pkg/sentry/fs/binder/BUILD b/pkg/sentry/fs/binder/BUILD
index 15f91699f..ec3928baf 100644
--- a/pkg/sentry/fs/binder/BUILD
+++ b/pkg/sentry/fs/binder/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "binder_state",
diff --git a/pkg/sentry/fs/dev/BUILD b/pkg/sentry/fs/dev/BUILD
index d33a19c2f..ea41615fd 100644
--- a/pkg/sentry/fs/dev/BUILD
+++ b/pkg/sentry/fs/dev/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "dev_state",
diff --git a/pkg/sentry/fs/fdpipe/BUILD b/pkg/sentry/fs/fdpipe/BUILD
index 9e1f65d3e..4fcb06f1f 100644
--- a/pkg/sentry/fs/fdpipe/BUILD
+++ b/pkg/sentry/fs/fdpipe/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "pipe_state",
diff --git a/pkg/sentry/fs/filetest/BUILD b/pkg/sentry/fs/filetest/BUILD
index 51a390d77..f481c57fb 100644
--- a/pkg/sentry/fs/filetest/BUILD
+++ b/pkg/sentry/fs/filetest/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "filetest_state",
diff --git a/pkg/sentry/fs/fsutil/BUILD b/pkg/sentry/fs/fsutil/BUILD
index 4fa6395f7..6eea64298 100644
--- a/pkg/sentry/fs/fsutil/BUILD
+++ b/pkg/sentry/fs/fsutil/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "fsutil_state",
diff --git a/pkg/sentry/fs/gofer/BUILD b/pkg/sentry/fs/gofer/BUILD
index e6f659c53..1277379e7 100644
--- a/pkg/sentry/fs/gofer/BUILD
+++ b/pkg/sentry/fs/gofer/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "gofer_state",
diff --git a/pkg/sentry/fs/host/BUILD b/pkg/sentry/fs/host/BUILD
index 97b64daed..23ec66f50 100644
--- a/pkg/sentry/fs/host/BUILD
+++ b/pkg/sentry/fs/host/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "host_state",
diff --git a/pkg/sentry/fs/lock/BUILD b/pkg/sentry/fs/lock/BUILD
index c15dde800..2607d7ed3 100644
--- a/pkg/sentry/fs/lock/BUILD
+++ b/pkg/sentry/fs/lock/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "lock_state",
diff --git a/pkg/sentry/fs/proc/BUILD b/pkg/sentry/fs/proc/BUILD
index 21b5fc0c3..870df47b2 100644
--- a/pkg/sentry/fs/proc/BUILD
+++ b/pkg/sentry/fs/proc/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "proc_state",
diff --git a/pkg/sentry/fs/proc/device/BUILD b/pkg/sentry/fs/proc/device/BUILD
index b62062bd7..34582f275 100644
--- a/pkg/sentry/fs/proc/device/BUILD
+++ b/pkg/sentry/fs/proc/device/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "device",
diff --git a/pkg/sentry/fs/proc/seqfile/BUILD b/pkg/sentry/fs/proc/seqfile/BUILD
index 48dd25e5b..c84f7e20d 100644
--- a/pkg/sentry/fs/proc/seqfile/BUILD
+++ b/pkg/sentry/fs/proc/seqfile/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "seqfile_state",
diff --git a/pkg/sentry/fs/ramfs/BUILD b/pkg/sentry/fs/ramfs/BUILD
index 663a1aeb9..d84f2c624 100644
--- a/pkg/sentry/fs/ramfs/BUILD
+++ b/pkg/sentry/fs/ramfs/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "ramfs_state",
diff --git a/pkg/sentry/fs/ramfs/test/BUILD b/pkg/sentry/fs/ramfs/test/BUILD
index 074b0f5ad..57fee45e2 100644
--- a/pkg/sentry/fs/ramfs/test/BUILD
+++ b/pkg/sentry/fs/ramfs/test/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "test_state",
diff --git a/pkg/sentry/fs/sys/BUILD b/pkg/sentry/fs/sys/BUILD
index 0ae2cbac8..095ff1f25 100644
--- a/pkg/sentry/fs/sys/BUILD
+++ b/pkg/sentry/fs/sys/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "sys_state",
diff --git a/pkg/sentry/fs/timerfd/BUILD b/pkg/sentry/fs/timerfd/BUILD
index 7fddc29f4..8b1b7872e 100644
--- a/pkg/sentry/fs/timerfd/BUILD
+++ b/pkg/sentry/fs/timerfd/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "timerfd_state",
diff --git a/pkg/sentry/fs/tmpfs/BUILD b/pkg/sentry/fs/tmpfs/BUILD
index be4e695d3..473ab4296 100644
--- a/pkg/sentry/fs/tmpfs/BUILD
+++ b/pkg/sentry/fs/tmpfs/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "tmpfs_state",
diff --git a/pkg/sentry/fs/tty/BUILD b/pkg/sentry/fs/tty/BUILD
index fce327dfe..363897b2c 100644
--- a/pkg/sentry/fs/tty/BUILD
+++ b/pkg/sentry/fs/tty/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "tty_state",
diff --git a/pkg/sentry/hostcpu/BUILD b/pkg/sentry/hostcpu/BUILD
index 9457618d8..f362d15c8 100644
--- a/pkg/sentry/hostcpu/BUILD
+++ b/pkg/sentry/hostcpu/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "hostcpu",
diff --git a/pkg/sentry/inet/BUILD b/pkg/sentry/inet/BUILD
index 1150ced57..eaf8f15b2 100644
--- a/pkg/sentry/inet/BUILD
+++ b/pkg/sentry/inet/BUILD
@@ -1,11 +1,9 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
package(
default_visibility = ["//:sandbox"],
licenses = ["notice"], # Apache 2.0
)
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "inet_state",
diff --git a/pkg/sentry/kernel/BUILD b/pkg/sentry/kernel/BUILD
index 07568b47c..c4a7dacb2 100644
--- a/pkg/sentry/kernel/BUILD
+++ b/pkg/sentry/kernel/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "kernel_state",
diff --git a/pkg/sentry/kernel/auth/BUILD b/pkg/sentry/kernel/auth/BUILD
index 7f0680b88..5b7b30557 100644
--- a/pkg/sentry/kernel/auth/BUILD
+++ b/pkg/sentry/kernel/auth/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "auth_state",
diff --git a/pkg/sentry/kernel/epoll/BUILD b/pkg/sentry/kernel/epoll/BUILD
index 04651d961..7d491efbc 100644
--- a/pkg/sentry/kernel/epoll/BUILD
+++ b/pkg/sentry/kernel/epoll/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "epoll_autogen_state",
diff --git a/pkg/sentry/kernel/eventfd/BUILD b/pkg/sentry/kernel/eventfd/BUILD
index 561ced852..7ec179bd8 100644
--- a/pkg/sentry/kernel/eventfd/BUILD
+++ b/pkg/sentry/kernel/eventfd/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "eventfd_state",
diff --git a/pkg/sentry/kernel/fasync/BUILD b/pkg/sentry/kernel/fasync/BUILD
index 8d06e1182..17749c0de 100644
--- a/pkg/sentry/kernel/fasync/BUILD
+++ b/pkg/sentry/kernel/fasync/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "fasync",
diff --git a/pkg/sentry/kernel/futex/BUILD b/pkg/sentry/kernel/futex/BUILD
index de9897c58..a97a43549 100644
--- a/pkg/sentry/kernel/futex/BUILD
+++ b/pkg/sentry/kernel/futex/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_template_instance(
name = "waiter_list",
diff --git a/pkg/sentry/kernel/kdefs/BUILD b/pkg/sentry/kernel/kdefs/BUILD
index b6c00042a..fe6fa2260 100644
--- a/pkg/sentry/kernel/kdefs/BUILD
+++ b/pkg/sentry/kernel/kdefs/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "kdefs",
diff --git a/pkg/sentry/kernel/memevent/BUILD b/pkg/sentry/kernel/memevent/BUILD
index c7779e1d5..66899910c 100644
--- a/pkg/sentry/kernel/memevent/BUILD
+++ b/pkg/sentry/kernel/memevent/BUILD
@@ -1,7 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
+load("//tools/go_stateify:defs.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "memevent",
diff --git a/pkg/sentry/kernel/pipe/BUILD b/pkg/sentry/kernel/pipe/BUILD
index ca9825f9d..4600d19bd 100644
--- a/pkg/sentry/kernel/pipe/BUILD
+++ b/pkg/sentry/kernel/pipe/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "pipe_state",
diff --git a/pkg/sentry/kernel/sched/BUILD b/pkg/sentry/kernel/sched/BUILD
index b533c51c4..125792f39 100644
--- a/pkg/sentry/kernel/sched/BUILD
+++ b/pkg/sentry/kernel/sched/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "sched",
diff --git a/pkg/sentry/kernel/semaphore/BUILD b/pkg/sentry/kernel/semaphore/BUILD
index 1656ad126..969145fe1 100644
--- a/pkg/sentry/kernel/semaphore/BUILD
+++ b/pkg/sentry/kernel/semaphore/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_template_instance(
name = "waiter_list",
diff --git a/pkg/sentry/kernel/shm/BUILD b/pkg/sentry/kernel/shm/BUILD
index 182cc1c76..0f88eb0ac 100644
--- a/pkg/sentry/kernel/shm/BUILD
+++ b/pkg/sentry/kernel/shm/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "shm_state",
diff --git a/pkg/sentry/kernel/time/BUILD b/pkg/sentry/kernel/time/BUILD
index 84f31b2dc..b3ed42aa4 100644
--- a/pkg/sentry/kernel/time/BUILD
+++ b/pkg/sentry/kernel/time/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "time_state",
diff --git a/pkg/sentry/limits/BUILD b/pkg/sentry/limits/BUILD
index 06c3e72b0..3ce41cacc 100644
--- a/pkg/sentry/limits/BUILD
+++ b/pkg/sentry/limits/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "limits_state",
diff --git a/pkg/sentry/loader/BUILD b/pkg/sentry/loader/BUILD
index 01a0ec426..e63052c6d 100644
--- a/pkg/sentry/loader/BUILD
+++ b/pkg/sentry/loader/BUILD
@@ -1,7 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_embed_data", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("@io_bazel_rules_go//go:def.bzl", "go_embed_data")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_embed_data(
name = "vdso_bin",
diff --git a/pkg/sentry/memmap/BUILD b/pkg/sentry/memmap/BUILD
index 7525fea45..2e367e189 100644
--- a/pkg/sentry/memmap/BUILD
+++ b/pkg/sentry/memmap/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "memmap_state",
diff --git a/pkg/sentry/memutil/BUILD b/pkg/sentry/memutil/BUILD
index a387a0c9f..341b30b98 100644
--- a/pkg/sentry/memutil/BUILD
+++ b/pkg/sentry/memutil/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "memutil",
diff --git a/pkg/sentry/mm/BUILD b/pkg/sentry/mm/BUILD
index 258389bb2..3f396986a 100644
--- a/pkg/sentry/mm/BUILD
+++ b/pkg/sentry/mm/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "mm_state",
diff --git a/pkg/sentry/platform/BUILD b/pkg/sentry/platform/BUILD
index d5be81f8d..15a7fbbc3 100644
--- a/pkg/sentry/platform/BUILD
+++ b/pkg/sentry/platform/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "platform_state",
diff --git a/pkg/sentry/platform/filemem/BUILD b/pkg/sentry/platform/filemem/BUILD
index 3c4d5b0b6..dadba1d38 100644
--- a/pkg/sentry/platform/filemem/BUILD
+++ b/pkg/sentry/platform/filemem/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "filemem_autogen_state",
diff --git a/pkg/sentry/platform/interrupt/BUILD b/pkg/sentry/platform/interrupt/BUILD
index 33dde2a31..35121321a 100644
--- a/pkg/sentry/platform/interrupt/BUILD
+++ b/pkg/sentry/platform/interrupt/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "interrupt",
diff --git a/pkg/sentry/platform/kvm/BUILD b/pkg/sentry/platform/kvm/BUILD
index 673393fad..4ef9e20d7 100644
--- a/pkg/sentry/platform/kvm/BUILD
+++ b/pkg/sentry/platform/kvm/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
go_template_instance(
diff --git a/pkg/sentry/platform/kvm/testutil/BUILD b/pkg/sentry/platform/kvm/testutil/BUILD
index 8533a8d89..e779e3893 100644
--- a/pkg/sentry/platform/kvm/testutil/BUILD
+++ b/pkg/sentry/platform/kvm/testutil/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "testutil",
diff --git a/pkg/sentry/platform/procid/BUILD b/pkg/sentry/platform/procid/BUILD
index 5db4f6261..ba68d48f4 100644
--- a/pkg/sentry/platform/procid/BUILD
+++ b/pkg/sentry/platform/procid/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "procid",
diff --git a/pkg/sentry/platform/ptrace/BUILD b/pkg/sentry/platform/ptrace/BUILD
index 16b0b3c69..ceee895dc 100644
--- a/pkg/sentry/platform/ptrace/BUILD
+++ b/pkg/sentry/platform/ptrace/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "ptrace",
diff --git a/pkg/sentry/platform/ring0/BUILD b/pkg/sentry/platform/ring0/BUILD
index 2df232a64..2485eb2eb 100644
--- a/pkg/sentry/platform/ring0/BUILD
+++ b/pkg/sentry/platform/ring0/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance")
go_template(
diff --git a/pkg/sentry/platform/ring0/pagetables/BUILD b/pkg/sentry/platform/ring0/pagetables/BUILD
index 023e298a0..7a86e2234 100644
--- a/pkg/sentry/platform/ring0/pagetables/BUILD
+++ b/pkg/sentry/platform/ring0/pagetables/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance")
go_template(
diff --git a/pkg/sentry/platform/safecopy/BUILD b/pkg/sentry/platform/safecopy/BUILD
index 8b9f29403..7dcf6e561 100644
--- a/pkg/sentry/platform/safecopy/BUILD
+++ b/pkg/sentry/platform/safecopy/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "safecopy",
diff --git a/pkg/sentry/safemem/BUILD b/pkg/sentry/safemem/BUILD
index dc4cfce41..e96509ce1 100644
--- a/pkg/sentry/safemem/BUILD
+++ b/pkg/sentry/safemem/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "safemem",
diff --git a/pkg/sentry/sighandling/BUILD b/pkg/sentry/sighandling/BUILD
index daaad7c90..f480f0735 100644
--- a/pkg/sentry/sighandling/BUILD
+++ b/pkg/sentry/sighandling/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "sighandling",
diff --git a/pkg/sentry/socket/BUILD b/pkg/sentry/socket/BUILD
index 5500a676e..929787aa0 100644
--- a/pkg/sentry/socket/BUILD
+++ b/pkg/sentry/socket/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "socket_state",
diff --git a/pkg/sentry/socket/control/BUILD b/pkg/sentry/socket/control/BUILD
index 25de2f655..faf2b4c27 100644
--- a/pkg/sentry/socket/control/BUILD
+++ b/pkg/sentry/socket/control/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "control_state",
diff --git a/pkg/sentry/socket/epsocket/BUILD b/pkg/sentry/socket/epsocket/BUILD
index 8430886cb..7ad5e88c5 100644
--- a/pkg/sentry/socket/epsocket/BUILD
+++ b/pkg/sentry/socket/epsocket/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "epsocket_state",
diff --git a/pkg/sentry/socket/hostinet/BUILD b/pkg/sentry/socket/hostinet/BUILD
index 60ec265ba..227ca3926 100644
--- a/pkg/sentry/socket/hostinet/BUILD
+++ b/pkg/sentry/socket/hostinet/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "hostinet_state",
diff --git a/pkg/sentry/socket/netlink/BUILD b/pkg/sentry/socket/netlink/BUILD
index 9df3ab17c..b23a243f7 100644
--- a/pkg/sentry/socket/netlink/BUILD
+++ b/pkg/sentry/socket/netlink/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "netlink_state",
diff --git a/pkg/sentry/socket/netlink/port/BUILD b/pkg/sentry/socket/netlink/port/BUILD
index 7340b95c9..ba6f686e4 100644
--- a/pkg/sentry/socket/netlink/port/BUILD
+++ b/pkg/sentry/socket/netlink/port/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "port_state",
diff --git a/pkg/sentry/socket/netlink/route/BUILD b/pkg/sentry/socket/netlink/route/BUILD
index ff3f7b7a4..726469fc9 100644
--- a/pkg/sentry/socket/netlink/route/BUILD
+++ b/pkg/sentry/socket/netlink/route/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "route_state",
diff --git a/pkg/sentry/socket/rpcinet/BUILD b/pkg/sentry/socket/rpcinet/BUILD
index 8973453f9..288199779 100644
--- a/pkg/sentry/socket/rpcinet/BUILD
+++ b/pkg/sentry/socket/rpcinet/BUILD
@@ -1,7 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
+load("//tools/go_stateify:defs.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "rpcinet",
diff --git a/pkg/sentry/socket/rpcinet/conn/BUILD b/pkg/sentry/socket/rpcinet/conn/BUILD
index 4923dee4b..c51ca14b1 100644
--- a/pkg/sentry/socket/rpcinet/conn/BUILD
+++ b/pkg/sentry/socket/rpcinet/conn/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # BSD
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "conn",
diff --git a/pkg/sentry/socket/rpcinet/notifier/BUILD b/pkg/sentry/socket/rpcinet/notifier/BUILD
index 6f3b06a05..2ae902b3f 100644
--- a/pkg/sentry/socket/rpcinet/notifier/BUILD
+++ b/pkg/sentry/socket/rpcinet/notifier/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # BSD
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "notifier",
diff --git a/pkg/sentry/socket/unix/BUILD b/pkg/sentry/socket/unix/BUILD
index 1ec6eb7ed..7d04d6b6b 100644
--- a/pkg/sentry/socket/unix/BUILD
+++ b/pkg/sentry/socket/unix/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "unix_state",
diff --git a/pkg/sentry/state/BUILD b/pkg/sentry/state/BUILD
index 9bd98f445..a57a8298e 100644
--- a/pkg/sentry/state/BUILD
+++ b/pkg/sentry/state/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "state",
diff --git a/pkg/sentry/strace/BUILD b/pkg/sentry/strace/BUILD
index c5946a564..e1c8db67a 100644
--- a/pkg/sentry/strace/BUILD
+++ b/pkg/sentry/strace/BUILD
@@ -1,7 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
+load("//tools/go_stateify:defs.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "strace",
diff --git a/pkg/sentry/syscalls/BUILD b/pkg/sentry/syscalls/BUILD
index d667b42c8..22a757095 100644
--- a/pkg/sentry/syscalls/BUILD
+++ b/pkg/sentry/syscalls/BUILD
@@ -1,7 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
+load("//tools/go_stateify:defs.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "syscalls",
diff --git a/pkg/sentry/syscalls/linux/BUILD b/pkg/sentry/syscalls/linux/BUILD
index d3f3cc459..574621ad2 100644
--- a/pkg/sentry/syscalls/linux/BUILD
+++ b/pkg/sentry/syscalls/linux/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "linux_state",
diff --git a/pkg/sentry/time/BUILD b/pkg/sentry/time/BUILD
index cbcd699d5..9452787fb 100644
--- a/pkg/sentry/time/BUILD
+++ b/pkg/sentry/time/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
go_template_instance(
diff --git a/pkg/sentry/uniqueid/BUILD b/pkg/sentry/uniqueid/BUILD
index c8ab03c3d..8eba3609e 100644
--- a/pkg/sentry/uniqueid/BUILD
+++ b/pkg/sentry/uniqueid/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "uniqueid",
diff --git a/pkg/sentry/usage/BUILD b/pkg/sentry/usage/BUILD
index a0fe0aa07..edee44d96 100644
--- a/pkg/sentry/usage/BUILD
+++ b/pkg/sentry/usage/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "usage_state",
diff --git a/pkg/sentry/usermem/BUILD b/pkg/sentry/usermem/BUILD
index 36c0760dd..9dd1cd2b5 100644
--- a/pkg/sentry/usermem/BUILD
+++ b/pkg/sentry/usermem/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "usermem_state",
diff --git a/pkg/sentry/watchdog/BUILD b/pkg/sentry/watchdog/BUILD
index 28fae4490..13bc33eb1 100644
--- a/pkg/sentry/watchdog/BUILD
+++ b/pkg/sentry/watchdog/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "watchdog",
diff --git a/pkg/sleep/BUILD b/pkg/sleep/BUILD
index f2b69b225..05e4ca540 100644
--- a/pkg/sleep/BUILD
+++ b/pkg/sleep/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "sleep",
diff --git a/pkg/state/BUILD b/pkg/state/BUILD
index bb6415d9b..012b0484e 100644
--- a/pkg/state/BUILD
+++ b/pkg/state/BUILD
@@ -1,7 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
go_template_instance(
diff --git a/pkg/state/statefile/BUILD b/pkg/state/statefile/BUILD
index df2c6a578..16abe1930 100644
--- a/pkg/state/statefile/BUILD
+++ b/pkg/state/statefile/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "statefile",
diff --git a/pkg/sync/BUILD b/pkg/sync/BUILD
index 1fc0c25b5..3959fea36 100644
--- a/pkg/sync/BUILD
+++ b/pkg/sync/BUILD
@@ -1,4 +1,4 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
package(
default_visibility = ["//:sandbox"],
diff --git a/pkg/sync/seqatomictest/BUILD b/pkg/sync/seqatomictest/BUILD
index 9d6ee2dfb..07b4f85ab 100644
--- a/pkg/sync/seqatomictest/BUILD
+++ b/pkg/sync/seqatomictest/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
go_template_instance(
diff --git a/pkg/syserr/BUILD b/pkg/syserr/BUILD
index e5ce48412..c0850f3d9 100644
--- a/pkg/syserr/BUILD
+++ b/pkg/syserr/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "syserr",
diff --git a/pkg/syserror/BUILD b/pkg/syserror/BUILD
index 68ddec786..e050c2043 100644
--- a/pkg/syserror/BUILD
+++ b/pkg/syserror/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "syserror",
diff --git a/pkg/tcpip/BUILD b/pkg/tcpip/BUILD
index 186a0d3bf..391d801d0 100644
--- a/pkg/tcpip/BUILD
+++ b/pkg/tcpip/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "tcpip_state",
diff --git a/pkg/tcpip/adapters/gonet/BUILD b/pkg/tcpip/adapters/gonet/BUILD
index 97da46776..bf618831a 100644
--- a/pkg/tcpip/adapters/gonet/BUILD
+++ b/pkg/tcpip/adapters/gonet/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "gonet",
diff --git a/pkg/tcpip/buffer/BUILD b/pkg/tcpip/buffer/BUILD
index 08adf18cd..efeb6a448 100644
--- a/pkg/tcpip/buffer/BUILD
+++ b/pkg/tcpip/buffer/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "buffer_state",
diff --git a/pkg/tcpip/checker/BUILD b/pkg/tcpip/checker/BUILD
index 5447cfbf4..e8a524918 100644
--- a/pkg/tcpip/checker/BUILD
+++ b/pkg/tcpip/checker/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "checker",
diff --git a/pkg/tcpip/header/BUILD b/pkg/tcpip/header/BUILD
index 859c2a106..3aa2cfb24 100644
--- a/pkg/tcpip/header/BUILD
+++ b/pkg/tcpip/header/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "tcp_header_state",
diff --git a/pkg/tcpip/link/channel/BUILD b/pkg/tcpip/link/channel/BUILD
index f2f0c8b6f..9a6f49c45 100644
--- a/pkg/tcpip/link/channel/BUILD
+++ b/pkg/tcpip/link/channel/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "channel",
diff --git a/pkg/tcpip/link/fdbased/BUILD b/pkg/tcpip/link/fdbased/BUILD
index aca3b14ca..6e75e9f47 100644
--- a/pkg/tcpip/link/fdbased/BUILD
+++ b/pkg/tcpip/link/fdbased/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "fdbased",
diff --git a/pkg/tcpip/link/loopback/BUILD b/pkg/tcpip/link/loopback/BUILD
index 9714e93db..cc4247ffd 100644
--- a/pkg/tcpip/link/loopback/BUILD
+++ b/pkg/tcpip/link/loopback/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "loopback",
diff --git a/pkg/tcpip/link/rawfile/BUILD b/pkg/tcpip/link/rawfile/BUILD
index 4b30c7c1c..10b35a37e 100644
--- a/pkg/tcpip/link/rawfile/BUILD
+++ b/pkg/tcpip/link/rawfile/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "rawfile",
diff --git a/pkg/tcpip/link/sharedmem/BUILD b/pkg/tcpip/link/sharedmem/BUILD
index 1bd79a3f4..5390257c5 100644
--- a/pkg/tcpip/link/sharedmem/BUILD
+++ b/pkg/tcpip/link/sharedmem/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "sharedmem",
diff --git a/pkg/tcpip/link/sharedmem/pipe/BUILD b/pkg/tcpip/link/sharedmem/pipe/BUILD
index e6c658071..ff798ae6f 100644
--- a/pkg/tcpip/link/sharedmem/pipe/BUILD
+++ b/pkg/tcpip/link/sharedmem/pipe/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "pipe",
diff --git a/pkg/tcpip/link/sharedmem/queue/BUILD b/pkg/tcpip/link/sharedmem/queue/BUILD
index 80cedade1..c4a7879c4 100644
--- a/pkg/tcpip/link/sharedmem/queue/BUILD
+++ b/pkg/tcpip/link/sharedmem/queue/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "queue",
diff --git a/pkg/tcpip/link/sniffer/BUILD b/pkg/tcpip/link/sniffer/BUILD
index d14f150d1..1e844f949 100644
--- a/pkg/tcpip/link/sniffer/BUILD
+++ b/pkg/tcpip/link/sniffer/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "sniffer",
diff --git a/pkg/tcpip/link/tun/BUILD b/pkg/tcpip/link/tun/BUILD
index 21da7d57e..a8bb03661 100644
--- a/pkg/tcpip/link/tun/BUILD
+++ b/pkg/tcpip/link/tun/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "tun",
diff --git a/pkg/tcpip/link/waitable/BUILD b/pkg/tcpip/link/waitable/BUILD
index 3b513383a..7582df32e 100644
--- a/pkg/tcpip/link/waitable/BUILD
+++ b/pkg/tcpip/link/waitable/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "waitable",
diff --git a/pkg/tcpip/network/BUILD b/pkg/tcpip/network/BUILD
index 963857f51..9a26b46c4 100644
--- a/pkg/tcpip/network/BUILD
+++ b/pkg/tcpip/network/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_test")
go_test(
name = "ip_test",
diff --git a/pkg/tcpip/network/arp/BUILD b/pkg/tcpip/network/arp/BUILD
index 689f66d6e..44f2b66e5 100644
--- a/pkg/tcpip/network/arp/BUILD
+++ b/pkg/tcpip/network/arp/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "arp",
diff --git a/pkg/tcpip/network/fragmentation/BUILD b/pkg/tcpip/network/fragmentation/BUILD
index a173f87fb..ac97ebe43 100644
--- a/pkg/tcpip/network/fragmentation/BUILD
+++ b/pkg/tcpip/network/fragmentation/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "fragmentation_state",
diff --git a/pkg/tcpip/network/hash/BUILD b/pkg/tcpip/network/hash/BUILD
index e1b5f26c4..1c22c52fc 100644
--- a/pkg/tcpip/network/hash/BUILD
+++ b/pkg/tcpip/network/hash/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "hash",
diff --git a/pkg/tcpip/network/ipv4/BUILD b/pkg/tcpip/network/ipv4/BUILD
index ae42b662f..19314e9bd 100644
--- a/pkg/tcpip/network/ipv4/BUILD
+++ b/pkg/tcpip/network/ipv4/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "ipv4",
diff --git a/pkg/tcpip/network/ipv6/BUILD b/pkg/tcpip/network/ipv6/BUILD
index d008ac7fb..1c3eccae0 100644
--- a/pkg/tcpip/network/ipv6/BUILD
+++ b/pkg/tcpip/network/ipv6/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "ipv6",
diff --git a/pkg/tcpip/ports/BUILD b/pkg/tcpip/ports/BUILD
index 710c283f7..3c3374275 100644
--- a/pkg/tcpip/ports/BUILD
+++ b/pkg/tcpip/ports/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "ports",
diff --git a/pkg/tcpip/seqnum/BUILD b/pkg/tcpip/seqnum/BUILD
index 6d28dbc3f..a75869dac 100644
--- a/pkg/tcpip/seqnum/BUILD
+++ b/pkg/tcpip/seqnum/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "seqnum_state",
diff --git a/pkg/tcpip/stack/BUILD b/pkg/tcpip/stack/BUILD
index 6d201d0a2..5e7355135 100644
--- a/pkg/tcpip/stack/BUILD
+++ b/pkg/tcpip/stack/BUILD
@@ -1,17 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
-
-go_stateify(
- name = "stack_state",
- srcs = [
- "registration.go",
- "stack.go",
- ],
- out = "stack_state.go",
- package = "stack",
-)
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "stack",
@@ -22,7 +11,6 @@ go_library(
"route.go",
"stack.go",
"stack_global_state.go",
- "stack_state.go",
"transport_demuxer.go",
],
importpath = "gvisor.googlesource.com/gvisor/pkg/tcpip/stack",
@@ -32,7 +20,6 @@ go_library(
deps = [
"//pkg/ilist",
"//pkg/sleep",
- "//pkg/state",
"//pkg/tcpip",
"//pkg/tcpip/buffer",
"//pkg/tcpip/header",
diff --git a/pkg/tcpip/stack/registration.go b/pkg/tcpip/stack/registration.go
index e9550a062..c66f925a8 100644
--- a/pkg/tcpip/stack/registration.go
+++ b/pkg/tcpip/stack/registration.go
@@ -31,6 +31,8 @@ type NetworkEndpointID struct {
}
// TransportEndpointID is the identifier of a transport layer protocol endpoint.
+//
+// +stateify savable
type TransportEndpointID struct {
// LocalPort is the local port associated with the endpoint.
LocalPort uint16
diff --git a/pkg/tcpip/transport/ping/BUILD b/pkg/tcpip/transport/ping/BUILD
index 1febbf7f5..28e3e1700 100644
--- a/pkg/tcpip/transport/ping/BUILD
+++ b/pkg/tcpip/transport/ping/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "ping_state",
diff --git a/pkg/tcpip/transport/queue/BUILD b/pkg/tcpip/transport/queue/BUILD
index 7e8ee1f66..fb878ad36 100644
--- a/pkg/tcpip/transport/queue/BUILD
+++ b/pkg/tcpip/transport/queue/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "queue_state",
diff --git a/pkg/tcpip/transport/tcp/BUILD b/pkg/tcpip/transport/tcp/BUILD
index 53623787d..6a7153e4d 100644
--- a/pkg/tcpip/transport/tcp/BUILD
+++ b/pkg/tcpip/transport/tcp/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "tcp_state",
diff --git a/pkg/tcpip/transport/tcp/testing/context/BUILD b/pkg/tcpip/transport/tcp/testing/context/BUILD
index 3caa38bcb..7a95594ef 100644
--- a/pkg/tcpip/transport/tcp/testing/context/BUILD
+++ b/pkg/tcpip/transport/tcp/testing/context/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "context",
diff --git a/pkg/tcpip/transport/tcpconntrack/BUILD b/pkg/tcpip/transport/tcpconntrack/BUILD
index 3d748528e..46da3e6f1 100644
--- a/pkg/tcpip/transport/tcpconntrack/BUILD
+++ b/pkg/tcpip/transport/tcpconntrack/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "tcpconntrack",
diff --git a/pkg/tcpip/transport/udp/BUILD b/pkg/tcpip/transport/udp/BUILD
index 4f7a47973..790dd55a3 100644
--- a/pkg/tcpip/transport/udp/BUILD
+++ b/pkg/tcpip/transport/udp/BUILD
@@ -1,8 +1,7 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/go_generics:defs.bzl", "go_template_instance")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "udp_state",
diff --git a/pkg/tcpip/transport/unix/BUILD b/pkg/tcpip/transport/unix/BUILD
index d58f06544..676f2cf92 100644
--- a/pkg/tcpip/transport/unix/BUILD
+++ b/pkg/tcpip/transport/unix/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify")
go_stateify(
name = "unix_state",
diff --git a/pkg/tmutex/BUILD b/pkg/tmutex/BUILD
index d9a2c5ae5..d18338fff 100644
--- a/pkg/tmutex/BUILD
+++ b/pkg/tmutex/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "tmutex",
diff --git a/pkg/unet/BUILD b/pkg/unet/BUILD
index e8e40315a..acdfd7cb6 100644
--- a/pkg/unet/BUILD
+++ b/pkg/unet/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "unet",
diff --git a/pkg/urpc/BUILD b/pkg/urpc/BUILD
index b29b25637..d32c57d1a 100644
--- a/pkg/urpc/BUILD
+++ b/pkg/urpc/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
go_library(
name = "urpc",
diff --git a/pkg/waiter/BUILD b/pkg/waiter/BUILD
index 032ec3237..8256acdb4 100644
--- a/pkg/waiter/BUILD
+++ b/pkg/waiter/BUILD
@@ -1,7 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
-load("//tools/go_stateify:defs.bzl", "go_stateify")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
go_stateify(
name = "waiter_state",
diff --git a/pkg/waiter/fdnotifier/BUILD b/pkg/waiter/fdnotifier/BUILD
index d5b5ee82d..4e582755d 100644
--- a/pkg/waiter/fdnotifier/BUILD
+++ b/pkg/waiter/fdnotifier/BUILD
@@ -1,6 +1,6 @@
package(licenses = ["notice"]) # Apache 2.0
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//tools/go_stateify:defs.bzl", "go_library")
go_library(
name = "fdnotifier",
diff --git a/tools/go_stateify/defs.bzl b/tools/go_stateify/defs.bzl
index 60a9895ff..2b2582b7a 100644
--- a/tools/go_stateify/defs.bzl
+++ b/tools/go_stateify/defs.bzl
@@ -22,6 +22,8 @@ go_library(
)
"""
+load("@io_bazel_rules_go//go:def.bzl", _go_library = "go_library", _go_test = "go_test")
+
def _go_stateify_impl(ctx):
"""Implementation for the stateify tool."""
output = ctx.outputs.out
@@ -33,6 +35,8 @@ def _go_stateify_impl(ctx):
args += ["-statepkg=%s" % ctx.attr._statepkg]
if ctx.attr.imports:
args += ["-imports=%s" % ",".join(ctx.attr.imports)]
+ if ctx.attr.explicit:
+ args += ["-explicit=true"]
args += ["--"]
for src in ctx.attr.srcs:
args += [f.path for f in src.files]
@@ -45,17 +49,15 @@ def _go_stateify_impl(ctx):
executable = ctx.executable._tool,
)
-"""
-Generates save and restore logic from a set of Go files.
-
-
-Args:
- name: the name of the rule.
- srcs: the input source files. These files should include all structs in the package that need to be saved.
- imports: an optional list of extra non-aliased, Go-style absolute import paths.
- out: the name of the generated file output. This must not conflict with any other files and must be added to the srcs of the relevant go_library.
- package: the package name for the input sources.
-"""
+# Generates save and restore logic from a set of Go files.
+#
+# Args:
+# name: the name of the rule.
+# srcs: the input source files. These files should include all structs in the package that need to be saved.
+# imports: an optional list of extra non-aliased, Go-style absolute import paths.
+# out: the name of the generated file output. This must not conflict with any other files and must be added to the srcs of the relevant go_library.
+# package: the package name for the input sources.
+# explicit: only generate for types explicitly annotated as savable.
go_stateify = rule(
implementation = _go_stateify_impl,
attrs = {
@@ -63,7 +65,41 @@ go_stateify = rule(
"imports": attr.string_list(mandatory = False),
"package": attr.string(mandatory = True),
"out": attr.output(mandatory = True),
+ "explicit": attr.bool(default = False),
"_tool": attr.label(executable = True, cfg = "host", default = Label("//tools/go_stateify:stateify")),
"_statepkg": attr.string(default = "gvisor.googlesource.com/gvisor/pkg/state"),
},
)
+
+def go_library(name, srcs, deps = [], imports = [], **kwargs):
+ """wraps the standard go_library and does stateification."""
+ if "encode_unsafe.go" not in srcs and (name + "_state_autogen.go") not in srcs:
+ # Only do stateification for non-state packages without manual autogen.
+ go_stateify(
+ name = name + "_state_autogen",
+ srcs = [src for src in srcs if src.endswith(".go")],
+ imports = imports,
+ package = name,
+ out = name + "_state_autogen.go",
+ explicit = True,
+ )
+ all_srcs = srcs + [name + "_state_autogen.go"]
+ if "//pkg/state" not in deps:
+ all_deps = deps + ["//pkg/state"]
+ else:
+ all_deps = deps
+ else:
+ all_deps = deps
+ all_srcs = srcs
+ _go_library(
+ name = name,
+ srcs = all_srcs,
+ deps = all_deps,
+ **kwargs
+ )
+
+def go_test(**kwargs):
+ """Wraps the standard go_test."""
+ _go_test(
+ **kwargs
+ )
diff --git a/tools/go_stateify/main.go b/tools/go_stateify/main.go
index 6c3583c62..231c6d80b 100644
--- a/tools/go_stateify/main.go
+++ b/tools/go_stateify/main.go
@@ -25,6 +25,7 @@ import (
"os"
"reflect"
"strings"
+ "sync"
)
var (
@@ -32,6 +33,7 @@ var (
imports = flag.String("imports", "", "extra imports for the output file")
output = flag.String("output", "", "output file")
statePkg = flag.String("statepkg", "", "state import package; defaults to empty")
+ explicit = flag.Bool("explicit", false, "only generate for types explicitly tagged '// +stateify savable'")
)
// resolveTypeName returns a qualified type name.
@@ -224,16 +226,24 @@ func main() {
// Emit the package name.
fmt.Fprint(outputFile, "// automatically generated by stateify.\n\n")
fmt.Fprintf(outputFile, "package %s\n\n", *pkg)
- fmt.Fprint(outputFile, "import (\n")
- if *statePkg != "" {
- fmt.Fprintf(outputFile, " \"%s\"\n", *statePkg)
- }
- if *imports != "" {
- for _, i := range strings.Split(*imports, ",") {
- fmt.Fprintf(outputFile, " \"%s\"\n", i)
- }
+
+ // Emit the imports lazily.
+ var once sync.Once
+ maybeEmitImports := func() {
+ once.Do(func() {
+ // Emit the imports.
+ fmt.Fprint(outputFile, "import (\n")
+ if *statePkg != "" {
+ fmt.Fprintf(outputFile, " \"%s\"\n", *statePkg)
+ }
+ if *imports != "" {
+ for _, i := range strings.Split(*imports, ",") {
+ fmt.Fprintf(outputFile, " \"%s\"\n", i)
+ }
+ }
+ fmt.Fprint(outputFile, ")\n\n")
+ })
}
- fmt.Fprint(outputFile, ")\n\n")
files := make([]*ast.File, 0, len(flag.Args()))
@@ -241,7 +251,7 @@ func main() {
for _, filename := range flag.Args() {
// Parse the file.
fset := token.NewFileSet()
- f, err := parser.ParseFile(fset, filename, nil, 0)
+ f, err := parser.ParseFile(fset, filename, nil, parser.ParseComments)
if err != nil {
// Not a valid input file?
fmt.Fprintf(os.Stderr, "Input %q can't be parsed: %v\n", filename, err)
@@ -308,6 +318,26 @@ func main() {
continue
}
+ if *explicit {
+ // In explicit mode, only generate code for
+ // types explicitly marked
+ // "// +stateify savable" in one of the
+ // proceeding comment lines.
+ if d.Doc == nil {
+ continue
+ }
+ savable := false
+ for _, l := range d.Doc.List {
+ if l.Text == "// +stateify savable" {
+ savable = true
+ break
+ }
+ }
+ if !savable {
+ continue
+ }
+ }
+
for _, gs := range d.Specs {
ts := gs.(*ast.TypeSpec)
switch ts.Type.(type) {
@@ -315,6 +345,8 @@ func main() {
// Don't register.
break
case *ast.StructType:
+ maybeEmitImports()
+
ss := ts.Type.(*ast.StructType)
// Define beforeSave if a definition was not found. This
@@ -360,6 +392,8 @@ func main() {
// Add to our registration.
emitRegister(ts.Name.Name)
case *ast.Ident, *ast.SelectorExpr, *ast.ArrayType:
+ maybeEmitImports()
+
_, val := resolveTypeName(ts.Name.Name, ts.Type)
// Dispatch directly.
@@ -377,10 +411,12 @@ func main() {
}
}
- // Emit the init() function.
- fmt.Fprintf(outputFile, "func init() {\n")
- for _, ic := range initCalls {
- fmt.Fprintf(outputFile, " %s\n", ic)
+ if len(initCalls) > 0 {
+ // Emit the init() function.
+ fmt.Fprintf(outputFile, "func init() {\n")
+ for _, ic := range initCalls {
+ fmt.Fprintf(outputFile, " %s\n", ic)
+ }
+ fmt.Fprintf(outputFile, "}\n")
}
- fmt.Fprintf(outputFile, "}\n")
}