Link error/OOM when rebuilding thunderbird

I am on nixos-25.05 branch in nixpkgs and try to (re-)build thunderbird (version 141.0) with a patch. But it always fails with a link error by lld:

$ nix build -L -f . thunderbird-unwrapped
...
thunderbird-unwrapped> /build/mozbuild/srcdirs/thunderbird-141.0-1c8fff0f7627/_virtualenvs/build/bin/python -m mozbuild.action.check_binary ../../../dist/bin/crashhelper
thunderbird-unwrapped> make[3]: Leaving directory '/build/thunderbird-141.0/objdir/toolkit/crashreporter/crash_helper'
thunderbird-unwrapped> /nix/store/s6cib4j1w7z35dhx80j722ib7csbwkq0-llvm-binutils-wrapper-19.1.7/bin/ld.lld: line 273: 35876 Killed                  /nix/store/qklx0lpaah79ypd9v6pihzw7l8dw2r5v-llvm-binutils-19.1.7/bin/ld.lld ${extraBefore+"${extraBefore[@]}"} ${params+"${params[@]}"} ${extraAfter+"${extraAfter[@]}"}
thunderbird-unwrapped> clang++: error: linker command failed with exit code 137 (use -v to see invocation)
...

It seems the nix-daemon process got OOM-killed:

$ journalctl
...
Aug 19 17:57:28 computer kernel: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=user.slice,mems_allowed=0,global_oom,task_memcg=/system.slice/nix-daemon.service,task=ld.lld,pid=1095786,uid=30001
Aug 19 17:57:28 computer kernel: Out of memory: Killed process 1095786 (ld.lld) total-vm:58096584kB, anon-rss:27165780kB, file-rss:2912kB, shmem-rss:1040kB, UID:30001 pgtables:105436kB oom_score_adj:0
Aug 19 17:57:28 computer systemd[1]: nix-daemon.service: A process of this unit has been killed by the OOM killer.
Aug 19 17:57:32 computer kernel: oom_reaper: reaped process 1095786 (ld.lld), now anon-rss:0kB, file-rss:0kB, shmem-rss:1040kB

How can I fix it?

I have 32 GB RAM and 40 GB swap. tmpfs space on /tmp seems big enough (total assigned 24GB, ~15 GB used during the build).

It seems the thunderbird build is extremely memory hungry. I increased the swap space by 15 GB and now the builds passes.

1 Like