IL2CPP builds taking hours

I have an Oculus Quest app that I am working on and most of the time the build takes about 2 minutes, and more and more frequently it will randomly take two hours. I say random because I cant figure out a pattern. Earlier I was trying to debug a specific script and was making small edits to one script file and building, I did something like 6 builds this way, and they all took about 2 minutes to compile. Then it was a 2 hour build for the next. It will also generally consume 99% of my 32 GB of memory. I should also mention there is practically no content in my project because most of that loads in via Asset Bundles.

It hangs at “Building native binary with IL2CPP…”

Unity 2020.3.26f1

Any idea how to avoid this? I have to build to headset for testing network features, and this is just murdering my productivity

Any shaders and materials?
Did you try restart unity, when compiling takes too long?

When the build take a long time, use a tool like Process Explorer to see what processes are running as children of Unity.exe. Likely there is some C++ compiler process that is taking a long time. You should be able to see the command line for that process, which will indicate which C++ file it is compiling. From there we might be able to determine the cause of the problem.

1 Like

Do you use all the shaders included in the project? If there are any unused ones – remove them.

@JoshPeterson , I upgraded to Unity 2021.3.8f1 to see if it would make any different. The first build took approximately an hour and a half. Here are snapshots from Process Explorer and Task Manager during the build. Is there something more specific you hoping to see out of Process Explorer?

8352480--1099101--Screenshot 2022-08-10 114919.png

any news on this? did you manage to solve it ?

Check what C++ compiler configuration is set to in player settings. Setting it to Master will cause this.