Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[build] Compile iOS static library as Relocatable Object File#9530

Closed
friedbunny wants to merge 1 commit into
masterfrom
fb-ios-static-relocatable
Closed

[build] Compile iOS static library as Relocatable Object File#9530
friedbunny wants to merge 1 commit into
masterfrom
fb-ios-static-relocatable

Conversation

@friedbunny
Copy link
Copy Markdown
Contributor

@friedbunny friedbunny commented Jul 17, 2017

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 with mh_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 ld docs, enabling relocation: “Merges object files to produce another mach-o object file with file type MH_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

@friedbunny friedbunny added build iOS Mapbox Maps SDK for iOS needs discussion ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Jul 17, 2017
@friedbunny friedbunny self-assigned this Jul 17, 2017
@friedbunny friedbunny requested review from 1ec5 and kkaefer July 17, 2017 23:28
@friedbunny
Copy link
Copy Markdown
Contributor Author

friedbunny commented Jul 17, 2017

This does bring some new warnings, such as these for every dylib we link:

▸ Linking libMapbox.a
⚠️ ld: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/usr/lib/libz.dylib, ignoring unexpected dylib file

▸ Linking libMapbox.a
⚠️ ld: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/usr/lib/libz.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x32 ) which is not the architecture being linked (armv7): /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/usr/lib/libz.tbd

Copy link
Copy Markdown
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@friedbunny
Copy link
Copy Markdown
Contributor Author

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.

@friedbunny friedbunny closed this Jan 5, 2018
@friedbunny friedbunny deleted the fb-ios-static-relocatable branch January 5, 2018 00:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

build ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold iOS Mapbox Maps SDK for iOS needs discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants