Factsheet
How do I unlock the true power of my LLVM clang?
ELI5-ish: LLVM vs Clang vs GCC
LLVM/Clang 10.0.0 is released!
Why you should use Clang
Videos
Hi all,
So I recently got a new Macbook Pro M4 laptop with 48 GB RAM. I have a simulation code that is template heavy and experiences a sort of template explosion. I did primary development on my macbook pro for a while, but now have ported the code over to my Asus ROG laptop with an NVIDIA GPU in it for further acceleration. Something I noticed immediately was that when enabling the full instantiation stack to compile on the M4, this took ~1 hr to complete. I sort of shrugged at this and said "ok I'll figure out how to get around this template explosion later" and would only instantiate the templates I needed at the time of development. However, when I ported everything to my older ROG laptop and compiled it to allow all of the ~180 template instantiations (it's a hydrodynamics code with different requirements for mesh geometries, dimensionality of the problem, etc), I found that everything compiled in about 2 minutes.
I'm fairly new to developing on macOS, but this seems egregious, no? on the macbook I'm compiling with llvm clang version 20.1.8 with the lld (I've also tried ld64) linker. On the ROG I compile with gcc 15 with the ld.bfd linker. I notice that the timecommand shows that the ROG linux machine uses about 500% cpu (~avg of 5 cores on a 16 core machine) during the build while the apple machine uses only a single core (a total of 12 cores on the machine) the entire time. I'm using the meson build system and the build configurations file is identical between both machines. So as a sort of sanity check I installed gcc-15 onto the macbook pro. I immediately saw 2min compilation times. This is where I'm lost. even when gcc uses the ld64 linker, we get much faster linking where I see a spike in cpu usage in btop hit 100% core usage during the link step. I have been searching around, but I'm not sure how to enable llvm clang's "performance mode." this difference seems large enough that it's likely my own ignorance to the llvm build system that's causing such discrepancies in compilation time. Any advice would be greatly appreciated! Thank you all for reading!