fix(build): close capnp codegen race for controller/worker/scheduler too (bug-1798)

The previous fix (654c6e8c) only closed the missing-dependency-edge race
inside the libxce target itself. A live user report on a second
from-scratch `./tools/xce-build.sh all debug` run showed the same race
still hitting scheduler/src/sim_record.c and core_events.c, which reach
controller.capnp.h directly via a raw -Ilib include path with no
declared dependency on the codegen step at all.

Root cause: libxce_dep = declare_dependency(link_with: libxce) -- the
dependency object controller/worker/scheduler all consume uniformly --
only orders a consumer's LINK step after libxce is built; it never
propagated a build-order dependency on the capnp custom_target to a
consumer's own COMPILE steps.

Fix: add `sources: [gen_srcs]` to libxce_dep's declare_dependency() call.
This kwarg exists specifically for generated files that must be built
before any consumer of a dependency compiles, and since every component
already lists libxce_dep in its own dependencies, this one change
propagates the missing edge everywhere with no per-component changes.

Verified: two consecutive full from-scratch `./tools/xce-build.sh all
debug` builds (1173/1173 targets, the user's own exact repro command)
both succeeded with no retry; a subsequent incremental controller/ASAN
rebuild stayed clean (1331/1331 tests, 0 ASAN diagnostics).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jaMf9QEwpugH2W9KAuc7f
This commit is contained in:
Rongsong Shen 2026-09-10 07:31:06 +00:00
parent 654c6e8c75
commit c1c6c9a248
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
2 changed files with 14 additions and 4 deletions

View file

@ -151,7 +151,17 @@ libxce = static_library('xce',
install: true)
libxce_dep = declare_dependency(link_with: libxce)
# bug-1798: `sources: [gen_srcs]` forces every consumer of libxce_dep
# (controller/worker/scheduler, none of which otherwise declare any
# dependency on this codegen step even though several of their own .c
# files #include "controller.capnp.h" directly via a raw -Ilib path) to
# build gen_srcs' outputs before compiling their own sources -- closing
# the same missing-dependency-edge race as the libxce_src fix above, but
# for consumers OUTSIDE the libxce target itself. link_with alone does not
# propagate this: it only orders the LINK step after libxce is built, not
# a consumer's own COMPILE steps against a header libxce never installs.
libxce_dep = declare_dependency(link_with: libxce, sources: [gen_srcs])
# libxce_shared_dep = declare_dependency(link_with: libxce_shared)
libxce_test_src = ['testsuite/test.c',