Bug report
Building CPython with --with-tail-call-interp without Tier 2 / JIT enabled produces a -Wunused-variable compiler warning.
./configure --with-tail-call-interp --with-pydebug
make
Actual behavior
In file included from Python/ceval.c:1113:
Python/opcode_targets.h:1034:29: warning: ‘instruction_funcptr_tracing_table’ defined but not used [-Wunused-variable]
1034 | static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expected behavior
Clean build without -Wunused-variable warnings.
Cause
instruction_funcptr_tracing_table is only used when Tier 2 tracing is active (Python/ceval_macros.h references TRACING_DISPATCH_TABLE under #if (_Py_TAIL_CALL_INTERP || USE_COMPUTED_GOTOS) && _Py_TIER2).
When building --with-tail-call-interp without JIT/Tier 2:
- In computed gotos mode,
opcode_tracing_targets_table is already guarded by #if _Py_TIER2 in Tools/cases_generator/target_generator.py.
- In tail-call mode,
instruction_funcptr_tracing_table (both forward declaration and definition) is emitted unconditionally, leaving it unused in Python/ceval.c.
Suggested fix
In Tools/cases_generator/target_generator.py, wrap the forward declaration and definition of instruction_funcptr_tracing_table in #if _Py_TIER2, matching opcode_tracing_targets_table:
# Forward declaration
out.emit("#if _Py_TIER2\n")
out.emit("static py_tail_call_funcptr instruction_funcptr_tracing_table[256];\n")
out.emit("#endif\n")
...
# Table definition
out.emit("#if _Py_TIER2\n")
out.emit("static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = {\n")
for name in sorted(analysis.instructions.keys()):
out.emit(f"[{name}] = _TAIL_CALL_TRACE_RECORD,\n")
named_values = analysis.opmap.values()
for rest in range(256):
if rest not in named_values:
out.emit(f"[{rest}] = _TAIL_CALL_UNKNOWN_OPCODE,\n")
out.emit("};\n")
out.emit("#endif\n")
CPython versions tested on:
CPython main (3.16), 3.15
Operating systems tested on:
Linux
Linked PRs
Bug report
Building CPython with
--with-tail-call-interpwithout Tier 2 / JIT enabled produces a-Wunused-variablecompiler warning.Actual behavior
Expected behavior
Clean build without
-Wunused-variablewarnings.Cause
instruction_funcptr_tracing_tableis only used when Tier 2 tracing is active (Python/ceval_macros.hreferencesTRACING_DISPATCH_TABLEunder#if (_Py_TAIL_CALL_INTERP || USE_COMPUTED_GOTOS) && _Py_TIER2).When building
--with-tail-call-interpwithout JIT/Tier 2:opcode_tracing_targets_tableis already guarded by#if _Py_TIER2inTools/cases_generator/target_generator.py.instruction_funcptr_tracing_table(both forward declaration and definition) is emitted unconditionally, leaving it unused inPython/ceval.c.Suggested fix
In
Tools/cases_generator/target_generator.py, wrap the forward declaration and definition ofinstruction_funcptr_tracing_tablein#if _Py_TIER2, matchingopcode_tracing_targets_table:CPython versions tested on:
CPython main (3.16), 3.15
Operating systems tested on:
Linux
Linked PRs