root icon indicating copy to clipboard operation
root copied to clipboard

6.26.04 Build failure on Ubuntu 22.04 amd64

Open steffen-AEI opened this issue 2 years ago • 17 comments

  • [x] Checked for duplicates

Describe the bug

Root 6.26.04 build fails in a Ubuntu 22.04 pbuilder sandbox, with the following features enabled:

-- Enabled support for:  asimage builtin_clang builtin_cling builtin_llvm builtin_nlohmannjson builtin_openui5 builtin_unuran builtin_vdt builtin_xrootd builtin_xxhash clad dataframe davix dcache exceptions fftw3 fitsio fortran gdml gfal gnuinstall gsl_shared gviz http fcgi mathmore mlp minuit2 mysql odbc opengl pgsql pyroot pythia8 r roofit webgui rpath shadowpw shared soversion sqlite ssl tmva tmva-pymva tmva-rmva spectrum unuran vdt x11 xml xrootd

with the error

[ 71%] Linking CXX executable ../bin/rootcling
/usr/bin/ld: ../lib/libCling.so.6.26.04: undefined reference to `typeinfo for clang::sema::FunctionScopeInfo' 
collect2: error: ld returned 1 exit status
make[4]: *** [main/CMakeFiles/rootcling.dir/build.make:101: bin/rootcling] Error 1

This looks like an incompatibility between clang and cling - which both are builtin. Building in a 20.04 pbuilder sandbox succeeds (same set of features as above, minus webgui, btw).

Expected behavior

The same set of build instructions (with identical dependencies) succeeds on Debian 11 Bullseye and 10 Buster, with

-- Enabled support for:  asimage builtin_clang builtin_cling builtin_llvm builtin_nlohmannjson builtin_openui5 builtin_unuran builtin_vdt builtin_xrootd builtin_xxhash clad dataframe davix dcache exceptions fftw3 fitsio fortran gdml gfal gnuinstall gsl_shared gviz http fcgi mathmore mlp minuit2 mysql odbc opengl pgsql pyroot pythia8 r roofit rpath shadowpw shared soversion sqlite ssl tmva tmva-pymva tmva-rmva spectrum unuran vdt x11 xml xrootd

(webgui is missing for a yet unknown reason)

To Reproduce

Install required and optional dependencies matching the selected feature set, then run cmake and make as suggested.

Setup

ROOT 6.26.04 OS Ubuntu 22.04 (amd64) pbuilder sandbox on 20.04 system Source: official tarball

Additional context

nothing yet

Full log (1.2MB) here

steffen-AEI avatar Jun 17 '22 08:06 steffen-AEI

Hi @steffen-AEI, unfortunately I cannot reproduce this issue on my side using a Docker container. Also we have builds on Ubuntu 22.04 in our Jenkins CI that don't show the problem either.

What worries me is that (if my memory doesn't fail me) we actually shouldn't produce typeinfos for LLVM classes - all relevant files should be built with -fno-rtti. Could you maybe check which file references that particular typeinfo? One obvious candidate would be TCling.cxx.o, could you post the output of nm ./core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o | grep _ZTI? If that doesn't show typeinfo references for the clang:: namespace (as it should or rather should not), could you search all object files in core/clingutils and core/metacling with something like find core/metacling/ -name "*.o" | xargs nm | grep _ZTI?

hahnjo avatar Jun 20 '22 07:06 hahnjo

I've been trying to reproduce the behaviour in an interactive pbuilder root, with the previous dependencies, but running cmake with minimal options, and make -j 1. Embarrassingly, I seem to get over the "71% (rootcling) point" - although the percentages may be misleading (the following is copied from script output, so it contains ANSI sequences):

[ 50%] .[32m.[1mLinking CXX executable ../bin/rootcling.[0m
cd /build/root-cds-6.26.04.sg/.build/main && /usr/bin/cmake -E cmake_link_script CMakeFiles/rootcling.dir/link.txt --verbose=1                                                                                                                                                            
/usr/bin/c++  -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O3 -DNDEBUG  -rdynamic CMakeFiles/rootcling.dir/src/rootcling.cxx.o -o ../bin/rootcling  -Wl,-rpath,/build/root-cds-6.26.04.sg/.build/lib: ../lib/libRIO.so ../lib/libCling.so ../lib/libThread.so ../lib/libCore.so -Wl,--unresolved-symbols=ignore-in-object-files
cd /build/root-cds-6.26.04.sg/.build/bin && ln -f rootcling rootcint
cd /build/root-cds-6.26.04.sg/.build/bin && ln -f rootcling genreflex
make[2]: Leaving directory '/build/root-cds-6.26.04.sg/.build'
[ 50%] Built target rootcling

and end up with a completely different error:

[ 85%] Generating G__MathMore.cxx, ../../lib/MathMore.pcm
cd /build/root-cds-6.26.04.sg/.build/math/mathmore && /usr/bin/cmake -E env LD_LIBRARY_PATH=/build/root-cds-6.26.04.sg/.build/lib: ROOTIGNOREPREFIX=1 /build/root-cds-6.26.04.sg/.build/bin/rootcling -rootbuild -v2 -f G__MathMore.cxx -cxxmodule -s /build/root-cds-6.26.04.sg/.build/lib/libMathMore.so -m MathCore.pcm -excludePath /build/root-cds-6.26.04.sg -excludePath /build/root-cds-6.26.04.sg/.build/ginclude -excludePath /build/root-cds-6.26.04.sg/.build/externals -excludePath /build/root-cds-6.26.04.sg/.build/builtins -compilerI/usr/include/c++/11 -compilerI/usr/include/x86_64-linux-gnu/c++/11 -compilerI/usr/include/c++/11/backward -compilerI/usr/lib/gcc/x86_64-linux-gnu/11/include -compilerI/usr/local/include -compilerI/usr/include/x86_64-linux-gnu -compilerI/usr/include -compilerI/usr/lib/gcc/x86_64-linux-gnu/11/include -compilerI/usr/local/include -compilerI/usr/include/x86_64-linux-gnu -compilerI/usr/include -I/build/root-cds-6.26.04.sg/.build/include -I/usr/include -I/build/root-cds-6.26.04.sg/math/mathmore/inc -I/build/root-cds-6.26.04.sg/core/unix/inc -I/build/root-cds-6.26.04.sg/core/foundation/v7/inc -I/build/root-cds-6.26.04.sg/core/base/v7/inc -I/build/root-cds-6.26.04.sg/core/clingutils/inc -I/build/root-cds-6.26.04.sg/core/textinput/inc -I/build/root-cds-6.26.04.sg/core/thread/inc -I/build/root-cds-6.26.04.sg/core/zip/inc -I/build/root-cds-6.26.04.sg/core/rint/inc -I/build/root-cds-6.26.04.sg/core/clib/inc -I/build/root-cds-6.26.04.sg/core/meta/inc -I/build/root-cds-6.26.04.sg/core/gui/inc -I/build/root-cds-6.26.04.sg/core/cont/inc -I/build/root-cds-6.26.04.sg/core/foundation/inc -I/build/root-cds-6.26.04.sg/core/base/inc -I/build/root-cds-6.26.04.sg/.build/ginclude -I/build/root-cds-6.26.04.sg/math/mathcore/v7/inc -I/build/root-cds-6.26.04.sg/math/mathcore/inc -I/build/root-cds-6.26.04.sg/core/imt/inc -I/build/root-cds-6.26.04.sg/core/multiproc/inc -I/usr/include -I/build/root-cds-6.26.04.sg/net/net/inc -I/build/root-cds-6.26.04.sg/io/io/v7/inc -I/build/root-cds-6.26.04.sg/io/io/inc Math/ChebyshevApprox.h Math/Derivator.h Math/DistFuncMathMore.h Math/GSLIntegrator.h Math/GSLMCIntegrator.h Math/GSLMinimizer.h Math/GSLMinimizer1D.h Math/GSLMultiRootFinder.h Math/GSLNLSMinimizer.h Math/GSLQuasiRandom.h Math/GSLRandom.h Math/GSLRandomFunctions.h Math/GSLRndmEngines.h Math/GSLRootFinder.h Math/GSLRootFinderDeriv.h Math/GSLSimAnMinimizer.h Math/InterpolationTypes.h Math/Interpolator.h Math/KelvinFunctions.h Math/MCParameters.h Math/PdfFuncMathMore.h Math/Polynomial.h Math/ParamFunction.h Math/QuasiRandom.h Math/RootFinderAlgorithms.h Math/SpecFuncMathMore.h Math/Vavilov.h Math/VavilovAccurate.h Math/VavilovAccurateCdf.h Math/VavilovAccuratePdf.h Math/VavilovAccurateQuantile.h Math/VavilovFast.h /build/root-cds-6.26.04.sg/math/mathmore/inc/Math/LinkDef.h
<<< cling interactive line includer >>>: fatal error: module file '/build/root-cds-6.26.04.sg/.build/lib/Rint.pcm' is out of date and needs to be rebuilt: could not read module signature
<<< cling interactive line includer >>>: note: imported by module 'MathCore' in '/build/root-cds-6.26.04.sg/.build/lib/MathCore.pcm'
Error: Module 'MathCore.pcm' failed to load.
Error: Error loading the default rootcling header files.
make[2]: *** [math/mathmore/CMakeFiles/G__MathMore.dir/build.make:142: math/mathmore/G__MathMore.cxx] Error 1
make[2]: Leaving directory '/build/root-cds-6.26.04.sg/.build'
make[1]: *** [CMakeFiles/Makefile2:26590: math/mathmore/CMakeFiles/G__MathMore.dir/all] Error 2

Something still seems to be wrong with cling? What is that Rint file, is it related to R (which isn't enabled)?

-- Enabled support for:  asimage builtin_clang builtin_cling builtin_llvm builtin_nlohmannjson builtin_openui5 builtin_vdt builtin_xrootd builtin_xxhash clad dataframe davix exceptions fftw3 fitsio gdml gfal gnuinstall http imt mathmore mlp minuit2 mysql opengl pgsql pyroot roofit webgui root7 rpath runtime_cxxmodules shared sqlite ssl tmva tmva-cpu tmva-pymva spectrum vdt x11 xml xrootd

I'm already running out of ideas but will retry with the full dependency set and cmake options line, keeping -j 1

steffen-AEI avatar Jun 21 '22 07:06 steffen-AEI

What is that Rint file, is it related to R (which isn't enabled)?

No, Rint is one of ROOT's core/ libraries. I suppose it stands for "interactive" or "interpreter".

module file [...] is out of date and needs to be rebuilt: could not read module signature

This type of error is usually only seen in incremental builds that were previously aborted or corrupted in one way or another. Is that the case or are you building from a clean directory?

hahnjo avatar Jun 21 '22 08:06 hahnjo

This is a temporarily created sandbox, created by pbuilder, and populated accordingly (with Build-Depends: packages) before running the actual build code - and destroyed immediately afterwards.

Thanks for clarifying the meaning of Rint, I was confused by the capital R.

In the meantime, I was able to re-run pbuilder and got the ::sema:: error from the beginning. If it turns out that an interactive session cannot reproduce batch session results (and errors) I really don't know what to do next :(

steffen-AEI avatar Jun 21 '22 11:06 steffen-AEI

Okay, getting closer, it seems. Debian seems to have some special ideas about running cmake, and would use

cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON "-GUnix Makefiles" -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc/root -Dgnuinstall=ON ..

with the failure above. Running

cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc/root -Dgnuinstall=ON ..

(only using the explicit -D options provided to dh_auto_configure) makes the build succeed.

Time to bisect...

steffen-AEI avatar Jun 22 '22 09:06 steffen-AEI

@steffen-AEI what is your use case for the pbuilder sandbox? As mentioned before, ROOT seems to generally work on Ubuntu 22.04 and we (as the ROOT team) cannot support all possible configuration and sandbox possibilities out there...

hahnjo avatar Jun 29 '22 06:06 hahnjo

I have a couple of Debian/Ubuntu packages which depend (and build-depend) on ROOT; the only clean way to support those is to have a ROOT package (or package set) as well.

Running cmake and make by hand succeeds while putting exactly the same instructions into a debian/rules file (as overrides for the default debhelper build steps) results in failure(s). Dropping debhelper, and going back to an old-style binary target, might be the last resort, but I'm trying to avoid this.

steffen-AEI avatar Jun 29 '22 07:06 steffen-AEI

@stephanlachnit I know you come from the Debian side, and I remember you have a private package of ROOT that builds successfully. Any idea what might go wrong on Ubuntu?

Otherwise I'm tempted to close this because it's basically not reproducible standalone, and I could simply argue it's a problem in the packaging system...

hahnjo avatar Aug 04 '22 12:08 hahnjo

@stephanlachnit I know you come from the Debian side, and I remember you have a private package of ROOT that builds successfully. Any idea what might go wrong on Ubuntu?

Seems a bit weird to me, never seen this kind of error. But I also stopped using pbuilder in favor of sbuild for quite a while now.

@steffen-AEI can you try to build the ROOT deb using this repository and sbuild? I.e.

# follow the instructions on the wiki to setup sbuild first
git clone https://salsa.debian.org/science-team/root.git
cd root
USCAN_SYMLINK=rename uscan -v --force-download # downloads source tarball, might take a while
sbuild

stephanlachnit avatar Aug 04 '22 12:08 stephanlachnit

I can see the same when trying to build root 6.26.06 on openSUSE Tumbleweed.

Full commandline of the failing link:

[ 1887s] [ 76%] Linking CXX executable ../bin/rootcling
[ 1887s] cd /home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/main && /usr/bin/cmake -E cmake_link_script CMakeFiles/rootcling.dir/link.txt --verbose=1
[ 1887s] /usr/bin/c++ -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O2 -g -DNDEBUG -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -rdynamic CMakeFiles/rootcling.dir/src/rootcling.cxx.o -o ../bin/rootcling  -Wl,-rpath,/home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/lib: ../lib/libRIO.so.6.26.06 ../lib/libCling.so.6.26.06 ../lib/libThread.so.6.26.06 ../lib/libCore.so.6.26.06 -Wl,--unresolved-symbols=ignore-in-object-files 
[ 1887s] /usr/lib64/gcc/x86_64-suse-linux/12/../../../../x86_64-suse-linux/bin/ld: ../lib/libCling.so.6.26.06: undefined reference to `typeinfo for clang::sema::FunctionScopeInfo'

Note the -Wl,--no-undefined linker option, added by default on TW for all builds.

StefanBruens avatar Aug 05 '22 22:08 StefanBruens

find /var/tmp/build-root/openSUSE_Tumbleweed-x86_64/.build.packages/BUILD/root-6.26.06/_builddir/core/metacling/ -iname \*o -print -exec nm -C --undefined '{}' \; | grep -E 'cxx.o| clang::sema'

...
/var/tmp/build-root/openSUSE_Tumbleweed-x86_64/.build.packages/BUILD/root-6.26.06/_builddir/core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o
         U clang::sema::FunctionScopeInfo::~FunctionScopeInfo()
         U typeinfo for clang::sema::FunctionScopeInfo
         U vtable for clang::sema::FunctionScopeInfo

StefanBruens avatar Aug 06 '22 04:08 StefanBruens

TCling.cxx is not build with -fno-rtti:

[ 1331s] [ 75%] Building CXX object core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o
[ 1331s] cd /home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/core/metacling/src && /var/lib/build/ccache/bin/c++  -I/home/abuild/rpmbuild/BUILD/root-6.26.06/interpreter/cling/include -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/metacling/res -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/clingutils/res -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/foundation/res -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/zip/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/clib/res -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/base/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/meta/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/clib/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/foundation/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/thread/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/cont/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/gui/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/io/io/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/ginclude -isystem /home/abuild/rpmbuild/BUILD/root-6.26.06/interpreter/llvm/src/tools/clang/include -isystem /home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/interpreter/llvm/src/tools/clang/include -isystem /home/abuild/rpmbuild/BUILD/root-6.26.06/interpreter/llvm/src/include -isystem /home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/interpreter/llvm/src/include -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O2 -g -DNDEBUG -fPIC -fvisibility-inlines-hidden -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread   -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-strict-aliasing -Wwrite-strings -Wno-shadow -Wno-unused-parameter -Wno-deprecated-declarations -std=c++17 -MD -MT core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o -MF CMakeFiles/MetaCling.dir/TCling.cxx.o.d -o CMakeFiles/MetaCling.dir/TCling.cxx.o -c /home/abuild/rpmbuild/BUILD/root-6.26.06/core/metacling/src/TCling.cxx

