I have a project that builds 5 binaries from 5 different schemes. Building each one of them separately takes around 2 minutes, with a large part of time spent on linking (lto I guess). I have a dummy target that builds all of them in parallel - I never managed to successfully build it, it goes on for 40-50 minutes and I just lose patience.
What happens is, all the compilation is done ok, but when linking starts, 10 linker processes are spawned (5 binaries x 2 architectures) and they seem to never finish. While they are running, "top" shows a kernel_task using a lot of cpu (>100%) and the instances of ld using around 20-30 each.
This is all happening on m1 macbook air 8/256.
My guess is that it is a combination of RAM pressure, thermal throttling and the OS aggressively shuffling the 10 processes over the 8 cores, leading to lots of cache misses and possibly swapping.
Is there any workaround I can apply - possibly some xcode setting to limit parallel jobs to 4-6 or something like that.