What does link-time-optimization mean for static libraries?
What does link-time-optimization mean for static libraries?
- Subject: What does link-time-optimization mean for static libraries?
- From: Jens Alfke <email@hidden>
- Date: Tue, 12 Nov 2013 07:51:49 -0800
My project’s[1] end product is a static iOS library that is then added to any app that wants to use it. What does link-time optimization mean for a target type like this? Does it make sense to enable the LTO build setting?
On one hand, the link operation doesn’t happen in my target, rather in the app that’s eventually going to use the library.
On the other hand, it sounds like LTO changes the content of the .o files to include intermediate output from the compiler that’s necessary at link time.
My guess is that turning on LTO will eventually improve my library’s code, even though this doesn’t happen until the app links.
I’m also guessing that if I build the library with LTO, this will require the app target to also turn on LTO to be able to successfully link … ? Or is it OK if some input .o files were compiled with LTO and some weren’t? Will my code still get LTO optimizations even if the app target doesn’t have the LTO flag turned on?
Also, while I’ve got the mic, I’m curious how much LTO even helps at all for a heavily Obj-C based target. I can’t think of any way that LTO could optimize Obj-C methods because the binding happens at runtime; it’s not feasible to inline any method calls or to make assumptions at build time about what method a message-send will call. I do have a bit of procedural C code in the library, though, which could probably benefit.
—Jens
[1] https://github.com/couchbase/couchbase-lite-ios
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden