Skip to content

[c++] avrogencpp: emit deterministic include guard#400

Merged
travisdowns merged 2 commits into
release-1.12.0-redpandafrom
td-stable-avrogen-include-guard-1.12
May 15, 2026
Merged

[c++] avrogencpp: emit deterministic include guard#400
travisdowns merged 2 commits into
release-1.12.0-redpandafrom
td-stable-avrogen-include-guard-1.12

Conversation

@travisdowns
Copy link
Copy Markdown
Member

@travisdowns travisdowns commented May 15, 2026

#399 was accidentally opened against `master` — this is the same PR retargeted against `release-1.12.0-redpanda`.

Patch content is unchanged from #399.

travisdowns and others added 2 commits May 15, 2026 12:32
CodeGen::guard() in avrogencpp.cc was suffixing the generated header's
include guard with the output of boost::mt19937 seeded from
::time(nullptr). That produced a different guard on every avrogen
invocation, e.g.:

  #ifndef FOO_AVROGEN_H_3350718792_H
  #ifndef FOO_AVROGEN_H_2362587291_H

Two consequences:

1. Generated headers were non-deterministic. Repeated runs on the same
   schema produced different bytes.

2. Build systems that key their cache on input-content digests
   (e.g. Bazel's remote cache, the Nix store) saw every consumer of the
   generated header miss the cache on every build, even when the schema
   was byte-identical. In a hermetic two-output-base Bazel build of
   Redpanda this surfaced as a chain of cascade rebuilds starting at
   manifest_file.avrogen.h and propagating through every .cc that
   included it.

headerFile_ is already guaranteed-unique per output. The random suffix
doesn't add uniqueness, only entropy. Mirrors the same change being
proposed upstream at apache/avro.
@travisdowns
Copy link
Copy Markdown
Member Author

RP crew any objection if we just delete master branch from our fork? Having a stale copy of upstream master usually serves no purpose I think.

@dotnwat
Copy link
Copy Markdown
Member

dotnwat commented May 15, 2026

RP crew any objection if we just delete master branch from our fork? Having a stale copy of upstream master usually serves no purpose I think.

either delete it, or make our fork the default. either one works!

@travisdowns
Copy link
Copy Markdown
Member Author

or make our fork the default. either one works!

I planned to do the latter regardless (will now).

@travisdowns travisdowns merged commit 6821e2b into release-1.12.0-redpanda May 15, 2026
1 check passed
@travisdowns travisdowns deleted the td-stable-avrogen-include-guard-1.12 branch May 15, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants