#35197 guix: add -Wl,--icf=safe to darwin build
| Reviewability | Reviews | Agreement | Size | ||||
|---|---|---|---|---|---|---|---|
| #35197 guix: add -Wl,--icf=safe to darwin build | Ready | 0 (+1) | Blocked | 4 | |||
|
|
|
|
| |||
Reviewability: ReadyStalePaused Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs. Size: lines added or modified outside tests, then in tests; greener = smaller. | |||||||
Goal
Enables safe identical code folding (ICF) linker flags in CMakeLists.txt when supported by the linker and compiler. The build system probes for and appends -faddrsig alongside -Wl,--icf=safe or -Wl,--icf=safe_thunks to executable linker flags.
Problem: macOS release binaries contain redundant copies of identical compiled functions, increasing download sizes and disk footprint without functional benefit.
Evidence of importance:
- Author measurements in the description and commit message show binary size reductions of '~0.5mb' for bitcoind and '1.3mb' for bitcoin-qt on aarch64-apple-darwin.
Risk of a mistake: medium (build). Incorrect linker code folding could violate C++ function pointer uniqueness semantics or cause linking regressions across toolchains.
Changed since the previous assessment: Appended the -faddrsig compiler/linker flag to the ICF test strings to ensure address significance tables are emitted so safe ICF does not fold address-taken functions.
Reviewability
Ready
Nothing known that would invalidate a review now.
Waiting on (from the thread read):
- author: address the requirement of -faddrsig on Darwin and probe order, and respond to status inquiry 2026-09-21
Agreement
Blocked
objection that needs a change, nobody has replied (151henry151)
Thread notes: Added sedited's question regarding whether the PR should be drafted or what its status is. The PR remains waiting on the author to address the open correctness and probe order objections.
Objections, suggestions, and questions:
| Reviewer | Type | Harm, request, or question | Status | Must be | Author replied | Quote |
|---|---|---|---|---|---|---|
| Sjors (member) | objection, correctness | Without -faddrsig, --icf=safe on Mach-O targets behaves like --icf=all, breaking function pointer uniqueness and folding address-significant functions. | contested · demonstrated by multiple reviewers that Mach-O LLD requires -faddrsig to avoid unsafe folding · v1, not yet re-checked | changed | yes | 2026-05-15: 'My LLM friend thinks that `--icf=safe` is not actually safe, because without an address-significance table (`-faddrsig`) it's equivalent to `--icf=all`.' |
| theuni (member) | objection, maintenance | Enabling ICF only for Guix builds hides potential linker issues from developers building locally. | fixed · fix pushed · resolved by moving flags to general build · v1, not yet re-checked | answered | yes | 2026-05-20: 'I worry that if any linker tricks like this cause any trouble, we'd only see it in guix binaries.' Status from: 2026-07-03: fanquake: 'I've pulled this back out of REDUCE_EXPORTS, into the general flags.' |
| hebasto (member) | objection, approach | The linker flag probe order appends --icf=safe after --icf=safe_thunks, which causes safe to override safe_thunks on toolchains supporting both. | open · v1, not yet re-checked | answered | no | 2026-07-26: 'This prioritizes `--icf=safe` over `--icf=safe_thunks` on the linker command line. However, shouldn't it be the other way around, since `safe_thunks` does not rely on the address-significance table?' |
| 151henry151 (contributor) | objection, correctness | On the pinned Guix toolchain, LLD 19 Mach-O folds address-taken functions unless -faddrsig is passed across core and depends, corrupting dispatch tables and function identity. | open · v1, not yet re-checked | changed | no | 2026-07-30: 'Not an ACK in its current shape — on the pinned Guix toolchain, `--icf=safe` behaves like `--icf=all` for the Darwin release binaries. Adding `-faddrsig` fixes that and keeps most of the size win' |
Support:
- davidgumberg (member) (ACK, 2026-05-14) [tested]: nice win in binary sizes, with Guix size benchmarks showing ~5% savings across Darwin binaries
- hebasto (member) (Concept ACK, 2026-07-26) [read]: on using the "Identical Code Folding" linker feature where possible.
Participants:
- 0xB10C (member, neutral, 1 statements 2026-05-14 to 2026-05-14): provided Guix build hashes
- davidgumberg (member, support, 1 statements 2026-05-14 to 2026-05-14): ACKed with size benchmark measurements and Guix hashes
- sedited (member, neutral, 2 statements 2026-05-14 to 2026-09-21): provided Guix build hashes and asked about PR status/drafting
- Sjors (member, objection, 4 statements 2026-05-15 to 2026-07-10): demonstrated that --icf=safe without -faddrsig folds address-significant functions on Darwin
- theuni (member, objection, 2 statements 2026-05-20 to 2026-06-16): concerned that Guix-only linker flags would hide linker issues from developers; resolved by moving flags to general build
- hebasto (member, objection, 3 statements 2026-07-26 to 2026-07-26): Concept ACK on ICF, but objected that -faddrsig is required for Darwin and noted safe shadows safe_thunks in probe order
- 151henry151 (contributor, objection, 1 statements 2026-07-30 to 2026-07-30): not an ACK as-is; proved address-significant function folding on Darwin LLD 19 and analyzed probe order
Files
0 lines under test/bench/ci.
- CMakeLists.txt +4/-0
Card
The short text the ranking pass compares across PRs.
This pull request configures safe identical code folding linker flags (-Wl,--icf=safe / -Wl,--icf=safe_thunks with -faddrsig) in CMakeLists.txt. It reduces Darwin release binary sizes, saving roughly 0.5 MB on bitcoind and 1.3 MB on bitcoin-qt according to the author. The change primarily benefits macOS users downloading release binaries.
Data
thread read through 2026-09-21 (18 statements), head ee9f7dbf5f
Discussion read under schema 1 rules: suggestions and questions may be missing, and an objection may combine several harms (schema history).
labels: Build system · draft
Categories
Build and CI
P3 · speedup (ranking pass: Moved down from 26: binary-size optimization only, ranks with the other size-reduction PRs)
Reduces Darwin release binary sizes by approximately 5% (~0.5 MB for bitcoind and 1.3 MB for bitcoin-qt) by enabling safe identical code folding. While a clear and useful optimization for macOS distribution packages, it does not fix a build failure or address CI reliability, making it reasonably deferrable.
Membership: Matches the 'Build system' label and directly modifies CMakeLists.txt to configure Darwin linker flags.
Factors: security/stability 0, bug 0, performance 1, user value 1, leverage 0