[build] Compile iOS static library as Relocatable Object File#9530
[build] Compile iOS static library as Relocatable Object File#9530friedbunny wants to merge 1 commit into
Conversation
|
This does bring some new warnings, such as these for every dylib we link:
|
1ec5
left a comment
There was a problem hiding this comment.
There’s scant official documentation on mh_object. The little bits I can find do indicate that it’s normal for a static library to have this type. However, neither this documentation nor the Stack Overflow posts you’ve linked to are particularly recent. Is there anything special about iOS that we should consider, such as how Bitcode might be affected?
|
Research seems to point to this type of static library being poorly supported and buggy. Being that we generally do not encourage the use of the static framework anyway, I’m going to abandon this speculative change. |
This is an experimental change, PR’d for discussion.
Changes
Sets the iOS static library’s Mach-O Type to Relocatable Object File (
mh_object), where it was previously the default, Static Library (staticlib). Also disables dead code stripping on the static library, as this is not compatible withmh_object.Effect
This reduces the uncompressed size of a release-build, symbol-stripped static library from 280 MB to 110 MB. See the footnote in #9022 (comment) for raw numbers. This has no effect on the ultimate size of an application.
Mechanism
Per this post about the
lddocs, enabling relocation: “Merges object files to produce another mach-o object file with file typeMH_OBJECT.” And per this post this has the effect of “helping” mark symbols as private, which probably accounts for some of the size reduction.Questions
Does this still qualify as a sufficiently static library?
Is it compatible with our current static library? So far, the answer is yes: inserting this library into an existing app works as expected. Have tested with Swift, will need to test with Obj-C.
Does this affect debugging in client apps?
Have not tested yet.
Does this break anything? 😬
So far, no, but our static library testing infrastructure is weak. Our symbol visibility script does not indicate any missing symbols.
Related issues
#8089, #9022
/cc @boundsj @kkaefer @1ec5