Skip to content

Commit 3404a81

Browse files
committed
W25 §5.1 dual-include compile check
Per W25 spec §5.1 falsification: verify the dual-typedef collision is fully resolved post-Step-A by including BOTH hir_c_api.h AND hir_basic_block_c.h in a single TU. If this file fails to compile, the canonicalization is incomplete. Python/jit/hir/w25_dual_include_check.c: Includes both canonical headers + uses both API call (hir_block_id) AND direct struct-field access (bb->id) to exercise the full dual-include surface. The function never executes at runtime — its existence + successful compilation is the test. NAMING NOTE: file is named w25_dual_include_check.c (not test_*) to avoid the JIT_SOURCES test_* exclude regex at jit_build/CMakeLists.txt :131. This way the dual-include check runs at every build, not as a separate gated test artifact. Per spec §5.1 'Add to the build as a test-only TU' — file-naming approach achieves the same goal without requiring a CMakeLists.txt amendment. Empirical pre-test: Pre-W25 (hir_c_api.h void* typedefs): would fail with 'redefinition of typedef HirBasicBlock with different type' Post-W25 Step A (forward struct decls): compiles cleanly because forward decl + full def coexist; no typedef collision. Spec §5.2 (lint gate active) deferred to Step C. Spec §5.3 (signature-drift mutation reproducer) deferred to pre-Step-B falsification baseline (per generalist commitment chat L2065). Authorization chain: - W25 spec §5.1: theologian L2017 - Supervisor sequencing (5.1 next after Step A): chat L2099 - Push 65 W25 Step A landed: e6a8a2d chat L2102
1 parent 40dd82e commit 3404a81

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* Copyright (c) Meta Platforms, Inc. and affiliates.
2+
*
3+
* W25 §5.1 dual-include compile check.
4+
*
5+
* Per W25 spec docs/w25-hbb-canonicalization.md §5.1: this TU includes
6+
* BOTH hir_c_api.h AND hir_basic_block_c.h to verify the dual-typedef
7+
* collision that blocked W25 Step B is fully resolved post-Step-A
8+
* (commit e6a8a2d0fb).
9+
*
10+
* Pre-W25: hir_c_api.h had `typedef void* HirBasicBlock` while
11+
* hir_basic_block_c.h had `typedef struct HirBasicBlock {...} HirBasicBlock`.
12+
* A single TU including both would fail with redefinition of HirBasicBlock
13+
* to a different type.
14+
*
15+
* Post-W25 Step A: hir_c_api.h forward-declares `struct HirBasicBlock`
16+
* and `struct HirCFG` instead. hir_basic_block_c.h's full struct definitions
17+
* satisfy the forward decls. Both headers coexist without conflict.
18+
*
19+
* If this file FAILS to compile, the W25 canonicalization is incomplete —
20+
* the typedef collision regression has been reintroduced. Step C lint gate
21+
* (when shipped) will catch the related class of regressions (local extern
22+
* decls of API functions).
23+
*
24+
* Naming note: file is named `w25_dual_include_check.c` (not test_*) to
25+
* avoid the JIT_SOURCES test_* exclude filter at jit_build/CMakeLists.txt:131.
26+
* This way the dual-include check runs at every build, not as a separate
27+
* gated test artifact.
28+
*/
29+
30+
#include "cinderx/Jit/hir/hir_c_api.h"
31+
#include "cinderx/Jit/hir/hir_basic_block_c.h"
32+
33+
/* Reference both API and struct-field access. The function never gets
34+
* called at runtime — its existence is the test. The compiler must
35+
* accept both hir_block_id (declared in hir_c_api.h with struct ptr
36+
* signature) AND direct struct-field access via hir_basic_block_c.h's
37+
* full layout. */
38+
int w25_dual_include_check(struct HirBasicBlock *bb) {
39+
if (bb == NULL) {
40+
return -1;
41+
}
42+
/* API call: hir_block_id signature is `int hir_block_id(struct HirBasicBlock *)` */
43+
int api_id = hir_block_id(bb);
44+
/* Direct struct field access: hir_basic_block_c.h's full layout exposes id_ */
45+
int direct_id = bb->id;
46+
/* Both should agree (runtime invariant — but the test is compile-time only). */
47+
return (api_id == direct_id) ? 0 : 1;
48+
}

0 commit comments

Comments
 (0)