From aecc3c41ad3d369424d1c21b0a352b78b091cd56 Mon Sep 17 00:00:00 2001 From: lazerg Date: Sun, 4 Oct 2026 18:03:00 +0500 Subject: [PATCH 1/2] gh-158795: Fix unused tracing table warning with --with-tail-call-interp --- .../next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst | 2 ++ Modules/_testinternalcapi/test_targets.h | 4 ++++ Python/opcode_targets.h | 4 ++++ Tools/cases_generator/target_generator.py | 4 ++++ 4 files changed, 14 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst diff --git a/Misc/NEWS.d/next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst b/Misc/NEWS.d/next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst new file mode 100644 index 00000000000000..cfd46b8b270760 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst @@ -0,0 +1,2 @@ +Fix an unused variable compiler warning for the tracing dispatch table when +building with :option:`--with-tail-call-interp` without the JIT. diff --git a/Modules/_testinternalcapi/test_targets.h b/Modules/_testinternalcapi/test_targets.h index 91b424773224e4..9f9d4ff89190c9 100644 --- a/Modules/_testinternalcapi/test_targets.h +++ b/Modules/_testinternalcapi/test_targets.h @@ -520,7 +520,9 @@ static void *opcode_tracing_targets_table[256] = { #else /* _Py_TAIL_CALL_INTERP */ static py_tail_call_funcptr instruction_funcptr_handler_table[256]; +#if _Py_TIER2 static py_tail_call_funcptr instruction_funcptr_tracing_table[256]; +#endif static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_pop_2_error(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_pop_1_error(TAIL_CALL_PARAMS); @@ -1031,6 +1033,7 @@ static py_tail_call_funcptr instruction_funcptr_handler_table[256] = { [231] = _TAIL_CALL_UNKNOWN_OPCODE, [232] = _TAIL_CALL_UNKNOWN_OPCODE, }; +#if _Py_TIER2 static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = { [BINARY_OP] = _TAIL_CALL_TRACE_RECORD, [BINARY_OP_ADD_FLOAT] = _TAIL_CALL_TRACE_RECORD, @@ -1289,4 +1292,5 @@ static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = { [231] = _TAIL_CALL_UNKNOWN_OPCODE, [232] = _TAIL_CALL_UNKNOWN_OPCODE, }; +#endif #endif /* _Py_TAIL_CALL_INTERP */ diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 91b424773224e4..9f9d4ff89190c9 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -520,7 +520,9 @@ static void *opcode_tracing_targets_table[256] = { #else /* _Py_TAIL_CALL_INTERP */ static py_tail_call_funcptr instruction_funcptr_handler_table[256]; +#if _Py_TIER2 static py_tail_call_funcptr instruction_funcptr_tracing_table[256]; +#endif static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_pop_2_error(TAIL_CALL_PARAMS); static PyObject *Py_PRESERVE_NONE_CC _TAIL_CALL_pop_1_error(TAIL_CALL_PARAMS); @@ -1031,6 +1033,7 @@ static py_tail_call_funcptr instruction_funcptr_handler_table[256] = { [231] = _TAIL_CALL_UNKNOWN_OPCODE, [232] = _TAIL_CALL_UNKNOWN_OPCODE, }; +#if _Py_TIER2 static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = { [BINARY_OP] = _TAIL_CALL_TRACE_RECORD, [BINARY_OP_ADD_FLOAT] = _TAIL_CALL_TRACE_RECORD, @@ -1289,4 +1292,5 @@ static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = { [231] = _TAIL_CALL_UNKNOWN_OPCODE, [232] = _TAIL_CALL_UNKNOWN_OPCODE, }; +#endif #endif /* _Py_TAIL_CALL_INTERP */ diff --git a/Tools/cases_generator/target_generator.py b/Tools/cases_generator/target_generator.py index e7cf6c223d22dc..a7a9154051d6ea 100644 --- a/Tools/cases_generator/target_generator.py +++ b/Tools/cases_generator/target_generator.py @@ -50,7 +50,9 @@ def function_proto(name: str) -> str: def write_tailcall_dispatch_table(analysis: Analysis, out: CWriter) -> None: out.emit("static py_tail_call_funcptr instruction_funcptr_handler_table[256];\n") out.emit("\n") + out.emit("#if _Py_TIER2\n") out.emit("static py_tail_call_funcptr instruction_funcptr_tracing_table[256];\n") + out.emit("#endif\n") out.emit("\n") # Emit function prototypes for labels. @@ -82,6 +84,7 @@ def write_tailcall_dispatch_table(analysis: Analysis, out: CWriter) -> None: out.emit("};\n") # Emit the tracing dispatch table. + 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") @@ -90,6 +93,7 @@ def write_tailcall_dispatch_table(analysis: Analysis, out: CWriter) -> None: if rest not in named_values: out.emit(f"[{rest}] = _TAIL_CALL_UNKNOWN_OPCODE,\n") out.emit("};\n") + out.emit("#endif\n") outfile.write("#endif /* _Py_TAIL_CALL_INTERP */\n") arg_parser = argparse.ArgumentParser( From 856d1633beedb5ff8cad16f3dd4e462cf040718b Mon Sep 17 00:00:00 2001 From: lazerg Date: Sun, 4 Oct 2026 23:24:53 +0500 Subject: [PATCH 2/2] Remove NEWS entry --- .../next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 Misc/NEWS.d/next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst diff --git a/Misc/NEWS.d/next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst b/Misc/NEWS.d/next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst deleted file mode 100644 index cfd46b8b270760..00000000000000 --- a/Misc/NEWS.d/next/Build/2026-10-04-13-00-14.gh-issue-158795.zYlNgM.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix an unused variable compiler warning for the tracing dispatch table when -building with :option:`--with-tail-call-interp` without the JIT.