while other are, e.g.:

[ 1327s] [ 75%] Building CXX object core/metacling/src/CMakeFiles/MetaCling.dir/TClingRdictModuleFileExtension.cxx.o
[ 1327s] cd /home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/core/metacling/src && /var/lib/build/ccache/bin/c++  -I/home/abuild/rpmbuild/BUILD/root-6.26.06/interpreter/cling/include -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/metacling/res -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/clingutils/res -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/foundation/res -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/zip/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/clib/res -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/base/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/meta/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/clib/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/foundation/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/thread/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/cont/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/core/gui/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/io/io/inc -I/home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/ginclude -isystem /home/abuild/rpmbuild/BUILD/root-6.26.06/interpreter/llvm/src/tools/clang/include -isystem /home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/interpreter/llvm/src/tools/clang/include -isystem /home/abuild/rpmbuild/BUILD/root-6.26.06/interpreter/llvm/src/include -isystem /home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/interpreter/llvm/src/include -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O2 -g -DNDEBUG -fPIC -fvisibility-inlines-hidden -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread   -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-strict-aliasing -Wwrite-strings -Wno-shadow -Wno-unused-parameter -Wno-deprecated-declarations -std=c++17 -fno-rtti -MD -MT core/metacling/src/CMakeFiles/MetaCling.dir/TClingRdictModuleFileExtension.cxx.o -MF CMakeFiles/MetaCling.dir/TClingRdictModuleFileExtension.cxx.o.d -o CMakeFiles/MetaCling.dir/TClingRdictModuleFileExtension.cxx.o -c /home/abuild/rpmbuild/BUILD/root-6.26.06/core/metacling/src/TClingRdictModuleFileExtension.cxx

StefanBruens avatar Aug 06 '22 04:08 StefanBruens

Obvious reason - -fno-rtti is only set for 3 source files:

https://github.com/root-project/root/blob/69002fa23d19ad50ff8dd6c7678a6343748ba3fd/core/metacling/src/CMakeLists.txt#L15-L19

StefanBruens avatar Aug 06 '22 04:08 StefanBruens

The culprit is ClingRAII.h, included from TCling.cxx:

https://github.com/root-project/root/blob/69002fa23d19ad50ff8dd6c7678a6343748ba3fd/core/metacling/src/ClingRAII.h#L15

https://github.com/root-project/root/blob/69002fa23d19ad50ff8dd6c7678a6343748ba3fd/core/metacling/src/ClingRAII.h#L37-L45

It should be sufficient to move SemaExprCleanupsRAII ctor/dtor to a separate implementation file. The remaining code only needs the FunctionScopeInfo forward declaration from clang/Sema/Sema.h.

StefanBruens avatar Aug 06 '22 14:08 StefanBruens

(slight correction to what I said before: Since https://github.com/root-project/root/pull/10289 LLVM is built with RTTI in master. This is different from released versions of 6.26 and earlier, so keep in mind while investigating...)

Note the -Wl,--no-undefined linker option, added by default on TW for all builds.

This option is also a ROOT default for shared libraries. I tested adding it to CMAKE_EXE_LINKER_FLAGS for executable as well and it doesn't change anything. (not sure if it should, after all all symbols must be resolved when linking an executable, no?)

find /var/tmp/build-root/openSUSE_Tumbleweed-x86_64/.build.packages/BUILD/root-6.26.06/_builddir/core/metacling/ -iname \*o -print -exec nm -C --undefined '{}' \; | grep -E 'cxx.o| clang::sema'

...
/var/tmp/build-root/openSUSE_Tumbleweed-x86_64/.build.packages/BUILD/root-6.26.06/_builddir/core/metacling/src/CMakeFiles/MetaCling.dir/TCling.cxx.o
         U clang::sema::FunctionScopeInfo::~FunctionScopeInfo()
         U typeinfo for clang::sema::FunctionScopeInfo
         U vtable for clang::sema::FunctionScopeInfo

Unfortunately I cannot reproduce this on my end. It's correct that only a few files are compiled with -fno-rtti, all others including TCling.cxx interface with the rest of ROOT and must be built with RTTI. They should never contain code that references RTTI of LLVM classes, and while it's possible that we overlooked something I don't quite understand why we can only observe the problem in very limited environments...

hahnjo avatar Aug 08 '22 09:08 hahnjo

(slight correction to what I said before: Since #10289 LLVM is built with RTTI in master. This is different from released versions of 6.26 and earlier, so keep in mind while investigating...)

Note the -Wl,--no-undefined linker option, added by default on TW for all builds.

This option is also a ROOT default for shared libraries. I tested adding it to CMAKE_EXE_LINKER_FLAGS for executable as well and it doesn't change anything. (not sure if it should, after all all symbols must be resolved when linking an executable, no?)

There are several occasions when symbol resolving may happen:

  1. When linking libCling.so - whe shared library is linked with --no-unresolved, but also with --unresolved-symbols=ignore-in-object-files -> missing symbols are ignored
[ 1473s] cd /home/abuild/rpmbuild/BUILD/root-6.26.06/_builddir/core/metacling/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/Cling.dir/link.txt --verbose=1
[ 1473s] /usr/bin/c++ -fPIC -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -std=c++17 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O2 -g -DNDEBUG  -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -Wl,--no-undefined -Wl,--hash-style="both" -shared -Wl,-soname,libCling.so.6.26 -o ../../../lib/libCling.so.6.26.06 ../../clingutils/CMakeFiles/ClingUtils.dir/src/RStl.cxx.o ../../clingutils/CMakeFiles/ClingUtils.dir/src/TClingUtils.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/BaseSelectionRule.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/ClassSelectionRule.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/DictSelectionReader.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/LinkdefReader.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/rootcling_impl.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/Scanner.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/SelectionRules.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/TModuleGenerator.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/VariableSelectionRule.cxx.o ../../dictgen/CMakeFiles/Dictgen.dir/src/XMLReader.cxx.o CMakeFiles/MetaCling.dir/rootclingTCling.cxx.o CMakeFiles/MetaCling.dir/ClingRAII.cxx.o CMakeFiles/MetaCling.dir/TCling.cxx.o CMakeFiles/MetaCling.dir/TClingBaseClassInfo.cxx.o CMakeFiles/MetaCling.dir/TClingCallbacks.cxx.o CMakeFiles/MetaCling.dir/TClingCallFunc.cxx.o CMakeFiles/MetaCling.dir/TClingClassInfo.cxx.o CMakeFiles/MetaCling.dir/TClingDataMemberInfo.cxx.o CMakeFiles/MetaCling.dir/TClingDeclInfo.cxx.o CMakeFiles/MetaCling.dir/TClingDiagnostics.cxx.o CMakeFiles/MetaCling.dir/TClingMemberIter.cxx.o CMakeFiles/MetaCling.dir/TClingMethodArgInfo.cxx.o CMakeFiles/MetaCling.dir/TClingMethodInfo.cxx.o CMakeFiles/MetaCling.dir/TClingRdictModuleFileExtension.cxx.o CMakeFiles/MetaCling.dir/TClingTypedefInfo.cxx.o CMakeFiles/MetaCling.dir/TClingTypeInfo.cxx.o CMakeFiles/MetaCling.dir/TClingValue.cxx.o  -Wl,-rpath,:::::::::::::::::::::::: -Wl,--unresolved-symbols=ignore-in-object-files 
  1. When linking the executable a built time - dependent on --no-undefined in the CMAKE_EXE_LINKER_FLAGS
  2. At runtime at startup, when the runtime linker uses LD_BIND_NOW (man ld.so) - either set via env variable, or by default with -Wl,-z,now
  3. At runtime when the symbol is used the first time (without LD_BIND_NOW)

Unfortunately I cannot reproduce this on my end. It's correct that only a few files are compiled with -fno-rtti, all others including TCling.cxx interface with the rest of ROOT and must be built with RTTI. They should never contain code that references RTTI of LLVM classes, and while it's possible that we overlooked something I don't quite understand why we can only observe the problem in very limited environments...

See above for what has been overlooked. TCling.cxx calls the ScopeInfo dtor, and thus references its vtable.

Are you using Clang or GCC for compiling? Which version?

Have you verified -Wl,--no-undefined is actually used when linking rootcling?

StefanBruens avatar Aug 08 '22 10:08 StefanBruens

I've tried both Clang and GCC, the latter in different versions (8.5 from CentOS 8 Stream and 12.1.0 built from source). I also verified that -Wl,--no-undefined is there when linking rootcling. But this is really not relevant if TCling.cxx.o doesn't reference undefined symbols.

So I focused on this point and found that -flto is the culprit; with LTO enabled I see the undefined references in TCling.cxx.o. I talked to a colleague and LTO is (traditionally) not supported for building ROOT. Could you turn that off please when building the package? I'm currently re-evaluating on my side what amount of problems exist with LTO, but it might not be fixed in 6.26 if the required changes are invasive or never if we (the ROOT team) cannot allocate time on solving all the issues.

hahnjo avatar Aug 08 '22 11:08 hahnjo

Unfortunately ROOT does not currently support LTO and we do not have at the moment effort available to make progress there. I propose to close this item because of that and because we already have an issue about LTO here https://github.com/root-project/root/issues/11657

dpiparo avatar Feb 04 '24 07:02 dpiparo

Hi @dpiparo, @hahnjo,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely, :robot:

github-actions[bot] avatar Feb 05 '24 06:02 github-actions[bot]