gvisor/tools/nogo
Kevin Krakauer 370672e989 prohibit direct use of sync/atomic (u)int64 functions
All atomic 64 bit ints are changed to atomicbitops.(Ui|I)nt64. A nogo checker
enforces that sync/atomic 64 bit functions are not called.

For reviewers: the interesting changes are in the atomicbitops and checkaligned
packages.

Why do this?
- It is very easy to accidentally use atomic values without sync/atomic funcs.
- We have checkatomics, but this is optional and is forgotten in several places.
  - Using a type+checker to enforce this seems less error prone and simpler.
- We get NoCopy protection.
- Use of 64 bit atomics can break 32 bit builds. We have types to handle this
  without any runtime cost, so we might as well use them.

PiperOrigin-RevId: 440473398
2022-04-08 16:06:26 -07:00
..
check prohibit direct use of sync/atomic (u)int64 functions 2022-04-08 16:06:26 -07:00
cli Ensure that nogo is enabled. 2022-02-03 23:45:40 -08:00
config Ensure that nogo is enabled. 2022-02-03 23:45:40 -08:00
facts Ensure that nogo is enabled. 2022-02-03 23:45:40 -08:00
flags Ensure that nogo is enabled. 2022-02-03 23:45:40 -08:00
sanity Ensure that nogo is enabled. 2022-02-03 23:45:40 -08:00
BUILD make: set --//tools/nogo:fast by default 2022-03-30 10:53:28 -07:00
README.md Add internal nogo analysis & checkescape tool. 2020-04-20 20:58:20 -07:00
defs.bzl make: set --//tools/nogo:fast by default 2022-03-30 10:53:28 -07:00
main.go Refactor nogo and provide facts render. 2022-01-19 10:26:27 -08:00

README.md

Extended "nogo" analysis

This package provides a build aspect that perform nogo analysis. This will be automatically injected to all relevant libraries when using the default go_binary and go_library rules.

It exists for several reasons.

  • The default nogo provided by bazel is insufficient with respect to the possibility of binary analysis. This package allows us to analyze the generated binary in addition to using the standard analyzers.

  • The configuration provided in this package is much richer than the standard nogo JSON blob. Specifically, it allows us to exclude specific structures from the composite rules (such as the Ranges that are common with the set types).

  • The bazel version of nogo is run directly against the go_library and go_binary targets, meaning that any change to the configuration requires a rebuild from scratch (for some reason included all C++ source files in the process). Using an aspect is more efficient in this regard.

  • The checks supported by this package are exported as tests, which makes it easier to reason about and plumb into the build system.

  • For uninteresting reasons, it is impossible to integrate the default nogo analyzer provided by bazel with internal Google tooling. To provide a consistent experience, this package allows those systems to be unified.

To use this package, import nogo_test from defs.bzl and add a single dependency which is a go_binary or go_library rule.