From 8fa8a57a5fd68c68404227dc4c5e68b005156ac2 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 16 Nov 2026 22:37:25 +0000 Subject: [PATCH 1/3] [cppjit] Autoparse names missing from namespaces [ROOT-patch] Enums and variables known only from a rootmap, like the ATLAS xAOD enums and constants, were not found. Rootmaps don't forward declare them, so they only exist once their header is parsed. But interop::GetScope calls TClass::GetClass first, which normalizes the name with autoloading off: TCling can't autoparse it, and clang caches the failed lookup. Later lookups never ask TCling again. The old cppyy checked for enums before calling TClass::GetClass, so it was not affected. If a name is missing from a namespace, ask TCling to autoparse it and look again. Closes #24176. Assisted-by: claude-code:claude-opus-5-5 (cherry picked from commit 619d2bce2afb84866e07733c865ef0eca1297a08) --- .../pyroot/cppjit/src/interop/interop_wrapper.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bindings/pyroot/cppjit/src/interop/interop_wrapper.cxx b/bindings/pyroot/cppjit/src/interop/interop_wrapper.cxx index e4674b8e76a1c..6c953419b0b9f 100644 --- a/bindings/pyroot/cppjit/src/interop/interop_wrapper.cxx +++ b/bindings/pyroot/cppjit/src/interop/interop_wrapper.cxx @@ -892,6 +892,17 @@ interop::TCppScope_t interop::GetNamed(const std::string& name, if (TCppScope_t named = Cpp::GetNamed(name, parent_scope)) return named; + // Rootmaps don't forward declare enums and variables. If TClass::GetClass + // looked one up before its header was parsed, clang cached that miss and + // won't ask TCling to autoparse it again (#24176). + if (parent_scope && Cpp::IsNamespace(parent_scope)) { + const std::string qualified_name = + Cpp::GetQualifiedCompleteName(parent_scope) + "::" + name; + if (gInterpreter->AutoParse(qualified_name.c_str())) + if (TCppScope_t named = Cpp::GetNamed(name, parent_scope)) + return named; + } + // "gROOT" is a macro expanding to ROOT::GetROOT(); ROOT master exposed it // to cppyy as a TGlobalMappedFunction, a mechanism this backend does not // consult. Resolve it to the underlying variable instead (making sure it From 5cf4d4eb06705469765314cfa2c98109b7406d95 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 16 Nov 2026 22:37:25 +0000 Subject: [PATCH 2/3] [test] Add test for #24176 Enums and variables that are only known from a rootmap must be importable from their namespace before their header was parsed. Assisted-by: claude-code:claude-opus-5-5 (cherry picked from commit fcf6b4742ef5ce9ee90a545a3b2fe0206d1c56fc) --- roottest/python/regression/CMakeLists.txt | 15 ++++++++++++++ roottest/python/regression/gh_24176.h | 18 +++++++++++++++++ roottest/python/regression/gh_24176.py | 20 +++++++++++++++++++ .../python/regression/gh_24176_selection.xml | 4 ++++ 4 files changed, 57 insertions(+) create mode 100644 roottest/python/regression/gh_24176.h create mode 100644 roottest/python/regression/gh_24176.py create mode 100644 roottest/python/regression/gh_24176_selection.xml diff --git a/roottest/python/regression/CMakeLists.txt b/roottest/python/regression/CMakeLists.txt index 38fa998332b83..ccb807e7c4df9 100644 --- a/roottest/python/regression/CMakeLists.txt +++ b/roottest/python/regression/CMakeLists.txt @@ -21,4 +21,19 @@ endif() ROOTTEST_ADD_TEST(gh_21536 MACRO gh_21536.py) + + ROOTTEST_GENERATE_REFLEX_DICTIONARY(gh_24176 + gh_24176.h + SELECTION gh_24176_selection.xml + FIXTURES_SETUP python-regression-gh_24176-dict-fixture) + + ROOTTEST_ADD_TEST(gh_24176_enum + MACRO gh_24176.py + OPTS enum + FIXTURES_REQUIRED python-regression-gh_24176-dict-fixture) + + ROOTTEST_ADD_TEST(gh_24176_variable + MACRO gh_24176.py + OPTS variable + FIXTURES_REQUIRED python-regression-gh_24176-dict-fixture) endif() diff --git a/roottest/python/regression/gh_24176.h b/roottest/python/regression/gh_24176.h new file mode 100644 index 0000000000000..90042621f1590 --- /dev/null +++ b/roottest/python/regression/gh_24176.h @@ -0,0 +1,18 @@ +#ifndef GH_24176_H +#define GH_24176_H + +// Rootmaps don't forward declare enums and variables. +namespace gh_24176 { +namespace ns { + +enum EnumInNamespace { + kFirst = 1, + kSecond = 2 +}; + +const int kConstant = 3; + +} // namespace ns +} // namespace gh_24176 + +#endif diff --git a/roottest/python/regression/gh_24176.py b/roottest/python/regression/gh_24176.py new file mode 100644 index 0000000000000..84b5f42f2c378 --- /dev/null +++ b/roottest/python/regression/gh_24176.py @@ -0,0 +1,20 @@ +# Regression test for https://github.com/root-project/root/issues/24176 +# +# The names are only known from the rootmap, and finding them requires parsing +# their header. The first lookup parses the whole header, so each kind of name +# is checked in its own process. + +import sys + +kind = sys.argv[-1] + +if kind == "enum": + from ROOT.gh_24176.ns import EnumInNamespace + + assert EnumInNamespace.kSecond == 2 +elif kind == "variable": + from ROOT.gh_24176.ns import kConstant + + assert kConstant == 3 +else: + raise ValueError(f"unknown kind {kind!r}") diff --git a/roottest/python/regression/gh_24176_selection.xml b/roottest/python/regression/gh_24176_selection.xml new file mode 100644 index 0000000000000..d3ac3446a0537 --- /dev/null +++ b/roottest/python/regression/gh_24176_selection.xml @@ -0,0 +1,4 @@ + + + + From 0364ffb5bc630b07c91dcfe18c8cea2324ecdf09 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 17 Nov 2026 16:35:50 +0100 Subject: [PATCH 3/3] [ci] Update cppinterop and cppjit tags They are not pointing to the ROOT forks. The CppInterOp tag is equivalent to the previous hash. (cherry picked from commit 81438d340d30d89e257a302073cbd3ecdacd2c2a) --- .github/workflows/cppinterop-diff.yml | 2 +- .github/workflows/cppjit-diff.yml | 2 +- bindings/pyroot/cppjit/cppjit-version.tag | 2 +- interpreter/CppInterOp/cppinterop-version.tag | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cppinterop-diff.yml b/.github/workflows/cppinterop-diff.yml index e64eadf01a7ad..5c889ec8a0f42 100644 --- a/.github/workflows/cppinterop-diff.yml +++ b/.github/workflows/cppinterop-diff.yml @@ -21,7 +21,7 @@ jobs: - name: Check out CppInterOp uses: actions/checkout@v6 with: - repository: compiler-research/CppInterOp + repository: root-project/CppInterOp ref: ${{ steps.determine-tag.outputs.tag }} path: CppInterOp - name: Drop directories that are not added to ROOT diff --git a/.github/workflows/cppjit-diff.yml b/.github/workflows/cppjit-diff.yml index 60cdce08483af..7fb4b0c2c27b8 100644 --- a/.github/workflows/cppjit-diff.yml +++ b/.github/workflows/cppjit-diff.yml @@ -21,7 +21,7 @@ jobs: - name: Check out cppjit uses: actions/checkout@v6 with: - repository: compiler-research/cppjit + repository: root-project/cppjit ref: ${{ steps.determine-tag.outputs.tag }} path: cppjit - name: Drop files that are not added to ROOT diff --git a/bindings/pyroot/cppjit/cppjit-version.tag b/bindings/pyroot/cppjit/cppjit-version.tag index baa6611f1a84d..aa8d68b8b4a98 100644 --- a/bindings/pyroot/cppjit/cppjit-version.tag +++ b/bindings/pyroot/cppjit/cppjit-version.tag @@ -1 +1 @@ -3c66389821de2084c69cc9fdfcd26e32b47e16f5 +ROOT-20261117-01 diff --git a/interpreter/CppInterOp/cppinterop-version.tag b/interpreter/CppInterOp/cppinterop-version.tag index 33412e6eb6090..3e44a12e7af58 100644 --- a/interpreter/CppInterOp/cppinterop-version.tag +++ b/interpreter/CppInterOp/cppinterop-version.tag @@ -1 +1 @@ -acfde2400bedb9a243106c7ec868d3b2e29a8d03 +ROOT-20261021-01