Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def data_dependency():
patches = [
"//bazel/thirdparty:avro-snappy-includes.patch",
"//bazel/thirdparty:avro-fmt-const.patch",
"//bazel/thirdparty:avrogen-stable-include-guard.patch",
],
patch_args = ["-p1"],
)
Expand Down
28 changes: 28 additions & 0 deletions bazel/thirdparty/avrogen-stable-include-guard.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From: Travis Downs <travis.downs@redpanda.com>
Subject: [PATCH] avrogencpp: use deterministic include guard

The generated header's include guard was suffixed with the output of a
`boost::mt19937` seeded from `::time(nullptr)`, which produced a different
guard on every avrogen invocation. That made every consumer of the generated
header (e.g. `manifest_list_avro.cc`) see a different input digest on each
build, breaking Bazel's remote cache for the entire dependency chain even
on byte-identical schemas.

`headerFile_` is already a unique-per-output path; `makeCanonical(h, true)`
canonicalizes it into a valid identifier ending in `_H` (from the `.h`
extension). Dropping the random number leaves a stable, still-unique guard.

Tracks CORE-16317.

diff --git a/lang/c++/impl/avrogencpp.cc b/lang/c++/impl/avrogencpp.cc
--- a/lang/c++/impl/avrogencpp.cc
+++ b/lang/c++/impl/avrogencpp.cc
@@ -793,7 +793,7 @@
string CodeGen::guard() {
string h = headerFile_;
makeCanonical(h, true);
- return h + "_" + lexical_cast<string>(random_()) + "_H";
+ return h + "_H";
}

void CodeGen::generate(const ValidSchema &schema) {
Loading