rui314 / mold

Mold: A Modern Linker 🦠
MIT License
14.32k stars 470 forks source link

cosmic-applets, rust, out of memory when linking? #1319

Open soloturn opened 3 months ago

soloturn commented 3 months ago

on arch linux we use mold to build cosmic desktop. one component recently fails on 8gb and 16gb machines. could mold somehow influence the maximum memory consumption?

❯ mold --version
mold 2.32.1 (cf1c02d097fc57113b7f9fabf1bc15f810b8b27c; compatible with GNU ld)

   Compiling cosmic-applets v0.1.1 (/home/st/.cache/paru/clone/cosmic-applets-git/src/cosmic-applets/cosmic-applets)
error: could not compile `cosmic-applets` (bin "cosmic-applets")

Caused by:
  process didn't exit successfully: `/home/st/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name cosmic_applets --edition=2021 cosmic-applets/src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=238 --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto=fat --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=1714d28f32d7998a -C extra-filename=-1714d28f32d7998a --out-dir /home/st/tmp/mytarget/release/deps -C strip=debuginfo -L dependency=/home/st/tmp/mytarget/release/deps --extern cosmic_app_list=/home/st/tmp/mytarget/release/deps/libcosmic_app_list-9aa5c823b11137ee.rlib --extern cosmic_applet_audio=/home/st/tmp/mytarget/release/deps/libcosmic_applet_audio-d66167647dec577c.rlib --extern cosmic_applet_battery=/home/st/tmp/mytarget/release/deps/libcosmic_applet_battery-2fbcf21b270aa7d3.rlib --extern cosmic_applet_bluetooth=/home/st/tmp/mytarget/release/deps/libcosmic_applet_bluetooth-c67013728f7a7221.rlib --extern cosmic_applet_input_sources=/home/st/tmp/mytarget/release/deps/libcosmic_applet_input_sources-f051b1b5d0dadc5b.rlib --extern cosmic_applet_minimize=/home/st/tmp/mytarget/release/deps/libcosmic_applet_minimize-730da686a635d845.rlib --extern cosmic_applet_network=/home/st/tmp/mytarget/release/deps/libcosmic_applet_network-97a3fbd682855a58.rlib --extern cosmic_applet_notifications=/home/st/tmp/mytarget/release/deps/libcosmic_applet_notifications-770cfb52ed769988.rlib --extern cosmic_applet_power=/home/st/tmp/mytarget/release/deps/libcosmic_applet_power-620519937d8b0bf1.rlib --extern cosmic_applet_status_area=/home/st/tmp/mytarget/release/deps/libcosmic_applet_status_area-bf555c414b40656b.rlib --extern cosmic_applet_tiling=/home/st/tmp/mytarget/release/deps/libcosmic_applet_tiling-d675b9659f5381a7.rlib --extern cosmic_applet_time=/home/st/tmp/mytarget/release/deps/libcosmic_applet_time-33307896b06b81a0.rlib --extern cosmic_applet_workspaces=/home/st/tmp/mytarget/release/deps/libcosmic_applet_workspaces-84c08c05aabb2e4f.rlib --extern cosmic=/home/st/tmp/mytarget/release/deps/libcosmic-efd0b61af43bf72b.rlib --extern tracing=/home/st/tmp/mytarget/release/deps/libtracing-fffa4013ff0fe02a.rlib --extern tracing_log=/home/st/tmp/mytarget/release/deps/libtracing_log-766a4312b74fee07.rlib --extern tracing_subscriber=/home/st/tmp/mytarget/release/deps/libtracing_subscriber-814a7462278da83f.rlib -C link-arg=-fuse-ld=mold -L native=/usr/lib -L native=/usr/lib -L native=/usr/lib -L native=/usr/lib` (signal: 9, SIGKILL: kill)
error: Recipe `build-debug` failed on line 24 with exit code 101
==> ERROR: A failure occurred in build().
    Aborting...
error: failed to build 'cosmic-applets-git-r1047.d10bc47-1': 
error: packages failed to build: cosmic-applets-git-r1047.d10bc47-1
rui314 commented 3 months ago

The first thing I would try is to set the MOLD_JOBS environment variable to 1.

https://github.com/rui314/mold/blob/main/docs/mold.md#environment-variables

soloturn commented 3 months ago

on the 16gb machin this worked, have many thanks. on the 8gb machine same error again. this memory consumption changed in the last week(s) what might have caused it?

rui314 commented 3 months ago

I don't think I made a change to affect memory usage. Can you rebuild mold from the last week's commit to see if the mold memory usage really went up?

ptr1337 commented 3 months ago

on the 16gb machin this worked, have many thanks. on the 8gb machine same error again. this memory consumption changed in the last week(s) what might have caused it?

The cosmic compilation generally takes a lot of RAM, even without mold. I think you are just getting out of RAM and dont have a big enough Swap.

soloturn commented 3 months ago

when running, i only see rustc as a process, not mold. it runs out of memory when producing the cosmic-applets binary. i notice now that there are more links to it than before, and it is 69M. it is 2 times bigger than the next one in size from cosmic. why does it have such a high memory consumption, and what has such a high memory consumption, technically?

lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-app-list -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-audio -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-battery -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-bluetooth -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-input-sources -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-minimize -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-network -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-notifications -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-power -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-status-area -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-tiling -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-time -> /usr/bin/cosmic-applets
lrwxrwxrwx    - root 31 Jul 05:35 /usr/bin/cosmic-applet-workspaces -> /usr/bin/cosmic-applets
.rwxr-xr-x  69M root 31 Jul 05:35 /usr/bin/cosmic-applets
rui314 commented 3 months ago

I don't think I can debug it for you with that information. If it worked a few weeks ago and it's now broken, please try to bisect it to find out which commit broke your build.