Lipo max input file size is limited

Hi,


We are working with a rather large library. We compile this library for different targets and put it into a fat library with Lipo.


We have the source code of this library, but as it's provided to us, we generally only create a Release version of this library.


Recently, we have been trying to find a bug in this library, and for that, we tried to build it as a Debug version. But to our surprise, the library built fine, but lipo failed to combine the libraries into a fat library. Saying "Can't write to target file ...".


It turned out that the filesize of the Debug version of the library is over 2Gb (about 2.1Gb), and we are guessing that lipo cannot handle file sizes larger than 2Gb. Although clang can create it just fine.


Let's assume that we cannot split the library into smaller libraries (I'm looking for a short-term solution)... What else can we do, other than strip a 100Mb or more of symbols from this file?


I was thinking about taking the source of lipo and make it work for file size > 2Gb. But are there any other suggestions?

Replies

Those are pretty much your options. That or file a bug with Apple and hope they fix it eventually.


If you decide to fix the bug yourself, please file a bug report at bugreport.apple.com and attach the patch so that everyone can benefit. 🙂

Well, I patched lipo to write the file in 1GB increments. The problem turned out that write() cannot write a buffer that's larger than 2GB. This seems to work, and I could write a fat library of 4456001188 bytes.


However, the fat_arch struct looks like this:


struct fat_arch {
        cpu_type_t      cputype;        / cpu specifier (int) */
        cpu_subtype_t   cpusubtype;     / machine specifier (int) */
        uint32_t        offset;         / file offset to this object file */
        uint32_t        size;           / size of this object file */
        uint32_t        align;          / alignment as a power of 2 */
};


And I'm putting in two libraries that are larger than 2GB (and one is arm7/arm7vs, so contains a 3rd architecture). The offset overflows, and the library cannot be used. So the next limit turns out to be 4294967296 (or actually less, because the first offset is always 68 bytes).


Oh well, at least I can get a debug library for one architecture in the archive, which is better than none.

I'll file a bug with Apple. Hopefully they have time to fix it. The fix is simple, but can probably not be backwards compatible. Maybe they can put it in Xcode 7.

would you share how do you do that? patching the lipo to output file in 1Gb increment? Thanks in advance!