Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault when compiling ROOT #1270

Closed
jmcarcell opened this issue May 31, 2024 · 4 comments
Closed

Segmentation fault when compiling ROOT #1270

jmcarcell opened this issue May 31, 2024 · 4 comments

Comments

@jmcarcell
Copy link

When compiling ROOT, I get a segmentation fault only when using mold, ld, lld and gold all work fine, with GCC 13, 14 and Clang 16 and 17. Originally reported in root-project/root#15473
Steps to reproduce:

git clone https://github.com/root-project/root
# Install mold and have it available in PATH, for example in /usr/bin
export LDFLAGS="-fuse-ld=mold"
cd root
mkdir builddir
cd builddir
cmake .. DCMAKE_CXX_STANDARD=20 -Dminimal=ON -G Ninja
ninja

And after waiting some time, errors like this one will appear:

[7643/9449] Generating G__RHTTP.cxx, ../../lib/RHTTP.pcm
FAILED: net/http/G__RHTTP.cxx lib/RHTTP.pcm /root/builddir/net/http/G__RHTTP.cxx /root/builddir/lib/RHTTP.pcm
cd /root/builddir/net/http && /usr/bin/cmake -E env LD_LIBRARY_PATH=/root/builddir/lib:/usr/local/lib: ROOTIGNOREPREFIX=1 /root/builddir/bin/rootcling -rootbuild -v2 -f G__RHTTP.cxx -cxxmodule -s /root/builddir/lib/libRHTTP.so -m RIO.pcm -m Thread.pcm -excludePath /root -excludePath /root/builddir/ginclude -excludePath /root/builddir/externals -excludePath /root/builddir/builtins -DUSE_WEBSOCKET -DUSE_X_DOM_SOCKET -DNO_SSL -DHTTP_WITHOUT_FASTCGI -compilerI/usr/include/c++/14.1.1 -compilerI/usr/include/c++/14.1.1/x86_64-pc-linux-gnu -compilerI/usr/include/c++/14.1.1/backward -compilerI/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include -compilerI/usr/local/include -compilerI/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include-fixed -compilerI/usr/include -compilerI/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include -compilerI/usr/local/include -compilerI/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include-fixed -compilerI/usr/include -I/root/builddir/include -I/usr/include -I/root/net/http/inc -I/root/core/unix/../clib/res -I/root/core/unix/inc -I/usr/include -I/root/core/zstd/inc -I/root/core/lz4/inc -I/root/core/lzma/inc -I/root/core/zip/inc -I/root/core/thread/inc -I/root/core/textinput/src -I/root/core/textinput/inc -I/root/core/rint/inc -I/root/core/meta/inc -I/root/core/gui/inc -I/root/core/foundation/res -I/root/core/foundation/v7/inc -I/root/core/foundation/inc -I/root/core/cont/inc -I/root/core/clingutils/res -I/root/core/clingutils/inc -I/root/core/clib/inc -I/root/core/base/v7/inc -I/root/core/base/inc -I/root/builddir/ginclude -I/root/io/io/v7/inc -I/root/io/io/inc -I/root/core/clib/res THttpCallArg.h THttpEngine.h THttpServer.h THttpWSHandler.h TRootSniffer.h TRootSnifferStore.h /root/net/http/inc/LinkDef.h
Segmentation fault

The issue seems to be the libCling.so library since I was able to compile fine by changing the linker used only for this target. The command above fails because rootcling is linked to libCling.so. The corresponding target is added in the CMakeLists.txt here: https://github.com/root-project/root/blob/master/core/metacling/src/CMakeLists.txt#L112. Cling is built on top of a patched version of LLVM 16 that can be found here: https://github.com/root-project/llvm-project.

@rui314
Copy link
Owner

rui314 commented May 31, 2024

Thank you for your report. I can reproduce the issue, and I think I found the cause of it. I'll submit a fix shortly.

@rui314 rui314 closed this as completed in 8cd85aa May 31, 2024
@rui314
Copy link
Owner

rui314 commented May 31, 2024

The above commit should fix the issue. ROOT passes both -z defs and --undefined=ignore-in-object-files to the linker, which triggered the bug. In this case, -z defs is redundant, as --undefined=ignore-in-object-files appears after that and override -z defs. If you remove -z defs from the build file, ROOT could be built with the current version of mold.

@jmcarcell
Copy link
Author

Thanks for the fix @rui314
I had a look and tried removing -z defs in the only place I could find it but I still got the same error (here). Alternatively I can just wait for the next version.

@rui314
Copy link
Owner

rui314 commented Jun 5, 2024

Yeah, it's been a month since the last release, and there are a few important bug fixes since then, so it may be a good idea to make another maintenance release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants