Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

build(ci): use mold and ICF for Linux desktop builds

Steven Enamakel7aa7caafc752
diff --git a/.github/workflows/build-desktop.yml b/.github/workflows/build-desktop.yml
index 19bbdadc9f..14bffe55cc 100644
--- a/.github/workflows/build-desktop.yml
+++ b/.github/workflows/build-desktop.yml
@@ -218,7 +218,7 @@ jobs:
libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
libgbm1 libpango-1.0-0 libcairo2 libatspi2.0-0 libxshmfence1 libu2f-udev \
- xvfb dbus dbus-x11
+ xvfb dbus dbus-x11 mold
command -v xdg-mime >/dev/null 2>&1 \
|| { echo "::error::xdg-mime is still missing after installing xdg-utils"; exit 1; }
# NOTE: The post-build dump lives further down (after `cargo tauri build`)
@@ -431,6 +431,16 @@ jobs:
TAURI_CONFIG_OVERRIDE: ${{ steps.config-overrides.outputs.json }}
MATRIX_ARGS: ${{ matrix.settings.args }}
PROFILE_FLAG: ${{ inputs.build_profile == 'debug' && '--debug' || '' }}
+ # Linux only: link with mold and fold byte-identical functions. The
+ # release profile's 16 codegen units and cross-crate instantiation
+ # leave many identical copies of the same function; MSVC already
+ # folds them (/OPT:ICF) and Apple's ld deduplicates by default, GNU ld
+ # cannot. `safe` only folds functions whose address is never taken,
+ # so C code comparing function pointers (sqlite) is unaffected.
+ # Measured on openhuman-core: 99.9 -> 97.6 MiB stripped. Per-target
+ # variables only reach the `--target` build, never build scripts.
+ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: -C link-arg=-fuse-ld=mold -C link-arg=-Wl,--icf=safe
+ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS: -C link-arg=-fuse-ld=mold -C link-arg=-Wl,--icf=safe
run: |
# Inline NODE_OPTIONS so it reaches the vite child spawned by
# beforeBuildCommand. Step-level env was observed not to propagate