ROOT Version: 6.26.04
Platform: Android x86_64 (Termux)
Compiler: Clang 15.0.1
Hi,
I’m trying to get cppyy working on my embedded device. I’m able to compile and run cling (installed with cpt.py), and can e.g. do import <stdio.h>
and printf("Hello World");
However, cppyy requires Root, and so I have been trying to get Root to build. For reference I am using the version of Root from the cppyy-backend
pip package.
I have gotten to the point where rootcling
builds successfully, with some minor patches including one to TPosixThread.cxx (disabling specific pthread_setcancelstate functionality, since that’s not available on Android). I don’t think this should be causing my issue.
My issue comes at the Generating PCH for core core/thread io/io
stage where I get a segfault:
[ 97%] Built target obj.clingInterpreter
[ 97%] Linking CXX static library ../../../../lib/libclingInterpreter.a
[ 97%] Built target clingInterpreter
[ 97%] Built target CLING
[ 97%] Built target LLVMRES
[ 98%] Built target Dictgen
[ 98%] Built target ClingUtils
[100%] Built target MetaCling
[100%] Linking CXX executable src/rootcling_stage1
[100%] Linking CXX shared library ../../../lib/libCling.so
[100%] Built target rootcling_stage1
[100%] Built target Cling
[100%] Built target G__CoreLegacy
[100%] Built target CoreLegacy
[100%] Built target G__ThreadLegacy
[100%] Built target ThreadLegacy
[100%] Built target G__RIOLegacy
[100%] Built target RIOLegacy
[100%] Linking CXX executable ../bin/rootcling
[100%] Built target rootcling
[100%] Generating etc/allDict.cxx.pch
Generating PCH for core core/thread io/io
IncrementalParser Setting up m_Consumer
<...>
DeclareInternal input is #include "cling/Interpreter/RuntimeUniverse.h"
<...>
DeclareInternal Finished
endTransaction empty tx, T is 0x72f71ce0f000
DeclareInternal input is <...>
<...>
DeclareInternal Finished
endTransaction empty tx, T is 0x72f71c9f9200
endTransaction empty tx, T is 0x72f71c9f9200
DeclareInternal input is #include "cling/Interpreter/DynamicLookupRuntimeUniverse.h"
<...>
DeclareInternal Finished
DeclareInternal input is namespace __CppyyLegacy_SpecialObjects{}
ParseInternal handling Decl
ParseInternal handing top level w/o trap
HandleTopLevelDecl: Handling top level decl
HandleTopLevelDecl: no m_Consumer, its pointer is 0x0
IncrementalParser::Compile Transaction CurT is 0x72f71c9fa600
IncrementalParser::Compile ParseRes 0
endTransaction empty tx, T is 0x72f71c9fa600
IncrementalParser::Compile PRT pointer is 0x0
IncrementalParser::Compile PRT int is 0
DeclareInternal setting *T to 0x0
DeclareInternal Finished
Stack dump:
0. Program arguments: ./bin/rootcling -rootbuild -generate-pch -f /data/data/com.termux/files/usr/tmp/allDict.cxx -noDictSelection -D__CLING__ -DROOT_PCH -I./include -I./etc -I./etc/dictpch -I./etc/cling -I/data/data/com.termux/files/home/cppyy-backend/cling/builddir/include -cxxflags -std=c++17 -pthread etc/dictpch/allHeaders.h etc/dictpch/allLinkDefs.h
make[2]: *** [CMakeFiles/onepcm.dir/build.make:79: etc/allDict.cxx.pch] Error 139
make[1]: *** [CMakeFiles/Makefile2:6458: CMakeFiles/onepcm.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
~/.../cling/builddir $
The extra logging is adding by me. Basically with gdb and whatnot I can see that the error is happening in TClingCallbacks.cxx
at
Transaction* T = 0;
m_Interpreter->declare("namespace __ROOT_SpecialObjects{}", &T);
fROOTSpecialNamespace = dyn_cast<NamespaceDecl>(T->getFirstDecl().getSingleDecl());
T is a nullptr, causing the segfault. I looked in the interpreter code, and it looks like the “namespace …” expression is being parsed successfully, but it’s not being added to the transaction, which eventually causes the nullptr.
It’s not being added because for some reason, m_Consumer
in DeclCollector::HandleTopLevelDecl
is 0x0 when the transaction is parsed. In the IncrementalParser::IncrementalParser
constructor, the value of WrappedConsumer
is 0x0. This seems to be intentional, since m_CI->getFrontendOpts().ProgramAction == frontend::ParseSyntaxOnly
and so the WrappedConsumer
is never being created.
So to summarize my understanding at the moment, it looks to me that 1. the WrappedConsumer
which is of type clang::ASTConsumer
is never being created, since the ProgramAction
is ParseSyntaxOnly
. At the same time, the fROOTSpecialNamespace
is expecting the transaction to be populated with declarations, which isn’t happening because WrappedConsumer (m_Consumer in DeclCollector) is never created.
Any guidance would be greatly appreciated!