Skip to content

bazel: log spam from metamorphic constants during code generations #76363

@stevendanna

Description

@stevendanna

We have code generators that pull in go packages that have metamorphic constants. For example, execgen and roachpb/gen both pull in tracing:

> go list -f '{{ join .Deps "\n" }}' ./pkg/sql/colexec/execgen/ | grep tracing | head -1
github.com/cockroachdb/cockroach/pkg/util/tracing
> go list -f '{{ join .Deps "\n" }}' ./pkg/roachpb/gen | grep tracing | head -1
github.com/cockroachdb/cockroach/pkg/util/tracing

which defines a metamorphic constant. When these packages are built with the crdb_test tag, there is a chance that on invocation they will initialize these metamorphic constants to random values and will print log message such as:

initialized metamorphic constant "span-reuse-rate" with value 10

As far as I know, this problem doesn't happen with the Make-based build because we do not set any tags when building utility binaries:

$(GO_INSTALL) -ldflags '$(LINKFLAGS)' -v $(if $($*-package),$($*-package),./pkg/cmd/$*)

In #76309 we took care of one of the larger offenders here by setting an environment variable that disables metamorphic constants at runtime. It would be nice to do this for all generators or find a way to build those generators without the crdb_test tag set to avoid this log output.

Epic CRDB-8036

Jira issue: CRDB-13084

Metadata

Metadata

Assignees

Labels

A-build-systemC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-dev-inf

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions