iOS Build Environment Help Center

libtool.exe command line can get above the Windows 8K limit

append delete JF

Windows 11
Builder version: 3.54
iOS SDK version: Xcode 14.2
Unity version: 2022.2.1f1

libtool has a problem linking when the command line to do so is > 8K of characters, which is Windows' limit for a command line. The object files are all in the current directory, so there is no easy way to shorten the paths here.

https://pastebin.com/a1au17Np

To test it out, if I remove enough object files from that command line to get under 8K, and then run that libtool.exe command line manually, it will generate an output file, so that is what is tripping it up.

I'm not sure how I should work around this problem, is there perhaps a flag I can pass to the compiler to prevent this situation?

Reply RSS

Replies

append delete #1. Pierre-Marie Baty

Hello

That's a well-known problem on Windows... And unfortunately here the problem occurs within the *il2cpp.exe* compiler driver supplied by Unity with their editor. They should have used the -filelist option. e.g. instead of :

%
libtool -static -o myStaticLib.a objfile1.obj objfile2.obj objfile3.obj ... objfileN.obj
%

the Unity il2cpp compiler driver should do :

%
libtool -static -o myStaticLib.a -filelist file_containing_the_list_of_object_files.txt
%

I already contacted the person who was in charge of implementing that in il2cpp.exe but got no reply yet. Let's hope it gets fixed quickly. Don't hesitate to forward this problem report to the Unity team because ATM only them can fix that (and if necessary, insist that "building for iOS targets on Windows is not supported" is not an answer. The problem is identified and the solution is known, that fix is a 5 minutes job).

Best regards && happy new year,

append delete #2. Pierre-Marie Baty

Just a follow-up on this issue.

The person in charge of it told me today that a PR was made at Unity and the fix should hopefully be in Unity 2023.1.

append delete #3. Zap

Any update from Unity on this? I tried with Unity 2022.2.3 and the problem still persists. Is the PR going to be accepted in the 2023.1 alpha versions only? Also, would it be possible to store the filenames into a file and run libtool with the -filelist option manually and then resume the build pipeline at the next step? Just an idea...

append delete #4. Pierre-Marie Baty

Hello,

Unfortunately, no update since 17 january (that was one week ago!)

I don't have more information on how Unity is progressing on this, but feel free to ask them on their forum and post here if you have more info.

About your idea, I already thought about something like that, but the problem is that the Unity il2cpp compiler is in fact a "compiler driver" whose task is to conduct various hardcoded compilation steps, of which calling libtool is simply the last one. And unfortunately the way it does it all in sequence is hardcoded, and AFAIK it's neither interruptible nor resumable.

To make it able to support this would require reverse-engineering, and at this point it would be probably saner to start an alternate implementation of il2cpp.exe from scratch.

I understand this problem prevents you from building your project, unfortunately there's little I can do on my side...

Perhaps an awful trick that could possibly work would look like this :

have il2cpp run (and obviously fail), prevent it from deleting its intermediary files on failure (by means to be determined), then take these intermediary object files and bundle them together in a static library by calling libtool yourself, and at this point resume the build.

Calling libtool ourselves and resuming the build is just a matter of editing the build.cmd master script, but preventing il2cpp from deleting its intermediary files would probably require some binary patching. Or perhaps setting a "no delete" flag or NTFS ACL permission on its intermediary output folder *while* it's running and before it fails... I don't like fragile hacks like those and would only consider investigating that if Unity doesn't provide the promised fix.

append delete #5. Zap

Wow, thanks for the quick and thorough answer, Pierre-Marie! I could try your suggested hack, could you point me to what line in build.cmd you call il2cpp? Then I can do the folder permissions stuff before that and call libtool.exe manually right after that, as well as and revert folder permissions and delete the intermediate linker input files.

append delete #6. Pierre-Marie Baty

Open build.cmd with your favorite text editor and look for "il2cpp.exe". It should be around line 1868. Everything's thoroughly commented. The actual call happens at line 1958 from a constructed command line.

If you manage to achieve success that way, I'd be happy to hear about it !

append delete #7. JF

Good news, I originally filed a bug on this in January, then it was closed as not repro by a customer service representative, then a few months later it got resurrected by a dev due to a discussion on the unity forums, and I just got notifiaction it may have been fixed now (not sure when it will roll out):

A fix for your bug report IN-27592: [General] il2cpp.exe should pass object files to libtool.exe with -filelist option rather than passing them in on the command line has been submitted with the following status: Fixed and currently awaits internal confirmation. Fix Version/s: Pending Resolution Notes:

append delete #8. Pierre-Marie Baty

This is excellent news. With a bit of luck it'll be in the next version of the editor !

append delete #9. Dominik

I had the same problem, found this thread, updated my Unity to the latest version (2022.3.4f1 in my case) and can confirm: it is now fixed! :)

append delete #10. Pierre-Marie Baty

Nice ! Thank you on behalf of all the other readers for reporting the good news :)

Reply

(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Moderators: Pierre-Marie Baty