[GLUTEN-12742][CORE] Fix protoc DEPENDS so incremental builds regenerate proto sources - #12744
Open
nielspardon wants to merge 1 commit into
Open
[GLUTEN-12742][CORE] Fix protoc DEPENDS so incremental builds regenerate proto sources#12744nielspardon wants to merge 1 commit into
nielspardon wants to merge 1 commit into
Conversation
…ate proto sources Both protoc `add_custom_command`s in cpp/core/CMakeLists.txt declared their dependency on a directory rather than on the `.proto` files, and the trailing slash passed to `get_filename_component(... DIRECTORY)` stripped a component, so the declared path ended up one to two levels above the inputs: SUBSTRAIT_PROTO_SRC_DIR .../resources/substrait/proto SUBSTRAIT_PROTO_DIR .../resources/substrait <-- declared dep files protoc reads .../resources/substrait/proto/substrait/*.proto Editing a `.proto` in place therefore changed no mtime in the build graph, and an incremental build silently skipped protoc and kept linking stale `*.pb.cc` / `*.pb.h`. This has been benign so far only because every `algebra.proto` change to date was additive or comment-only; it turns wrong as soon as a field is renumbered or removed, because the JVM then writes one tag while the native library probes another and protobuf shunts the bytes into unknown fields without raising anything. Depend on the globbed file lists instead, matching what the ClickHouse backend already does in cpp-ch/local-engine/proto/CMakeLists.txt. The `get_filename_component` calls become dead and are dropped. Also add `CONFIGURE_DEPENDS` to both globs so that adding or deleting a `.proto` re-runs CMake instead of requiring a manual re-configure. `dev/builddeps-veloxbe.sh` does `rm -rf build`, so CI and the official build script were unaffected; this only bit local incremental builds, IDE builds, and any workflow reusing cpp/build. Fixes apache#12742
nielspardon
marked this pull request as ready for review
August 11, 2026 06:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Fixes #12742.
Both protoc
add_custom_commands incpp/core/CMakeLists.txtdeclared their dependency on a directory rather than on the.protofiles — and on the wrong directory. The trailing slash passed toget_filename_component(... DIRECTORY)strips the last component, so the declared dependency landed one to two levels above the actual inputs:SUBSTRAIT_PROTO_SRC_DIR.../resources/substrait/protoSUBSTRAIT_PROTO_DIR(declared dependency).../resources/substrait.../resources/substrait/proto/substrait/*.protoEditing a
.protoin place therefore changed no mtime that the build graph was watching, so an incremental native build silently skipped protoc and kept linking stale*.pb.cc/*.pb.h. The Gluten protos had the identical bug (GLUTEN_PROTO_DIRresolved to.../org/apache/glutenwhile the protos live in.../org/apache/gluten/proto/).This has gone unnoticed because every
algebra.protochange so far has been additive or comment-only, which makes a stale descriptor benign. It stops being benign as soon as a field is renumbered or removed: the JVM emits at the new tag while the native library probes the old one, and since protobuf shunts the mismatched bytes into unknown fields, nothing is raised — no exception, no fallback to vanilla Spark, just silently wrong behaviour. See the issue for the concrete case that surfaced this (aWriteRel.bucket_specrenumbering producing unbucketed files for a table the metastore records asCLUSTERED BY).dev/builddeps-veloxbe.shdoesrm -rf build, so CI and the official build script always do a clean generation — which is precisely why this survived. It only bites local incremental builds, IDE builds, and any workflow that reusescpp/build.Changes
DEPENDS ${SUBSTRAIT_PROTO_DIR}→DEPENDS ${SUBSTRAIT_PROTO_FILES}DEPENDS ${GLUTEN_PROTO_DIR}→DEPENDS ${GLUTEN_PROTO_FILES}get_filename_componentcalls, which are now deadCONFIGURE_DEPENDSto bothfile(GLOB ...)calls, so adding or deleting a.protore-runs CMake instead of requiring a manual re-configureThe globbed file lists were already computed a few lines above each command; depending on them matches what the ClickHouse backend already does —
cpp-ch/local-engine/proto/CMakeLists.txt:33usesDEPENDS ${protobuf_files}.CONFIGURE_DEPENDSneeds CMake 3.12+;cpp/core/CMakeLists.txtrequires 3.16, andcpp-chalready uses it.How was this patch tested?
cpp/corecannot be configured standalone (it needs Velox/Arrow andGLUTEN_HOME), so the proto sections were extracted verbatim into a minimal Ninja project pointed at the real proto trees, and built both before and after the change:build.ninja.../resources/substrait(a directory).protofilestouch algebra.proto→ buildninja: no work to doRunning Substrait PROTO compilertouch config.proto→ buildninja: no work to doRunning Gluten PROTO compiler.proto→ buildGLOB mismatch!→ re-configure → generated.proto→ buildGLOB mismatch!→ re-configureno work to dono work to do(no spurious re-runs)The "before" harness reproduces the issue's repro exactly. Regeneration of
algebra.pb.ccafter the fix was additionally confirmed by mtime.python3 dev/check.py format main --fixreports no formatting changes.No functional code changes, so no new unit test is applicable — this is a build-graph correctness fix.
This PR was prepared with the assistance of AI.