72 Commits
Author SHA1 Message Date
Andrei Vagin f010ae01ac Fix a few typos 2025-01-29 21:16:51 -08:00
Nevena KotlajaandgVisor bot 676b9db40f Remove implicit dependencies of _allowlist_function_transition in third_party
Rules are not required to have an implicit dependencies on the transition allowlist since Bazel knows where the file is.

PiperOrigin-RevId: 693260553
2024-11-05 02:04:19 -08:00
gVisor bot 7bcc2b0167 Internal change.
PiperOrigin-RevId: 659870484
2024-08-06 02:28:50 -07:00
Luke SandbergandgVisor bot 6c1bd9c689 Automated Code Change
PiperOrigin-RevId: 610097546
2024-02-24 20:49:26 -08:00
Nevena KotlajaandgVisor bot 2ba23f3ae4 Migrate Automatic Exec Groups by adding a toolchain parameter to the affected actions
This is a step forward for the full migration of Automatic Exec Groups (AEGs). This change will be effective once AEGs are enabled.

In this CL I've added a toolchain_type to `toolchain` attribute of ctx.actions.{run, run_shell} since the Execution platform is selected on a toolchain type level, not on a rule level like before AEGs.

PiperOrigin-RevId: 560782417
2023-08-28 12:14:35 -07:00
Jamie LiuandgVisor bot 16dc811cb7 Fix expected import path for Go cmd/vendor packages.
PiperOrigin-RevId: 557273882
2023-08-15 15:44:34 -07:00
Michael PrattandgVisor bot f3e4a1fc3b Remove last remaining !go1.22 build tag
The last remaining !go1.22 build is protecting the definition of
pkg/sync.maptype, which is a copy of runtime.maptype. We need to ensure these
definitions match so we can safely access the hasher field.

At its core, this CL achieves this check by ensuring that
unsafe.Offsetof(maptype{}.Hasher) matches the offset in the runtime version of
the type.

Several things happen along the way to achieve this:

* As of May 2023, runtime.maptype is actually a type alias for
internal/abi.MapType. checkoffset was failing to record the offsets because it
skipped type aliases for no good reason. Simply removing the type alias check
is sufficient to make type aliases work. (This part of the CL is technically
unnecessary because this CL ultimately references internal/abi.MapType
directly in anticipation of removal of the type alias. But there is no reason
not to allow type aliases).

* The checkconst / checkoffset regexp unintentionally does not allow / in
package paths, even though the rest of the package supports /. Fix this.

