--icf=safe Enable safe identical code folding.
This reduces the size of bitcoind by ~0.5mb, and bitcoin-qt by 1.3mb (aarch64-apple-darwin).
This option exists for lld, which is why it's only added for darwin builds.
--icf=safe Enable safe identical code folding.
This reduces the size of bitcoind by ~0.5mb, and bitcoin-qt by 1.3mb (aarch64-apple-darwin).
This option exists for lld, which is why it's only added for darwin builds.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35197.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline and AI policy for information on the review process.
| Type | Reviewers |
|---|---|
| Concept ACK | hebasto, 151henry151 |
| Stale ACK | davidgumberg |
If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
<!--85328a0da195eb286784d51f73fa0af9-->
π§ At least one of the CI tasks failed.
<sub>Task i686, no IPC: https://github.com/bitcoin/bitcoin/actions/runs/25275669000/job/74105140405</sub>
<sub>LLM reason (β¨ experimental): CI failed because the sock_tests test in the βBitcoin Core Test Suiteβ failed (ctest reported 1 failing test out of 296).</sub>
<details><summary>Hints</summary>
Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
</details>
ACK https://github.com/bitcoin/bitcoin/commit/aa3bbe2ea218c9645fe43d0df3aa2cbdf30a99cc
Seems reasonable to me, the only harm is this will introduce ambiguity in some cases when debugging/profiling release binaries[^1], but that seems fine to me, and it's a nice win in binary sizes, might be worth highlighting with a release note.
All sizes in bytes:
| Binary | Parent (aa3bbe2ea218^) | Branch (aa3bbe2ea218) | Size reduced | % of original size reduced |
|---|---|---|---|---|
| bitcoin | 209512 | 193040 | 16472 | -7.86% |
| bitcoin-cli | 3167072 | 2540328 | 626744 | -19.79% |
| bitcoind | 12551448 | 11940744 | 610704 | -4.87% |
| bitcoin-qt | 32420944 | 31097424 | 1323520 | -4.08% |
| bitcoin-tx | 2393064 | 2327088 | 65976 | -2.76% |
| bitcoin-util | 372088 | 355576 | 16512 | -4.44% |
| bitcoin-wallet | 4163212 | 4014652 | 148560 | -3.57% |
| Total | 55277340 | 52468852 | 2808488 | -5.08% |
| Binary | Parent (aa3bbe2ea218^) | Branch (aa3bbe2ea218) | Size reduced | % of original size reduced |
|---|---|---|---|---|
| bitcoin | 177056 | 164688 | 12368 | -6.99% |
| bitcoin-cli | 3273828 | 2688284 | 585544 | -17.89% |
| bitcoind | 13704300 | 13204764 | 499536 | -3.65% |
| bitcoin-qt | 35216384 | 34037176 | 1179208 | -3.35% |
| bitcoin-tx | 2663816 | 2606144 | 57672 | -2.17% |
| bitcoin-util | 478888 | 458296 | 20592 | -4.30% |
| bitcoin-wallet | 4528568 | 4408920 | 119648 | -2.64% |
| Total | 60042840 | 57568272 | 2474568 | -4.12% |
<details>
<summary>
This branch:
$ git checkout --detach aa3bbe2ea218c9645fe43d0df3aa2cbdf30a99cc
HEAD is now at aa3bbe2ea2 guix: add -Wl,--icf=safe to darwin build
$ ./contrib/guix/guix-build
$ source contrib/shell/git-utils.bash && uname -m && find guix-build-$(git_head_version)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
x86_64
55d2df2755f4533cb38d8cb13a02d5d3ff9f07416fb97597fc81679f610159ba guix-build-aa3bbe2ea218/output/aarch64-linux-gnu/SHA256SUMS.part
8d8861c3ffb2f841e4a6cd4c018d0f656f025fbc976be266f7532302bba26e36 guix-build-aa3bbe2ea218/output/aarch64-linux-gnu/bitcoin-aa3bbe2ea218-aarch64-linux-gnu-debug.tar.gz
fe2cd08a58db5da330e70eca9bd2a29f6922686f7cab9c36599a683da81a3c47 guix-build-aa3bbe2ea218/output/aarch64-linux-gnu/bitcoin-aa3bbe2ea218-aarch64-linux-gnu.tar.gz
89534395b221b0be8d076a34e147285b30636fe2fe4685df0c2ac5dd6244c8ae guix-build-aa3bbe2ea218/output/arm-linux-gnueabihf/SHA256SUMS.part
9fa95a8d0990d270965dde7ab6e4465221ef1693ee60a6c6ba3b02fe3602e058 guix-build-aa3bbe2ea218/output/arm-linux-gnueabihf/bitcoin-aa3bbe2ea218-arm-linux-gnueabihf-debug.tar.gz
0a58a126e4fc1150d76ec4ca9cd1fe864ccdaec1536055adb977c221801f2ef0 guix-build-aa3bbe2ea218/output/arm-linux-gnueabihf/bitcoin-aa3bbe2ea218-arm-linux-gnueabihf.tar.gz
5a5bb6f80eb68eff565767d039d523555e715c620705c3329d4e240073a84799 guix-build-aa3bbe2ea218/output/arm64-apple-darwin/SHA256SUMS.part
753b9cccd5a4c20f4da34183533a385c52454facf4cb30c11956c1c8df4023eb guix-build-aa3bbe2ea218/output/arm64-apple-darwin/bitcoin-aa3bbe2ea218-arm64-apple-darwin-codesigning.tar.gz
12b397bb76d18d5bd9cd21d91c78d64c58dc32b20823953f5f6909e40f26ef5b guix-build-aa3bbe2ea218/output/arm64-apple-darwin/bitcoin-aa3bbe2ea218-arm64-apple-darwin-unsigned.tar.gz
072d890fe500e86d59441778e8d1cc2b4a5a3bb5e1fa1fcaba443f713a2e3bb2 guix-build-aa3bbe2ea218/output/arm64-apple-darwin/bitcoin-aa3bbe2ea218-arm64-apple-darwin-unsigned.zip
16c8ec7d7f16dfa24c1dd2b1f72d02207be3769e8b7ae57e31fd3285a22bf9d0 guix-build-aa3bbe2ea218/output/dist-archive/bitcoin-aa3bbe2ea218.tar.gz
a321e30a01ee92115eccd85e2dfc04a0853939a7396854e93d530f9bc7dd5feb guix-build-aa3bbe2ea218/output/powerpc64-linux-gnu/SHA256SUMS.part
fcc07d881190898c1b5ec62d128ea1c920ab5b93141b27f5cbc4bbffdb955ae2 guix-build-aa3bbe2ea218/output/powerpc64-linux-gnu/bitcoin-aa3bbe2ea218-powerpc64-linux-gnu-debug.tar.gz
d294b23f21efcb42b80cca6517a8ade2f551ff91cba9a1087551ebafefc5b579 guix-build-aa3bbe2ea218/output/powerpc64-linux-gnu/bitcoin-aa3bbe2ea218-powerpc64-linux-gnu.tar.gz
7d767fd902ce82b913c232079125fb39e50a7fd3ea8716de53cd5e43f9097135 guix-build-aa3bbe2ea218/output/riscv64-linux-gnu/SHA256SUMS.part
d6d9e2f7857e6ee07a3de4eb62f389210ec675a96f79da32870f49d4426a5800 guix-build-aa3bbe2ea218/output/riscv64-linux-gnu/bitcoin-aa3bbe2ea218-riscv64-linux-gnu-debug.tar.gz
645437534011d3379e78ea2e725eb981c9239a54b2074c4dc475d666673e61fc guix-build-aa3bbe2ea218/output/riscv64-linux-gnu/bitcoin-aa3bbe2ea218-riscv64-linux-gnu.tar.gz
96bcf9374a0bac414c93ee7b10562dafee4b1ab8e6e26c70455de9ab895d4699 guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/SHA256SUMS.part
a9b28e8b47c4a4763d884b35bda7d762baea62012b8a84d140052de1419fec9f guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/bitcoin-aa3bbe2ea218-x86_64-apple-darwin-codesigning.tar.gz
99a3c91cfb265ee54b92994a756f02da3a17c470b78ea449283b7ae331d80e0d guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/bitcoin-aa3bbe2ea218-x86_64-apple-darwin-unsigned.tar.gz
b6378480d9340b3ea7359fd36a1e5d2596bd61b4f55af2c35bb66946aa8b9ea5 guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/bitcoin-aa3bbe2ea218-x86_64-apple-darwin-unsigned.zip
87d286a7d7a1a9d3314bdb119459c0929f8bd07a0b1057f142ef56de0ff03173 guix-build-aa3bbe2ea218/output/x86_64-linux-gnu/SHA256SUMS.part
6bfec675c208926dc3a724b14a6243a04775973f756c28c0e6381e98b31c990b guix-build-aa3bbe2ea218/output/x86_64-linux-gnu/bitcoin-aa3bbe2ea218-x86_64-linux-gnu-debug.tar.gz
0deba9d8d6f822a46e0402bd4dd45ca1aaec3b2beda968078e9f80c8f1ed9fb5 guix-build-aa3bbe2ea218/output/x86_64-linux-gnu/bitcoin-aa3bbe2ea218-x86_64-linux-gnu.tar.gz
501de61ed069dc2cb870f6b24233add5cf615b590163a3147557d89f9a8f2c98 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/SHA256SUMS.part
64613dafb19a609574f3c2357aa5f7f8c6e596052a28d5b75fd1cb99229a82b2 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-codesigning.tar.gz
b21b5f257847361ea46236eadc46f2fba5203ce3ce9404bcaa8b0784cdd6395d guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-debug.zip
85f42938bc43eae94561b8b0ad929256b10015883538abc0a4c72568d38dbda0 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-setup-unsigned.exe
d1cc3f18e7fbd064e593b8a15548bee9dc23a5d2e00ad1eaf7629f3780988497 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-unsigned.zip
Parent of this branch:
$ git checkout --detach aa3bbe2ea218c9645fe43d0df3aa2cbdf30a99cc^
Previous HEAD position was aa3bbe2ea2 guix: add -Wl,--icf=safe to darwin build
HEAD is now at ccbd00ab87 Merge bitcoin/bitcoin#35152: doc: clarify local IWYU workflow and pragmas
x86_64
$ ./contrib/guix/guix-build
$ source contrib/shell/git-utils.bash && uname -m && find guix-build-$(git_head_version)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
x86_64
6f01954a6da43e5030fb657bef9205e4a2e0b8570118057d1ef462945667c1ff guix-build-ccbd00ab87c0/output/aarch64-linux-gnu/SHA256SUMS.part
c1f705dbfa1a7a0448520e4b33beed49c3d7bc5c8aa0260fb3d1ea0e9fa6b738 guix-build-ccbd00ab87c0/output/aarch64-linux-gnu/bitcoin-ccbd00ab87c0-aarch64-linux-gnu-debug.tar.gz
86f8807beb480ad9e498e8f3f188da2691043f57eacc13b938d820bc2104a4f5 guix-build-ccbd00ab87c0/output/aarch64-linux-gnu/bitcoin-ccbd00ab87c0-aarch64-linux-gnu.tar.gz
e593543795635ad4abe6457cf4a644f64513bdf2353b86c91bfb42700ea645ab guix-build-ccbd00ab87c0/output/arm-linux-gnueabihf/SHA256SUMS.part
c9490fbd2d3257e3ac5e68952a1b285c41215e8cc9854bd5fe109a179f660fc6 guix-build-ccbd00ab87c0/output/arm-linux-gnueabihf/bitcoin-ccbd00ab87c0-arm-linux-gnueabihf-debug.tar.gz
33c048240c8e39e997c99f5f1ad65ffadcfa87a27efa4d8cc31480c52df0a31e guix-build-ccbd00ab87c0/output/arm-linux-gnueabihf/bitcoin-ccbd00ab87c0-arm-linux-gnueabihf.tar.gz
836c5266792a1af4bbbd41cbd64e6e39cbb5ae07f24bddc4361aec865e93edf0 guix-build-ccbd00ab87c0/output/arm64-apple-darwin/SHA256SUMS.part
35037e8539e06b0295a500738972adfd51ce19714735c27a60f9e9152a117458 guix-build-ccbd00ab87c0/output/arm64-apple-darwin/bitcoin-ccbd00ab87c0-arm64-apple-darwin-codesigning.tar.gz
f0e207e846478dbac5369c446968a845095d0a446279d12fc0ee12b1c122bc92 guix-build-ccbd00ab87c0/output/arm64-apple-darwin/bitcoin-ccbd00ab87c0-arm64-apple-darwin-unsigned.tar.gz
6a1c2a10d64be5e8ebafb95ab4bd6fd660ff799e179f1bf4580fa5ac12235382 guix-build-ccbd00ab87c0/output/arm64-apple-darwin/bitcoin-ccbd00ab87c0-arm64-apple-darwin-unsigned.zip
6970241efc463e6d6c381552d0441371ccacf8ce2ff33d8e02d45d8cc8c06bdb guix-build-ccbd00ab87c0/output/dist-archive/bitcoin-ccbd00ab87c0.tar.gz
566ea369d7bce1181312dfb59786e18eaa71b926d90eea4dd71fbdf39f515954 guix-build-ccbd00ab87c0/output/powerpc64-linux-gnu/SHA256SUMS.part
f5abb3102db6f4b3190401fa53ebe9d7ce5ee7cc77d287f2c2427361255d4f2d guix-build-ccbd00ab87c0/output/powerpc64-linux-gnu/bitcoin-ccbd00ab87c0-powerpc64-linux-gnu-debug.tar.gz
083e483c8acacf5917c562482c1542ade311694a0d55242ac741362e47efc3c2 guix-build-ccbd00ab87c0/output/powerpc64-linux-gnu/bitcoin-ccbd00ab87c0-powerpc64-linux-gnu.tar.gz
f60d0fcab94d8a31bf3425b826ce846288c3dd67bc00cd9786ee4422c8e325f0 guix-build-ccbd00ab87c0/output/riscv64-linux-gnu/SHA256SUMS.part
81dc5307effbbc1bae53a716c479fee4ad17e7509a1104c6f600007409c41f58 guix-build-ccbd00ab87c0/output/riscv64-linux-gnu/bitcoin-ccbd00ab87c0-riscv64-linux-gnu-debug.tar.gz
418bbed5862d9580ab883c4680de72b3baff174698e2ddd70401137d47a73286 guix-build-ccbd00ab87c0/output/riscv64-linux-gnu/bitcoin-ccbd00ab87c0-riscv64-linux-gnu.tar.gz
3d7d4ef5f6e5249a7dca655d876fda778a5db8da93db2151841c2110f93fbfb1 guix-build-ccbd00ab87c0/output/x86_64-apple-darwin/SHA256SUMS.part
7b6fafd0fff00dde6c20472d303af8e855186ee800733d137e1d10cd26fca320 guix-build-ccbd00ab87c0/output/x86_64-apple-darwin/bitcoin-ccbd00ab87c0-x86_64-apple-darwin-codesigning.tar.gz
3833fcb1f92a47a4dc8aca6d78d2e7bdb6a397add6cb2a915261337e096b3e9a guix-build-ccbd00ab87c0/output/x86_64-apple-darwin/bitcoin-ccbd00ab87c0-x86_64-apple-darwin-unsigned.tar.gz
dd5387f86e2ef96bbd4fd7df123e1db1c682a86de2c74df6b4db576608f0d920 guix-build-ccbd00ab87c0/output/x86_64-apple-darwin/bitcoin-ccbd00ab87c0-x86_64-apple-darwin-unsigned.zip
230942ba6fcf51284ea0c3a2938c99941468889608deac3dc244bf5ee66109d4 guix-build-ccbd00ab87c0/output/x86_64-linux-gnu/SHA256SUMS.part
e742b6cf36cc3b67fcc21ad81595a9af5d92bff9b42422ee1a25fc687300360f guix-build-ccbd00ab87c0/output/x86_64-linux-gnu/bitcoin-ccbd00ab87c0-x86_64-linux-gnu-debug.tar.gz
3d464ea0075b1a4f6f636142bae079913c350e38554d37dab2c27674ba3db40f guix-build-ccbd00ab87c0/output/x86_64-linux-gnu/bitcoin-ccbd00ab87c0-x86_64-linux-gnu.tar.gz
6abf1ed4ac46caaeb195bb138bc2464cdfb75dc87a71dc4bb71cb8ce6139cf67 guix-build-ccbd00ab87c0/output/x86_64-w64-mingw32/SHA256SUMS.part
f6c5969dc830a5916b5a166096d9374f787534da7c1026d6060032effc5df9c3 guix-build-ccbd00ab87c0/output/x86_64-w64-mingw32/bitcoin-ccbd00ab87c0-win64-codesigning.tar.gz
eebc0a0a58585056fba7b3d1aee3fed231ba2de7acc191a88867b2f5643e8de9 guix-build-ccbd00ab87c0/output/x86_64-w64-mingw32/bitcoin-ccbd00ab87c0-win64-debug.zip
a9c0578c04efb43dca5b8206649e8d25ed7ea3da5386890df1d1563acdf1105f guix-build-ccbd00ab87c0/output/x86_64-w64-mingw32/bitcoin-ccbd00ab87c0-win64-setup-unsigned.exe
c3f147cb64e7c5be56749ff764620b00356180ed372ca4f696619fcf4be99ce6 guix-build-ccbd00ab87c0/output/x86_64-w64-mingw32/bitcoin-ccbd00ab87c0-win64-unsigned.zip
</details>
[^1]: From the Safe ICF paper (https://static.googleusercontent.com/media/research.google.com/en/us/pubs/archive/36912.pdf) : "profiling and debugging binaries with merged functions can be confusing, as the PC values of merged functions cannot be always disambiguated to point to the correct function." The paper proposes a mitigation but my (limited) understanding is that this is not implemented anywhere.
Guix build (aarch64):
55d2df2755f4533cb38d8cb13a02d5d3ff9f07416fb97597fc81679f610159ba guix-build-aa3bbe2ea218/output/aarch64-linux-gnu/SHA256SUMS.part
8d8861c3ffb2f841e4a6cd4c018d0f656f025fbc976be266f7532302bba26e36 guix-build-aa3bbe2ea218/output/aarch64-linux-gnu/bitcoin-aa3bbe2ea218-aarch64-linux-gnu-debug.tar.gz
fe2cd08a58db5da330e70eca9bd2a29f6922686f7cab9c36599a683da81a3c47 guix-build-aa3bbe2ea218/output/aarch64-linux-gnu/bitcoin-aa3bbe2ea218-aarch64-linux-gnu.tar.gz
89534395b221b0be8d076a34e147285b30636fe2fe4685df0c2ac5dd6244c8ae guix-build-aa3bbe2ea218/output/arm-linux-gnueabihf/SHA256SUMS.part
9fa95a8d0990d270965dde7ab6e4465221ef1693ee60a6c6ba3b02fe3602e058 guix-build-aa3bbe2ea218/output/arm-linux-gnueabihf/bitcoin-aa3bbe2ea218-arm-linux-gnueabihf-debug.tar.gz
0a58a126e4fc1150d76ec4ca9cd1fe864ccdaec1536055adb977c221801f2ef0 guix-build-aa3bbe2ea218/output/arm-linux-gnueabihf/bitcoin-aa3bbe2ea218-arm-linux-gnueabihf.tar.gz
5a5bb6f80eb68eff565767d039d523555e715c620705c3329d4e240073a84799 guix-build-aa3bbe2ea218/output/arm64-apple-darwin/SHA256SUMS.part
753b9cccd5a4c20f4da34183533a385c52454facf4cb30c11956c1c8df4023eb guix-build-aa3bbe2ea218/output/arm64-apple-darwin/bitcoin-aa3bbe2ea218-arm64-apple-darwin-codesigning.tar.gz
12b397bb76d18d5bd9cd21d91c78d64c58dc32b20823953f5f6909e40f26ef5b guix-build-aa3bbe2ea218/output/arm64-apple-darwin/bitcoin-aa3bbe2ea218-arm64-apple-darwin-unsigned.tar.gz
072d890fe500e86d59441778e8d1cc2b4a5a3bb5e1fa1fcaba443f713a2e3bb2 guix-build-aa3bbe2ea218/output/arm64-apple-darwin/bitcoin-aa3bbe2ea218-arm64-apple-darwin-unsigned.zip
16c8ec7d7f16dfa24c1dd2b1f72d02207be3769e8b7ae57e31fd3285a22bf9d0 guix-build-aa3bbe2ea218/output/dist-archive/bitcoin-aa3bbe2ea218.tar.gz
a321e30a01ee92115eccd85e2dfc04a0853939a7396854e93d530f9bc7dd5feb guix-build-aa3bbe2ea218/output/powerpc64-linux-gnu/SHA256SUMS.part
fcc07d881190898c1b5ec62d128ea1c920ab5b93141b27f5cbc4bbffdb955ae2 guix-build-aa3bbe2ea218/output/powerpc64-linux-gnu/bitcoin-aa3bbe2ea218-powerpc64-linux-gnu-debug.tar.gz
d294b23f21efcb42b80cca6517a8ade2f551ff91cba9a1087551ebafefc5b579 guix-build-aa3bbe2ea218/output/powerpc64-linux-gnu/bitcoin-aa3bbe2ea218-powerpc64-linux-gnu.tar.gz
7d767fd902ce82b913c232079125fb39e50a7fd3ea8716de53cd5e43f9097135 guix-build-aa3bbe2ea218/output/riscv64-linux-gnu/SHA256SUMS.part
d6d9e2f7857e6ee07a3de4eb62f389210ec675a96f79da32870f49d4426a5800 guix-build-aa3bbe2ea218/output/riscv64-linux-gnu/bitcoin-aa3bbe2ea218-riscv64-linux-gnu-debug.tar.gz
645437534011d3379e78ea2e725eb981c9239a54b2074c4dc475d666673e61fc guix-build-aa3bbe2ea218/output/riscv64-linux-gnu/bitcoin-aa3bbe2ea218-riscv64-linux-gnu.tar.gz
96bcf9374a0bac414c93ee7b10562dafee4b1ab8e6e26c70455de9ab895d4699 guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/SHA256SUMS.part
a9b28e8b47c4a4763d884b35bda7d762baea62012b8a84d140052de1419fec9f guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/bitcoin-aa3bbe2ea218-x86_64-apple-darwin-codesigning.tar.gz
99a3c91cfb265ee54b92994a756f02da3a17c470b78ea449283b7ae331d80e0d guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/bitcoin-aa3bbe2ea218-x86_64-apple-darwin-unsigned.tar.gz
b6378480d9340b3ea7359fd36a1e5d2596bd61b4f55af2c35bb66946aa8b9ea5 guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/bitcoin-aa3bbe2ea218-x86_64-apple-darwin-unsigned.zip
87d286a7d7a1a9d3314bdb119459c0929f8bd07a0b1057f142ef56de0ff03173 guix-build-aa3bbe2ea218/output/x86_64-linux-gnu/SHA256SUMS.part
6bfec675c208926dc3a724b14a6243a04775973f756c28c0e6381e98b31c990b guix-build-aa3bbe2ea218/output/x86_64-linux-gnu/bitcoin-aa3bbe2ea218-x86_64-linux-gnu-debug.tar.gz
0deba9d8d6f822a46e0402bd4dd45ca1aaec3b2beda968078e9f80c8f1ed9fb5 guix-build-aa3bbe2ea218/output/x86_64-linux-gnu/bitcoin-aa3bbe2ea218-x86_64-linux-gnu.tar.gz
501de61ed069dc2cb870f6b24233add5cf615b590163a3147557d89f9a8f2c98 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/SHA256SUMS.part
64613dafb19a609574f3c2357aa5f7f8c6e596052a28d5b75fd1cb99229a82b2 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-codesigning.tar.gz
b21b5f257847361ea46236eadc46f2fba5203ce3ce9404bcaa8b0784cdd6395d guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-debug.zip
85f42938bc43eae94561b8b0ad929256b10015883538abc0a4c72568d38dbda0 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-setup-unsigned.exe
d1cc3f18e7fbd064e593b8a15548bee9dc23a5d2e00ad1eaf7629f3780988497 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-unsigned.zip
x86_64
55d2df2755f4533cb38d8cb13a02d5d3ff9f07416fb97597fc81679f610159ba guix-build-aa3bbe2ea218/output/aarch64-linux-gnu/SHA256SUMS.part
8d8861c3ffb2f841e4a6cd4c018d0f656f025fbc976be266f7532302bba26e36 guix-build-aa3bbe2ea218/output/aarch64-linux-gnu/bitcoin-aa3bbe2ea218-aarch64-linux-gnu-debug.tar.gz
fe2cd08a58db5da330e70eca9bd2a29f6922686f7cab9c36599a683da81a3c47 guix-build-aa3bbe2ea218/output/aarch64-linux-gnu/bitcoin-aa3bbe2ea218-aarch64-linux-gnu.tar.gz
89534395b221b0be8d076a34e147285b30636fe2fe4685df0c2ac5dd6244c8ae guix-build-aa3bbe2ea218/output/arm-linux-gnueabihf/SHA256SUMS.part
9fa95a8d0990d270965dde7ab6e4465221ef1693ee60a6c6ba3b02fe3602e058 guix-build-aa3bbe2ea218/output/arm-linux-gnueabihf/bitcoin-aa3bbe2ea218-arm-linux-gnueabihf-debug.tar.gz
0a58a126e4fc1150d76ec4ca9cd1fe864ccdaec1536055adb977c221801f2ef0 guix-build-aa3bbe2ea218/output/arm-linux-gnueabihf/bitcoin-aa3bbe2ea218-arm-linux-gnueabihf.tar.gz
5a5bb6f80eb68eff565767d039d523555e715c620705c3329d4e240073a84799 guix-build-aa3bbe2ea218/output/arm64-apple-darwin/SHA256SUMS.part
753b9cccd5a4c20f4da34183533a385c52454facf4cb30c11956c1c8df4023eb guix-build-aa3bbe2ea218/output/arm64-apple-darwin/bitcoin-aa3bbe2ea218-arm64-apple-darwin-codesigning.tar.gz
12b397bb76d18d5bd9cd21d91c78d64c58dc32b20823953f5f6909e40f26ef5b guix-build-aa3bbe2ea218/output/arm64-apple-darwin/bitcoin-aa3bbe2ea218-arm64-apple-darwin-unsigned.tar.gz
072d890fe500e86d59441778e8d1cc2b4a5a3bb5e1fa1fcaba443f713a2e3bb2 guix-build-aa3bbe2ea218/output/arm64-apple-darwin/bitcoin-aa3bbe2ea218-arm64-apple-darwin-unsigned.zip
16c8ec7d7f16dfa24c1dd2b1f72d02207be3769e8b7ae57e31fd3285a22bf9d0 guix-build-aa3bbe2ea218/output/dist-archive/bitcoin-aa3bbe2ea218.tar.gz
a321e30a01ee92115eccd85e2dfc04a0853939a7396854e93d530f9bc7dd5feb guix-build-aa3bbe2ea218/output/powerpc64-linux-gnu/SHA256SUMS.part
fcc07d881190898c1b5ec62d128ea1c920ab5b93141b27f5cbc4bbffdb955ae2 guix-build-aa3bbe2ea218/output/powerpc64-linux-gnu/bitcoin-aa3bbe2ea218-powerpc64-linux-gnu-debug.tar.gz
d294b23f21efcb42b80cca6517a8ade2f551ff91cba9a1087551ebafefc5b579 guix-build-aa3bbe2ea218/output/powerpc64-linux-gnu/bitcoin-aa3bbe2ea218-powerpc64-linux-gnu.tar.gz
7d767fd902ce82b913c232079125fb39e50a7fd3ea8716de53cd5e43f9097135 guix-build-aa3bbe2ea218/output/riscv64-linux-gnu/SHA256SUMS.part
d6d9e2f7857e6ee07a3de4eb62f389210ec675a96f79da32870f49d4426a5800 guix-build-aa3bbe2ea218/output/riscv64-linux-gnu/bitcoin-aa3bbe2ea218-riscv64-linux-gnu-debug.tar.gz
645437534011d3379e78ea2e725eb981c9239a54b2074c4dc475d666673e61fc guix-build-aa3bbe2ea218/output/riscv64-linux-gnu/bitcoin-aa3bbe2ea218-riscv64-linux-gnu.tar.gz
96bcf9374a0bac414c93ee7b10562dafee4b1ab8e6e26c70455de9ab895d4699 guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/SHA256SUMS.part
a9b28e8b47c4a4763d884b35bda7d762baea62012b8a84d140052de1419fec9f guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/bitcoin-aa3bbe2ea218-x86_64-apple-darwin-codesigning.tar.gz
99a3c91cfb265ee54b92994a756f02da3a17c470b78ea449283b7ae331d80e0d guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/bitcoin-aa3bbe2ea218-x86_64-apple-darwin-unsigned.tar.gz
b6378480d9340b3ea7359fd36a1e5d2596bd61b4f55af2c35bb66946aa8b9ea5 guix-build-aa3bbe2ea218/output/x86_64-apple-darwin/bitcoin-aa3bbe2ea218-x86_64-apple-darwin-unsigned.zip
87d286a7d7a1a9d3314bdb119459c0929f8bd07a0b1057f142ef56de0ff03173 guix-build-aa3bbe2ea218/output/x86_64-linux-gnu/SHA256SUMS.part
6bfec675c208926dc3a724b14a6243a04775973f756c28c0e6381e98b31c990b guix-build-aa3bbe2ea218/output/x86_64-linux-gnu/bitcoin-aa3bbe2ea218-x86_64-linux-gnu-debug.tar.gz
0deba9d8d6f822a46e0402bd4dd45ca1aaec3b2beda968078e9f80c8f1ed9fb5 guix-build-aa3bbe2ea218/output/x86_64-linux-gnu/bitcoin-aa3bbe2ea218-x86_64-linux-gnu.tar.gz
501de61ed069dc2cb870f6b24233add5cf615b590163a3147557d89f9a8f2c98 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/SHA256SUMS.part
64613dafb19a609574f3c2357aa5f7f8c6e596052a28d5b75fd1cb99229a82b2 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-codesigning.tar.gz
b21b5f257847361ea46236eadc46f2fba5203ce3ce9404bcaa8b0784cdd6395d guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-debug.zip
85f42938bc43eae94561b8b0ad929256b10015883538abc0a4c72568d38dbda0 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-setup-unsigned.exe
d1cc3f18e7fbd064e593b8a15548bee9dc23a5d2e00ad1eaf7629f3780988497 guix-build-aa3bbe2ea218/output/x86_64-w64-mingw32/bitcoin-aa3bbe2ea218-win64-unsigned.zip
Same x86_64 hashes a @0xB10C and @davidgumberg above.
Lightly tested the binary on a MacBook Pro M4 with macOS 26.4.1.
I tried a build with --icf=all too, but there's no size difference (for arm64)
My LLM friend thinks that --icf=safe is not actually safe, because without an address-significance table (-faddrsig) it's equivalent to --icf=all.
Fresh numbers from the rebuilt artifacts:
| variant | commit | bin/ total |
libexec/ total |
tar.gz savings |
|---|---|---|---|---|
master @ ccbd00ab87c0 |
ccbd00ab87c09779e9edc589af6df5c967687a2f | 55,277,340 | 76,844,864 | 0.00 MB |
-faddrsig --icf=safe |
55ea6999c8618438649800c674faee721278169b | 52,617,668 | 72,106,840 | 1.84 MB |
--icf=all |
22d9baefb1af13300d5d6f423a6ffc28b1218428 | 52,468,852 | 71,892,200 | 1.92 MB |
-faddrsig --icf=all |
64bb33a8ab0846698982143e8e16b51848c9e617 | 52,468,852 | 71,892,200 | 1.92 MB |
--icf=safe |
aa3bbe2ea218c9645fe43d0df3aa2cbdf30a99cc | 52,468,852 | 71,892,200 | 1.92 MB |
Branch with the above combinations: codex/icf-combinations
Update: numbers are for HOSTS="arm64-apple-darwin"
address-significance table (-faddrsig)
Can you elaborate? According to what you linked, -faddrsig only has an effect on ELF targets. We are only using the flag for Darwin (MACHO) targets here.
I don't know, but the table shows a difference between just --icf=safe and -faddrsig --icf=safe for the macOS arm64 target (I updated my comment above to specify arm64-apple-darwin).
I had it generate an example:
void f(void) {}
void g(void) {}
void (*p)(void) = f;
int main(void) { return p == g; }
<details><summary>Try this on a guix machine:</summary>
mkdir -p tmp/addrsig-check
HOST=arm64-apple-darwin \
guix time-machine \
--url=https://codeberg.org/guix/guix.git \
--commit=c5eee3336cc1d10a3cc1c97fde2809c3451624d3 \
-- shell \
--manifest=contrib/guix/manifest.scm \
--pure \
-- bash -lc '
set -eu
cat > tmp/addrsig-check/test.c <<EOF
void f(void) {}
void g(void) {}
void (*p)(void) = f;
int main(void) { return p == g; }
EOF
clang --target=arm64-apple-darwin -c tmp/addrsig-check/test.c -o tmp/addrsig-check/no-addrsig.o
clang --target=arm64-apple-darwin -faddrsig -c tmp/addrsig-check/test.c -o tmp/addrsig-check/with-addrsig.o
echo "clang version:"
clang --version | head -1
echo
echo "driver passes -faddrsig to cc1:"
clang --target=arm64-apple-darwin -faddrsig -### -c tmp/addrsig-check/test.c -o /dev/null 2>&1 | grep -- -faddrsig || true
echo
echo "without -faddrsig:"
llvm-objdump --macho --section-headers tmp/addrsig-check/no-addrsig.o | grep llvm_addrsig || true
echo
echo "with -faddrsig:"
llvm-objdump --macho --section-headers tmp/addrsig-check/with-addrsig.o | grep llvm_addrsig || true
'
</details>
It outputs:
without -faddrsig:
with -faddrsig:
3 __llvm_addrsig 00000008 0000000000000098 DATA
So I guess that help page I linked to is wrong.
Hmm. A few things...
-ffunction-sections. Weirdly, (using x86-64-linux as a test) I don't see any difference with that vs -fno-function-sections. I can't explain that.-ffunction-sections I see mostly removals of .gcc_except_table.*. From a quick search, that seems fine.My main concern though.. why not add this to CMakeLists.txt and turn it on by default? I worry that if any linker tricks like this cause any trouble, we'd only see it in guix binaries.
My main concern though.. why not add this to CMakeLists.txt and turn it on by default?
One reason is that it could have side-effects for debug builds. Do you see this being rolled into REDUCE_EXPORTS (although I feel like it'd been discussed to remove that entirely)? There's also a (newer) --icf=safe_thunks, which we could test/use specifically for arm64 darwin, and then test/use --icf=safe generically for any other target that supports it.
Hmm, that's tempting, but I'm not sure we want to conflate those things. Especially if, as you mention, we might eventually just get rid of the option and make the REDUCE_EXPORTS behavior default.
For darwin, there's now --keep-icf-stabs, which would (in theory) make it safe to turn on for everyone.
Sadly, I don't see an equivalent for ELF targets :(
I've pulled this back out of REDUCE_EXPORTS, into the general flags. We try safe_thunks first, and then try safe.
> --icf=safe
> Enable safe identical code folding.
This reduces the size of (release) bitcoind by ~0.5mb, and bitcoin-qt
by 1.3mb (aarch64-apple-darwin).
I wrote earlier:
My LLM friend thinks that
--icf=safeis not actually safe, because without an address-significance table (-faddrsig) it's equivalent to--icf=all.
That seems to be fixed here: https://github.com/llvm/llvm-project/pull/188400
MachO --icf=safe and --icf=safe_thunks used to keep folding code from object files that did not contain __llvm_addrsig, which was inconsistent with the conservative ELF/COFF behavior. Mark all symbols in such objects as address-significant instead, and add regression coverage for both safe ICF modes with and without addrsig. @fanquake wrote:
According to what you linked,
-faddrsigonly has an effect on ELF targets. We are only using the flag for Darwin (MACHO) targets here.
It does, since https://reviews.llvm.org/D123751
Implement support for __llvm_addrsig for MachO in llvm-mc
The issue applies to both safe_thunks and safe, so still relevant as of 24ad7419dea40e647b10791105a0659df143e014.
Maybe it's not realistic to actually run into this, but <details><summary>if you throw enough tokens at it:</summary>
On the guix machine:
mkdir -p ~/icf-demo
Add audit.h:
#pragma once
using Validator = bool (*)(const char*);
namespace reqlib {
//! The library's built-in default policy.
bool PermitAll(const char*);
void SetValidator(Validator v);
//! Returns true if the audit trail was wrongly skipped.
bool HandleRequest(const char* req);
} // namespace reqlib
Add lib.cpp:
#include "audit.h"
#include <cstdio>
namespace reqlib {
bool PermitAll(const char*) { return true; }
static Validator g_validator{PermitAll};
void SetValidator(Validator v) { g_validator = v; }
bool HandleRequest(const char* req)
{
// Fast path: the built-in default needs no audit trail.
if (g_validator != PermitAll) {
std::printf("AUDIT: '%s' checked by custom policy\n", req);
g_validator(req);
return false;
}
std::printf("(no audit: library believes the default policy is installed)\n");
g_validator(req);
return true;
}
} // namespace reqlib
Add app.cpp:
#include "audit.h"
#include <cstdio>
int main()
{
// Ops policy: permissive for now, to be tightened later.
// Nobody duplicated any code -- this is just a lambda.
Validator ops_policy = [](const char*) { return true; };
reqlib::SetValidator(ops_policy);
const bool bug{reqlib::HandleRequest("withdraw 100 BTC")};
// volatile: keep the compiler from folding the comparison itself --
// it is entitled to assume distinct functions have distinct addresses.
Validator volatile a{ops_policy};
Validator volatile b{reqlib::PermitAll};
std::printf("\nops_policy (lambda) = %p\nreqlib::PermitAll = %p\n", (void*)a, (void*)b);
std::printf("at runtime they are: %s\n", a == b ? "THE SAME FUNCTION" : "distinct");
if (bug) {
std::printf("\nFAIL: the linker folded the app's lambda into the library's default,\n"
" so the \"has the default been replaced?\" check is dead code\n"
" and the audit trail was silently skipped.\n");
return 1;
}
std::printf("\nPASS: function identity preserved; audit trail intact.\n");
return 0;
}
Build the broken version:
export SDK_PATH=${SDK_PATH:-$HOME/macOS-SDKs}
SDK="$SDK_PATH/Xcode-26.1.1-17B100-extracted-SDK-with-libcxx-headers"
HOST=arm64-apple-darwin guix time-machine \
--url=https://codeberg.org/guix/guix.git \
--commit=c5eee3336cc1d10a3cc1c97fde2809c3451624d3 \
-- shell --manifest=contrib/guix/manifest_build.scm --share="$SDK_PATH" --pure \
-- clang++ --target=arm64-apple-darwin -isysroot"$SDK" -nostdlibinc \
-iwithsysroot/usr/include/c++/v1 \
-iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks \
-mmacos-version-min=14.0 -mlinker-version=711 -Xclang -fno-cxx-modules \
-std=c++20 -O2 -fuse-ld=lld \
-Wl,-platform_version,macos,14.0,14.0 -Wl,--icf=safe \
~/icf-demo/lib.cpp ~/icf-demo/app.cpp -o ~/icf-demo/icf-broken
Build correct version by adding -faddrsig added and -o ~/icf-demo/icf-fixed
Copy and to macOS (arm64) and run:
scp guix:icf-demo/icf-broken guix:icf-demo/icf-fixed .
./icf-broken; echo "exit=$?" # exit=1, audit silently skipped
./icf-fixed; echo "exit=$?" # exit=0, audit intact
</details>
604 | @@ -605,6 +605,11 @@ if(REDUCE_EXPORTS) 605 | try_append_linker_flag("-Wl,-no_exported_symbols" VAR CMAKE_EXE_LINKER_FLAGS) 606 | endif() 607 | 608 | +# Attempt to use safe identical code folding. This reduces 609 | +# binary size. 610 | +try_append_linker_flag("-Wl,--icf=safe_thunks" VAR CMAKE_EXE_LINKER_FLAGS) 611 | +try_append_linker_flag("-Wl,--icf=safe" VAR CMAKE_EXE_LINKER_FLAGS)
We try
safe_thunksfirst, and then trysafe.
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?
Concept ACK on using the "Identical Code Folding" linker feature where possible.
I agree with @Sjors. The address-significance table emitted by -faddrsig is the only thing that makes -Wl,--icf=safe different form -Wl,--icf=all. And it must be enabled explicitly for macOS targets.
I wrote earlier:
My LLM friend thinks that
--icf=safeis not actually safe, because without an address-significance table (-faddrsig) it's equivalent to--icf=all.That seems to be fixed here: llvm/llvm-project#188400
Tested this using the following snapshot:
$ clang --version
Ubuntu clang version 23.0.0 (++20260707081847+70646dd3eda3-1~exp1~20260707082012.1709)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-23/bin
For bitcoind (the arm64-apple-darwin target), --icf=safe without -faddrsig results in the same binary size as --icf=none.
Reviewed at 24ad7419dea4. 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 (measured below).
This settles the -faddrsig question in the thread: on Mach-O with ld64.lld 19.1.7, --icf=safe without -faddrsig folds address-taken functions. Objects built without the flag carry no __llvm_addrsig section, and lld 19's Mach-O port then treats every function as foldable β the conservative "no table, don't fold" fallback exists only on ELF/COFF, which is why --icf=safe is fine on Linux (clang emits the table by default there) but not on Darwin. The upstream fix @Sjors linked (llvm/llvm-project#188400) means a future toolchain turns this same configuration into a silent no-op instead. Either way, Darwin needs -faddrsig for safe to mean safe β and this is why safe and all produced identical sizes: today they do the same folding.
<details><summary>Repro on the pinned toolchain (extends [@Sjors](/bitcoin-bitcoin/contributor/sjors/)' earlier example; clang/LLD 19.1.7 via <code>guix time-machine</code> + <code>manifest_build.scm</code>)</summary>
#define N __attribute__((noinline))
N int f(int x) { return x * 7 + 3; }
N int g(int x) { return x * 7 + 3; }
N int h(int x) { return x * 9 + 1; }
N int k(int x) { return x * 9 + 1; }
typedef int (*fp)(int);
volatile fp pf = f;
volatile fp pg = g;
int main(void) { return pf(1) + pg(2) + h(3) + k(4); }
Compiled with clang --target=arm64-apple-darwin -O2 [-faddrsig] against the extracted SDK, linked with -fuse-ld=lld -Wl,--icf=safe (or all), then llvm-nm --numeric-sort | grep -E ' _(f|g|h|k)$':
--icf=safe, no -faddrsig: --icf=safe, with -faddrsig: --icf=all:
00000001000003b0 T _f 00000001000003b0 T _f 00000001000003b0 T _f
00000001000003b0 T _g 00000001000003c0 T _g 00000001000003b0 T _g
00000001000003c0 T _h 00000001000003d0 T _h 00000001000003c0 T _h
00000001000003c0 T _k 00000001000003d0 T _k 00000001000003c0 T _k
f/g are address-taken; safe without -faddrsig is indistinguishable from all.
</details>
It shows in the real artifacts. Taking llvm-nm --defined-only on the unstripped arm64-apple-darwin bitcoind, keeping text symbols, deduping identical (address, name) pairs, and counting addresses claimed by more than one name: 4,149 symbols share 678 addresses in my Guix build of this tip, versus zero in an identically processed build of the base (all three builds list the same 15,899 text symbols, so every collision is ICF). Rebuilt with -faddrsig, 614 fold groups remain (legitimate folding of non-address-taken code); the other 70 are address-significant and should not have folded β including std::variant visitation dispatchers, whose addresses sit in std::visit dispatch tables, and distinct tinyformat::format instantiations.
To measure the true safe win β and whether it survives on the depends static libraries, whose objects also need the table β I rebuilt arm64-apple-darwin with -faddrsig added to darwin_CFLAGS/darwin_CXXFLAGS in depends/hosts/darwin.mk (propagates to depends and core via toolchain.cmake). bin/ sizes in bytes from the extracted -unsigned.tar.gz (stripped release binaries):
| Binary | Parent (297fd1489bbf) | Branch as-is (β --icf=all) |
Branch + -faddrsig (true safe) |
|---|---|---|---|
| bitcoin | 209512 | 193040 (β7.86%) | 193064 (β7.85%) |
| bitcoin-cli | 3626584 | 2884432 (β20.46%) | 2901008 (β20.01%) |
| bitcoind | 12583620 | 11939980 (β5.11%) | 11989516 (β4.72%) |
| bitcoin-qt | 32453708 | 31080876 (β4.23%) | 31248148 (β3.71%) |
| bitcoin-tx | 2409480 | 2343496 (β2.74%) | 2343552 (β2.74%) |
| bitcoin-util | 388496 | 355584 (β8.47%) | 372000 (β4.25%) |
| bitcoin-wallet | 4179668 | 4014700 (β3.95%) | 4031228 (β3.55%) |
| Total | 55851068 | 52812108 (β5.44%) | 53078516 (β4.96%) |
So the fix is cheap overall: 4.96% total reduction under true safe versus 5.44% now. The exception is bitcoin-util, which keeps only half its win β the binary where address-significant folding was doing the most work, i.e. exactly the folds safe exists to prevent. Sizes are scoped to arm64-apple-darwin; my base control covered x86_64-linux-gnu, x86_64-w64-mingw32 and arm64-apple-darwin only, so I have no x86_64 Darwin baseline.
@hebasto on the probe order: moot today, but it arms on the next toolchain bump. On the pinned toolchain the safe_thunks probe fails β LINKER_SUPPORTS__WL___ICF_SAFE_THUNKS is empty in the release build's CMakeCache.txt, so only --icf=safe is appended. That matches the source: LLD 19's Mach-O driver accepts only none/safe/all and warns-then-defaults-to-none on anything else (getICFLevel); Mach-O safe_thunks landed in LLVM 20. Once the toolchain reaches 20+, I'd expect both probes to pass and both flags to land on the link line β and since the driver takes the last --icf= (getLastArgValue, verified on 19 by reversing the flag order), safe would permanently shadow safe_thunks. Guarding the second probe avoids that:
try_append_linker_flag("-Wl,--icf=safe_thunks" VAR CMAKE_EXE_LINKER_FLAGS RESULT_VAR linker_supports_icf_safe_thunks)
if(NOT linker_supports_icf_safe_thunks)
try_append_linker_flag("-Wl,--icf=safe" VAR CMAKE_EXE_LINKER_FLAGS)
endif()
Moving the probes into the root CMakeLists.txt doesn't change non-Darwin output: a control build of the base (297fd1489bbf, FORCE_VERSION/SOURCE_DATE_EPOCH pinned to this tip's) produced x86_64-linux-gnu and x86_64-w64-mingw32 binaries whose only differing bytes were the three known version-carrying artifacts β embedded commit-id strings, .gnu_debuglink CRCs, and the PE header checksum; after normalizing those, the extracted trees compare byte-identical. riscv64-linux-gnu built clean with the exemption in place.
All of the Darwin work above was cross-compiled and analyzed on an x86_64 Linux machine β I haven't run these binaries on macOS hardware. The only functional testing of the ICF-folded binaries so far remains @Sjors' earlier smoke test on his MacBook.
<details><summary>Guix build (x86_64)</summary>
79cdcb0b524218c92c4e55b8a8580b7a282a208f64e63cbb906496fa286fe8e4 guix-build-24ad7419dea4/output/aarch64-linux-gnu/SHA256SUMS.part
1dacd2082a4ea38ca9d9f3ca6d179c4a796fe4ab7dd58f48413e8321f5a88889 guix-build-24ad7419dea4/output/aarch64-linux-gnu/bitcoin-24ad7419dea4-aarch64-linux-gnu-debug.tar.gz
cf139f9381d62b7af34e9f869e6444062cc8439435505b9d3e06b1a36e77d752 guix-build-24ad7419dea4/output/aarch64-linux-gnu/bitcoin-24ad7419dea4-aarch64-linux-gnu.tar.gz
a1a64bf02505833eb74064bad185251ccfeb090a8260e5b4a6ebda8acfb37e37 guix-build-24ad7419dea4/output/arm-linux-gnueabihf/SHA256SUMS.part
14f4780436cea32591cd4fa8fef3b5e9359ff4751b116f5c804779a694db6d3c guix-build-24ad7419dea4/output/arm-linux-gnueabihf/bitcoin-24ad7419dea4-arm-linux-gnueabihf-debug.tar.gz
e3081a1fc9f3509208b4ac362895b486c87b5c1f8a1b0153358eed8536d62d25 guix-build-24ad7419dea4/output/arm-linux-gnueabihf/bitcoin-24ad7419dea4-arm-linux-gnueabihf.tar.gz
f791c9c9a06dea1356ba2b130b84befd8d5982969a21216c75d53a41597c5aa9 guix-build-24ad7419dea4/output/arm64-apple-darwin/SHA256SUMS.part
4624a97304b3196b046cc49a32a161d1b114ad364ac3041503f33385f4ef5dc2 guix-build-24ad7419dea4/output/arm64-apple-darwin/bitcoin-24ad7419dea4-arm64-apple-darwin-codesigning.tar.gz
25d08506235ed48c27abc8cceecd28ec659ccda761317afed3c6c6f59f1574c2 guix-build-24ad7419dea4/output/arm64-apple-darwin/bitcoin-24ad7419dea4-arm64-apple-darwin-unsigned.tar.gz
4e5353512546db8be1ab295120ca8bec6aa7282d6aa485a40065e18988223221 guix-build-24ad7419dea4/output/arm64-apple-darwin/bitcoin-24ad7419dea4-arm64-apple-darwin-unsigned.zip
91bf75abc2acc3e3eca85d159a8cc150f6a275b07fc293514eefd71c0b13e7dc guix-build-24ad7419dea4/output/dist-archive/bitcoin-24ad7419dea4.tar.gz
af7f449030a4270321e3c635cea6b7cb93e05acdb73128efd6ee764b373d49ec guix-build-24ad7419dea4/output/powerpc64-linux-gnu/SHA256SUMS.part
27106f27a2b8a2873de820cea76efcbb51bd88f40589b3e47175ee5226411b0d guix-build-24ad7419dea4/output/powerpc64-linux-gnu/bitcoin-24ad7419dea4-powerpc64-linux-gnu-debug.tar.gz
158232ece4c292a996a3d4574ed47b6b9273d6c58dc2dd0f95782211933fa26a guix-build-24ad7419dea4/output/powerpc64-linux-gnu/bitcoin-24ad7419dea4-powerpc64-linux-gnu.tar.gz
a6480bb08234f20396f7273ea8b77a986da40f28d1a87e5779284de38904c4ab guix-build-24ad7419dea4/output/riscv64-linux-gnu/SHA256SUMS.part
1640b6a6832264e7e048c3b43fd2b8b52b0a07ee031a8ab7cf24268aa2468285 guix-build-24ad7419dea4/output/riscv64-linux-gnu/bitcoin-24ad7419dea4-riscv64-linux-gnu-debug.tar.gz
6614b05ba1a112b96e717dd417db1f0d929dc4ac993d2c59d99c3d9ebd1ed653 guix-build-24ad7419dea4/output/riscv64-linux-gnu/bitcoin-24ad7419dea4-riscv64-linux-gnu.tar.gz
93d9483b63fa600ad8c519ae55f284e89160c06057e85a0f7d6563ce9366eb1f guix-build-24ad7419dea4/output/x86_64-apple-darwin/SHA256SUMS.part
090ce10c5b6f23bbbf5412e34f9c93da688ba2b587814d2e672720ab9567d413 guix-build-24ad7419dea4/output/x86_64-apple-darwin/bitcoin-24ad7419dea4-x86_64-apple-darwin-codesigning.tar.gz
98171e4be2690aa3ca382cb62d9bda331b787a8c5a3ad6c0a5ea3b7138bb6949 guix-build-24ad7419dea4/output/x86_64-apple-darwin/bitcoin-24ad7419dea4-x86_64-apple-darwin-unsigned.tar.gz
f603e0e566dedd051333727c1f60d9bc96884410a279b63b728904bc6810e6f1 guix-build-24ad7419dea4/output/x86_64-apple-darwin/bitcoin-24ad7419dea4-x86_64-apple-darwin-unsigned.zip
c49278c62f9435eaa9766ba31e6719bfd83c69a5b918ba895f41f43f0576aa75 guix-build-24ad7419dea4/output/x86_64-linux-gnu/SHA256SUMS.part
5c52f4e89f0962944ca015d49fe138e1542db7cce0a9e22196b300292333450c guix-build-24ad7419dea4/output/x86_64-linux-gnu/bitcoin-24ad7419dea4-x86_64-linux-gnu-debug.tar.gz
c6ef006f60f3c111c442ee6f6fee41a3bffa05c92f8e1b356e3ef8d28df740cb guix-build-24ad7419dea4/output/x86_64-linux-gnu/bitcoin-24ad7419dea4-x86_64-linux-gnu.tar.gz
f29b432b8f92f4b2d88c714c812f8a0654b691daedcd41d8dc8848849781a54a guix-build-24ad7419dea4/output/x86_64-w64-mingw32/SHA256SUMS.part
ed6de4310b9de743a07210c4b6826f3f1d75bfceeb6988d6c05a24ae48d477da guix-build-24ad7419dea4/output/x86_64-w64-mingw32/bitcoin-24ad7419dea4-win64-codesigning.tar.gz
b01a96d25ab20e8301b621f2e4882e2da58afba80d31eec025d5f200263e307d guix-build-24ad7419dea4/output/x86_64-w64-mingw32/bitcoin-24ad7419dea4-win64-debug.zip
1c286ad25dba26e70771ed615f98bd157261cefd7ee819db8481c273a47607de guix-build-24ad7419dea4/output/x86_64-w64-mingw32/bitcoin-24ad7419dea4-win64-setup-unsigned.exe
39025c9504ab7ec2400a40dacacf28d35169e5d4c9c6cce8d21d572ae6fc50d1 guix-build-24ad7419dea4/output/x86_64-w64-mingw32/bitcoin-24ad7419dea4-win64-unsigned.zip
</details>
No other attestations at this tip yet (the earlier ones in the thread are for aa3bbe2ea218).