Visitar URL original
compiler: fix RC_ORACLE block — extern "C" only at namespace scope · SonicField/cpython@f2e5bfe · GitHub
Skip to content

Commit f2e5bfe

Browse files
committed
compiler: fix RC_ORACLE block — extern "C" only at namespace scope
Bug surfaced during Step 5 execution at HEAD 9cbf413: /data/users/alexturner/phoenix/cpython/Python/jit/compiler.cpp:136:10: error: expected unqualified-id ...:138:5: error: use of undeclared identifier 'rc_oracle_run' Root cause: my push 44 W3 dispatcher (a99db92 Step 3.5, also in 6450421c93 amended → a99db92) declared `extern "C" int rc_oracle_run(...)` inside the function body. C++17 [dcl.link] forbids linkage-specifications in block scope — they may only appear at namespace scope. Production builds (RC_ORACLE undefined) MASKED the bug because the entire #ifdef block is absent; the linkage-specification only enters the parser when RC_ORACLE is defined. push 44 gate caught nothing because no python build defines RC_ORACLE. Fix: move `extern "C" int rc_oracle_run(void *func);` to file scope (line 32, between #include block and `namespace jit`), guarded by the same #ifdef RC_ORACLE so production builds remain unaffected. Inside the function body, just call rc_oracle_run() (now visible via the file-scope declaration). Verification: - Production cmake --build phoenix_jit + make python: PASS, 0 errors (RC_ORACLE undefined → both forward-decl and dispatcher absent) - Out-of-band -DRC_ORACLE=1 compile of compiler.cpp: PASS (3.2 MB compiler_rc_oracle.cpp.o), 0 errors - nm production python | grep rc_oracle: 0 matches (Item python#15 falsifier still satisfied) Push 45 (gate-script fix follow-up). Discovery + fix is itself the push 44 W3 oracle's first real value: the synthetic-injection infrastructure surfaced a real linkage bug in the dispatcher that production gates would never have caught (RC_ORACLE not defined → block absent → bug invisible).
1 parent 9cbf413 commit f2e5bfe

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎Python/jit/compiler.cpp‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
#include <chrono>
3030
#include <iostream>
3131

32+
#ifdef RC_ORACLE
33+
// W3 R4 oracle entry point — defined in libphoenix_rc_oracle.a (built only
34+
// when RC_ORACLE is defined). Forward-declared here at file scope because
35+
// C++ doesn't allow extern "C" inside a function body.
36+
extern "C" int rc_oracle_run(void *func);
37+
#endif
38+
3239
namespace jit {
3340

3441
template <typename T>
@@ -133,7 +140,8 @@ void Compiler::runPasses(
133140
// env var RC_ORACLE_USE_CXX selects between current C path and the
134141
// cc4a18e7e5 C++ snapshot (refcount_insertion.cpp via adapter).
135142
// See docs/oracle_scratch/_rc_oracle_adapter.h for full BRIDGE SPEC + invariants.
136-
extern "C" int rc_oracle_run(void *func); // libphoenix_rc_oracle.a
143+
// (rc_oracle_run forward-declared at file scope below; C++ does not allow
144+
// extern "C" inside function body.)
137145
if (const char *env = getenv("RC_ORACLE_USE_CXX"); env != nullptr && *env != '0') {
138146
rc_oracle_run(&irfunc); // cc4a18e7e5 C++ refcount_insertion via adapter
139147
} else {

0 commit comments

Comments
 (0)