* checkconst was comparing the literal AST expression string against the
runtime value (i.e., "unsafe.Offsetof(maptype{}.Hasher)" vs "72", which fails
comparison. Switch to getting the resolved constant value from the type
checker.

* nogo/check.importer only loads package facts on direct import (stored in
importer.cache). If a package is not directly imported ImportPackageFact will
not find the facts. Typically packages need to ensure they directly depend on
packages they want facts from (e.g., pkg/sync has a dummy import of runtime in
runtime.go). This doesn't work for internal/abi because we cannot directly
import an internal package. Work around this as a hack by unconditionally
"importing" internal/abi when analyzing any package.

With regard to the last point, not that the nogo/defs.bzl nogo integration only
provides facts from the direct dependencies and the entire stdlib (since the
stdlib is analyzed as one bundle). So this trick only works for a stdlib
package. A bazel package indirect dependency would be missing facts altogether.

PiperOrigin-RevId: 549999084
2023-07-21 11:22:36 -07:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Adin ScannellandgVisor bot 733b1cd0bb Remove //tools/nogo:full flag.
With the latest nogo change, facts are no longer in the build paths. Since full
is only used to speed these paths (and is enabled for full analysis) the full
flag is now redundant and can be removed safely.

PiperOrigin-RevId: 511935530
2023-02-23 18:08:37 -08:00
Adin ScannellandgVisor bot bd561fd3f9 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
2023-02-23 13:17:49 -08:00
Adin ScannellandgVisor bot 2f9fabe0ac Add GOOS and GOARCH to nogo findings.
PiperOrigin-RevId: 511689371
2023-02-22 22:14:13 -08:00
Adin ScannellandgVisor bot 05d60444e0 Silence excessive nogo noise.
PiperOrigin-RevId: 511679657
2023-02-22 21:19:17 -08:00
Adin ScannellandgVisor bot c34a085729 Add assembly analysis to nogo.
This temporarily disables many asmdecl checks to minimize concurrent code
changes; these will be fixed separately.

PiperOrigin-RevId: 511619271
2023-02-22 15:57:50 -08:00
Adin ScannellandgVisor bot 6a4908b262 Process nogo targets across all architectures.
PiperOrigin-RevId: 511343590
2023-02-21 17:06:02 -08:00
Adin ScannellandgVisor bot c829d82a8f Update checklinkname to avoid hard-coded names.
PiperOrigin-RevId: 510524474
2023-02-17 14:40:10 -08:00
Michael PrattandgVisor bot 845fb007de Add constants to package-level fact
Unexported constants can end up unaddressable in objectpath and thus their
object facts get lost on fact import. Work around this by adding a
package-level fact which is a map of all constants to their value.

Remove the Value facts because it is confusing to have two ways to access the
same thing (especially when one only works sometimes).

PiperOrigin-RevId: 505153453
2023-01-27 10:38:13 -08:00
Michael PrattandgVisor bot 0c38f72156 Move procid to dynamic facts render
Based on cl/504066914, this generates the proper procid offsets at build time.

Package facts needs an update to properly skip underscore imports, which don't
have facts for some reason (because they are unnamed?).

Drop use of runtime.getprocid given that these generated code is pretty solid.

PiperOrigin-RevId: 504926257
2023-01-26 13:27:57 -08:00
Michael PrattandgVisor bot 2e68fa3c15 Enable analysis of packages using type parameters
Upstream analyzers support type parameters now, so we no longer need to skip
analysis.

PiperOrigin-RevId: 504383378
2023-01-24 14:56:58 -08:00
Adin ScannellandgVisor bot 12a930a63e Move goid to dynamic facts render.
This removes the need for ongoing tags.

This change requires some minor updates to remove dependency cycles, since
the goid package is a base library used by many internals (log, sync, etc.).

PiperOrigin-RevId: 504066914
2023-01-23 13:29:37 -08:00
Liam Miller-CushonandgVisor bot 413330510c Internal change.
PiperOrigin-RevId: 488486099
2022-11-14 15:35:21 -08:00
Kevin KrakauerandgVisor bot d8aa09e04c convert uses of interface{} to any
Done via:
  find . -name "*.go" | xargs sed -i -E 's/interface\{\}/any/g'

PiperOrigin-RevId: 487033228
2022-11-08 13:14:06 -08:00
Ayush RanjanandgVisor bot bda5ce7977 Simplify codebase.
Ran gofmt -w -s ./

PiperOrigin-RevId: 449415155
2022-05-18 00:56:31 -07:00
Kevin KrakauerandgVisor bot 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
Andrei VaginandgVisor bot be49295381 make: set --//tools/nogo:fast by default
nogo:fast is converted to nogo:full with the opposite meaning.
All nogo tests have to be always executed with this option.

Analyzing Go Standard Library takes about 10 minutes on buildkite,
but it is required only to run nogo tests.

PiperOrigin-RevId: 438343203
2022-03-30 10:53:28 -07:00
Michael PrattandgVisor bot 34623f4d75 Skip analysis of sync/atomic
https://go.dev/issue/50860 is adding Pointer[T] to sync/atomic,
which will trip up analyzers that don't handle generics. Skip
it for now.

Drop constraints, maps, slices, as they were dropped from the
standard library.

PiperOrigin-RevId: 437808952
2022-03-28 11:25:37 -07:00