Out of memory compiling cling on WSL2

System is Windows 10 Home + WSL2 (Ubuntu 22.04)
I followed instructions on root.cern/cling/cling_build_instructions/ and failed on “cmake --build .”
[ 87%] Linking CXX executable …/…/…/…/bin/clang
collect2: fatal error: ld terminated with signal 9 [Killed]
compilation terminated.
gmake[2]: *** [tools/clang/tools/driver/CMakeFiles/clang.dir/build.make:340: bin/clang-13] Error 1
gmake[2]: *** Deleting file ‘bin/clang-13’
gmake[1]: *** [CMakeFiles/Makefile2:36892: tools/clang/tools/driver/CMakeFiles/clang.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2

I googled around and found out this seem to mean that memory is not enough, and someone got it to work by assigning 8GB of memory to WSL2. I did the same, and verified with htop that WSL2 has 12GB memory available. Yet the same error emerged. I’m guessing the same amount of memory was available in my previous failed run.

Is my problem not enough physical memory? Or did I perhaps cause some other error? I wonder how can I rule out either possibility. Has anyone run into a similar problem before?

Not sure this is really ROOT related. Anyway I got another question: why do you build ROOT from source? Can’t you use pre-built binaries or use conda?

Oh sorry, I overlooked at your post… First, welcome to the ROOT Forum! Then, I’m not sure there is anything we can do about memory. Maybe try to reduce the number of parallel builds (i.e. make -j4 or make -j2 or even make -j1)

Some instructions for ROOT on WSL2 can be found at Complete ROOT Installation Instructions for WSL (Ubuntu 18.04 on Windows 10) (and other posts linked from there).
As Bertrand mentions you should not need to compile ROOT from source.

Thanks guys. It didn’t occur to me that cling is not for building with typical desktop resources.

I tried cmake with -j1 and got the same result.

I’ll switch to use the pre-compiled binary then.

Just to clarify, it should be possible to build ROOT (EDIT: and therefore cling) on typical desktop resources. @Axel built ROOT on raspberry pi, and @hahnjo on RISC-V! :smiley:

I’m not sure what the underlying problem here is :confused:

Hi @pundemonium, just to confirm - you are building Cling standalone, not full ROOT? Which CMAKE_BUILD_TYPE did you pass? For Debug you will need a lot of memory, at least if you are using the default ld. Do you need debug symbols?

1 Like

Hi @hahnjo,

Thanks for the interest in my little problem.

Yes I’m building cling alone and not the full ROOT, if I understand things correctly.

I did use Debug, as you guessed. I first tried using Release but I run into the following error at 87% that I’m not equipped to tackle:

/home/shiqh/workspace/cling/src/tools/cling/lib/Interpreter/DeclUnloader.cpp: In member function ‘bool cling::DeclUnloader::VisitFunctionTemplateDecl(clang::FunctionTemplateDecl*)’:
/home/shiqh/workspace/cling/src/tools/cling/lib/Interpreter/DeclUnloader.cpp:944:55: error: ‘class clang::FunctionTemplateDecl’ has no member named ‘loaded_spec_begin’
944 | for (FunctionTemplateDecl::spec_iterator I = FTD->loaded_spec_begin(),

Then I switched to Debug to see if that gets me around the the problem. Which lead to my original post.

I think I only need the basic functionalities so any option works for me at the moment.

Ah yes, this is because the instructions to build Cling are out-of-date. We migrated to a fork of the LLVM monorepo (GitHub - root-project/llvm-project at cling-llvm13), updated build instructions are prepared in this PR: Update cling_build_instructions.md wrt monorepo by Axel-Naumann · Pull Request #870 · root-project/web · GitHub. In short you will need to clone llvm-project and then run something like


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.