Skip to content

Arch Linux / AUR builds OOM on 16 GB systems during release linking (candle/wgpu + LTO) #1196

Closed

Description

@rajchauhan28

Description

When building lightcraft on Arch Linux via the AUR package (lightcraft-0.6.0-1) or when building release binaries from source on machines with 16 GB RAM and high CPU thread counts (e.g. 16–20 threads), the build consistently fails due to Out-Of-Memory kills (systemd-oomd / kernel OOM-killer) during the final linking step.

Environment

  • OS: Arch Linux / CachyOS (Linux 7.2.x)
  • CPU: Intel Core i5-13500HX (20 threads)
  • RAM: 16 GB RAM + 16 GB Swap/Zram
  • AUR Package: lightcraft 0.6.0-1 (Maintainer: Caleb Maclennan)

Cause of OOM

During cargo build --release, Cargo builds both lightcraft and lightcraft-cli concurrently. Because the workspace includes heavy dependencies (candle-core, wgpu, egui, liblightcraft_web.so), linking both binaries simultaneously requires substantial memory.

In the AUR package, the build environment also specifies:

export CARGO_PROFILE_RELEASE_DEBUG=2
export CARGO_PROFILE_RELEASE_STRIP=false
export CARGO_PROFILE_RELEASE_LTO=thin
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1

The combination of DEBUG=2 (generating massive DWARF symbols) and CODEGEN_UNITS=1 + LTO=thin causes rustc's codegen unit (lto cgu.0.rcgu.) to consume over 6–7 GB RSS per process. When both binaries link in parallel on a high-thread system, peak memory usage exceeds 10 GB RSS and 9 GB swap, triggering systemd-oomd and terminating the terminal session:

kernel: lto cgu.0.rcgu.: page allocation failure: order:0, mode:0xc0de0
systemd-oomd[1029]: Marked ... for killing due to memory used (16.4 GB) / total (16.4 GB) and swap used (14.8 GB) / total (16.4 GB) being more than 90.00%
systemd[1289]: app-ghostty-...scope: systemd-oomd killed 84 process(es) in this unit.
systemd[1289]: app-ghostty-...scope: Failed with result 'oom-kill'.

Resolution

The build succeeds reliably on 16 GB systems by:

  1. Limiting concurrent cargo jobs (e.g. CARGO_BUILD_JOBS=1 or 2) so both large binaries aren't linked simultaneously.
  2. Avoiding DEBUG=2 and CODEGEN_UNITS=1 with LTO on memory-constrained systems.

Opening this issue to:

  1. Document this behavior for users and downstream packagers building from source on machines with <= 16 GB RAM.
  2. Note for Arch Linux / AUR maintainers (such as Caleb Maclennan) to relax CARGO_PROFILE_RELEASE_DEBUG and CODEGEN_UNITS=1 or serialize binary linking in the PKGBUILD.

Activity

  1. aiongg commented on Oct 21, 2026

    @aiongg
    Contributor

    Documented in v0.8.0: README → low-memory release builds; the PKGBUILD change is for the AUR package.

  2. added a commit that references this issue on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions