Repository navigation
fix(flutter): stop shipping LTO bitcode in the iOS static lib (pub.dev 256MiB) - #196
Merged
Merged
Conversation
…v 256MiB) A cargo staticlib never goes through a link step, so the workspace's fat-LTO (lto = true) only makes cargo pass -C embed-bitcode=yes: every codegen unit embeds its full LLVM bitcode (.llvmbc on ELF, __LLVM,__bitcode on Mach-O) and it stays in the .a forever. On the v0.5.0 xcframework each slice hit ~128MB (bitcode ~80% + debug symbols); the two slices pushed the uncompressed pub package past the 256MiB limit and pub.dev rejected the release. - new [profile.ios-release] (inherits release, lto = false); the iOS build script switches to it, keeping opt-level=z / codegen-units=1 / strip - the script additionally runs strip -Sx (debug + local symbols; globals stay for the podspec force_load) and bitcode_strip -r as a guard - measured on the Linux staticlib (same mechanism): 138.4MB -> 66.5MB; per-member .llvmbc gone (16.9MB in the largest single object) - CFBundleShortVersionString in the generated Info.plist was hardcoded 0.2.0; now read from Cargo.toml - flutter CHANGELOG gains the missing 0.5.0 entry (pub validation warning) Desktop .a artifacts on the GitHub Release keep the fat profile for now; nothing links them at CI time and nothing limits their size.
Xcode 26.6's bitcode_strip fails on the LTO-off archive with 'internal link edit command failed' (the tool has been dead weight since Apple removed bitcode support in Xcode 14). Its only job was guarding against a profile regression; a 64MiB size gate does that more directly and maps onto the pub.dev package limit — a healthy slice is ~15-30MB, an LTO/bitcode regression lands near 128MB.
This was referenced Sep 28, 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.
Problem
The v0.5.0 release failed on Publish Flutter to pub.dev:
Uncompressed package archive is too large (size > 268435456). Every other release target (crates.io, npm, PyPI, Maven Central, GitHub Release) succeeded.Root cause: a cargo
staticlibnever goes through a link step, so the workspace'slto = trueonly makes cargo pass-C embed-bitcode=yes— every codegen unit embeds its full LLVM bitcode (.llvmbcon ELF,__LLVM,__bitcodeon Mach-O) and it stays in the.aforever. The 0.5.0 iOS xcframework slices hit ~128MB each (bitcode ≈80% + debug symbols), pushing the unpacked pub package past 256MiB. 0.3.0 (92MB/slice) had just squeaked under.Fix
[profile.ios-release](inheritsrelease,lto = false) — used only byscripts/build-ios-xcframework.sh;opt-level = "z",codegen-units = 1andstripare unchanged, and every other target keeps fat-LTO.strip -Sx(debug + local symbols; global symbols stay — the podspecforce_loadresolves against them) andxcrun bitcode_strip -ras a belt-and-braces guard.CFBundleShortVersionStringin the generated Info.plist was hardcoded0.2.0; now read fromCargo.toml.bindings/flutter/CHANGELOG.mdgains the missing0.5.0entry (pub validation warning, and pub.dev renders it on the package page).Validation
cargo build --profile ios-release --target x86_64-unknown-linux-gnu -p aimux-ffi):strip -Sx.llvmbcsections: 0 (was 16.9MB inside the single largest object)RUSTFLAGS="-C lto=off"does not work (cargo orders its own profile flag after user RUSTFLAGS) — hence the dedicated profile.Flutter bindingjob (ci.yml) runs this script on macOS withflutter test, so the PR checks exercise the real Apple toolchain end to end.Release follow-up
After merge:
workflow_dispatchthe Release workflow with onlyflutterenabled to re-publish the 0.5.0 package (android + ios artifacts rebuild with this fix; GitHub Release assets stay as-is).