Skip to content

Commit 3b8e3ca

Browse files
authored
Use ICF in macOS release builds to reduce binary sizes (#19615)
Inspired by denoland/deno#34478 Use `--icf=safe` for optimized macOS release artifacts, via Rust's bundled Mach-O LLD. Measurements showed useful size wins on macOS; Linux did not show a meaningful artifact-size improvement and are excluded here. See #19615 (comment)
1 parent 49db7f5 commit 3b8e3ca

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎.github/workflows/build-release-binaries.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ jobs:
112112
args: --release --locked --out dist --features self-update --compatibility pypi
113113
env:
114114
CARGO: ${{ github.workspace }}/scripts/cargo.sh
115+
# Use Rust's bundled Mach-O LLD, which supports ICF.
116+
# ICF reduces the macOS x86_64 uv binary size by ~2%.
117+
RUSTFLAGS: "-C linker=rust-lld -C linker-flavor=ld64.lld -C link-arg=--icf=safe"
115118
- name: "Upload wheels"
116119
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
117120
with:
@@ -145,6 +148,9 @@ jobs:
145148
args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
146149
env:
147150
CARGO: ${{ github.workspace }}/scripts/cargo.sh
151+
# Use Rust's bundled Mach-O LLD, which supports ICF.
152+
# ICF reduces the macOS x86_64 uv-build binary size by ~0.7%.
153+
RUSTFLAGS: "-C linker=rust-lld -C linker-flavor=ld64.lld -C link-arg=--icf=safe"
148154
- name: "Upload wheels uv-build"
149155
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
150156
with:
@@ -179,6 +185,9 @@ jobs:
179185
args: --release --locked --out dist --features self-update --compatibility pypi
180186
env:
181187
CARGO: ${{ github.workspace }}/scripts/cargo.sh
188+
# Use Rust's bundled Mach-O LLD, which supports ICF.
189+
# ICF reduces the macOS aarch64 uv binary size by ~1.4%.
190+
RUSTFLAGS: "-C linker=rust-lld -C linker-flavor=ld64.lld -C link-arg=--icf=safe"
182191
- name: "Test wheel - aarch64"
183192
run: |
184193
pip install ${PACKAGE_NAME} --no-index --find-links dist/ --force-reinstall
@@ -218,6 +227,9 @@ jobs:
218227
args: --profile minimal-size --locked --out crates/uv-build/dist -m crates/uv-build/Cargo.toml --compatibility pypi
219228
env:
220229
CARGO: ${{ github.workspace }}/scripts/cargo.sh
230+
# Use Rust's bundled Mach-O LLD, which supports ICF.
231+
# ICF reduces the macOS aarch64 uv-build binary size by ~0.7%.
232+
RUSTFLAGS: "-C linker=rust-lld -C linker-flavor=ld64.lld -C link-arg=--icf=safe"
221233
- name: "Test wheel - aarch64"
222234
run: |
223235
pip install ${PACKAGE_NAME}_build --no-index --find-links crates/uv-build/dist --force-reinstall

0 commit comments

Comments
 (0)