# Out of memory compiling cling on WSL2

**URL:** <https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983>\
**Category:** Cling\
**Tags:** build\
**Created:** [August 9, 2023, 12:17pm UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983 "2023-08-09T12:17:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pundemonium](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@pundemonium](https://root-forum.cern.ch/u/pundemonium)\
**Post date:** [August 9, 2023, 12:17pm UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/1 "2023-08-09T12:17:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 9, 2023, 12:27pm UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/2 "2023-08-09T12:27:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 9, 2023, 12:30pm UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/3 "2023-08-09T12:30:56Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [August 9, 2023, 4:27pm UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/4 "2023-08-09T16:27:24Z")

</div>

Some instructions for ROOT on WSL2 can be found at [Complete ROOT Installation Instructions for WSL (Ubuntu 18.04 on Windows 10)](https://root-forum.cern.ch/t/complete-root-installation-instructions-for-wsl-ubuntu-18-04-on-windows-10/35148) (and other posts linked from there).  
As Bertrand mentions you should not need to compile ROOT from source.

---

<div class="post-metadata">

**Author:** ![pundemonium](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@pundemonium](https://root-forum.cern.ch/u/pundemonium)\
**Post date:** [August 10, 2023, 10:51am UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/5 "2023-08-10T10:51:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [August 10, 2023, 2:10pm UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/6 "2023-08-10T14:10:18Z")

</div>

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! 😃

I’m not sure what the underlying problem here is 😕

---

<div class="post-metadata">

**Author:** ![hahnjo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hahnjo/32/34077_2.png) [@hahnjo](https://root-forum.cern.ch/u/hahnjo)\
**Post date:** [August 10, 2023, 2:26pm UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/7 "2023-08-10T14:26:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pundemonium](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@pundemonium](https://root-forum.cern.ch/u/pundemonium)\
**Post date:** [August 14, 2023, 9:54am UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/8 "2023-08-14T09:54:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hahnjo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hahnjo/32/34077_2.png) [@hahnjo](https://root-forum.cern.ch/u/hahnjo)\
**Post date:** [August 14, 2023, 10:58am UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/9 "2023-08-14T10:58:47Z")

</div>

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](https://github.com/root-project/llvm-project/tree/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](https://github.com/root-project/web/pull/870). In short you will need to clone `llvm-project` and then run something like

```auto
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_TOOLS=Off -DLLVM_EXTERNAL_PROJECTS=cling -DLLVM_EXTERNAL_CLING_SOURCE_DIR=/path/to/cling/src -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD="host;NVPTX" /path/to/llvm-project/llvm

```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 28, 2023, 10:59am UTC](https://root-forum.cern.ch/t/out-of-memory-compiling-cling-on-wsl2/55983/10 "2023-08-28T10:59:32Z")

</div>

Closed on August 28, 2023, 10:59am UTC

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