Fold identical functions in the bindings on every platform, not just Linux - #6734
Open
Fedr wants to merge 4 commits into
Open
Fold identical functions in the bindings on every platform, not just Linux#6734Fedr wants to merge 4 commits into
Fedr wants to merge 4 commits into
Conversation
Grantim
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--icf=allhas been Linux-only since it was added, with the note "until lld-link (Windows) and ld64.lld (macOS) get their own measurements". Those measurements are now in, from #6731: every macOS leg linked the module with ICF and ran the full Python sanity suite on the result.--icf=all__textalone drops 12.8% on x64 and 20.1% on arm64. arm64 folds more, as expected: fixed-width instructions make more of the ~190k near-duplicate template instantiations byte-identical.What changed
Only the
IS_LINUXguard around the flag, replaced by one that excludes the two platforms that cannot use it. It stays inside theMODE=releasepreset, because that is where-flto=thincomes from and lld's LTO codegen is what emits the per-function sections ICF folds; aMODE=nonebuild has nothing to fold on any platform.Emscripten —
wasm-ldhas no ICF. This was covered implicitly before (IS_LINUXis cleared when targeting Emscripten); now it is explicit.Windows — nothing to add:
lld-linkalready folds by default. Measured on the wheel build, which unlikebuild-test-windows.ymluses this preset:/opt:icf/opt:noicfmrmeshpy.pydmrcudapy.pyd/opt:icfis a no-op because ICF comes with/opt:refin non-debug links, and disabling it costs 6.8 MB. The GNU spelling never reached the linker's logic there either —lld-link: warning: ignoring unknown argument '--icf=all', byte-identical output — so passing it on Windows would only add a warning.Not included
-fomit-frame-pointerwas measured in the same run and is not usable on macOS: it grows the module by 12-15% (Apple's ABI expects a frame pointer, so dropping it pushes functions out of the compact-unwind encodings into much bulkier DWARF entries) and it breaks the sanity suite outright —libc++abi: terminating due to uncaught exception of type pybind11::stop_iteration, i.e. unwinding stops finding handlers. Alignment padding is already nil under-Oz(477 bytes in a 34.7 MB__text), so there is nothing there either.