GCC vs. LLVM Clang Compilers For The Apple M2 On Linux

Written by Michael Larabel in Software on 1 September 2022. Page 1 of 4. 12 Comments

With the Apple M2 running Asahi Linux you may be wondering whether it's better to use the GCC compiler as is the default on upstream Arch Linux or whether going for LLVM Clang will yield better performance given all the LLVM/Clang usage by AArch64 vendors, including Apple's own Xcode compiler toolchain making use of it. If you are wondering about GCC vs. Clang for building binaries on the Apple M2, here are some benchmarks.

With the Apple M2 MacBook Air I was curious how GCC vs. Clang was competing for performance, so I ran some benchmarks. The Apple M2 was running the Arch-based Asahi Linux as the only distribution currently capable of running this latest Apple Silicon. With its Linux 5.19-based kernel I tested both LLVM Clang 14.0.6 and then GCC 12.1, both as packaged for Arch/Asahi. Throughout all the testing the CFLAGS/CXXFLAGS were maintained the same and targeting the -O3 optimization level.

apple m2 compilers

From there dozens of different C/C++ benchmarks were carried out to see whether the binaries resulting from GCC 12 or Clang 14 were faster on the Apple M2 running Linux.

Related Articles