Note that LLVM doesn't guarantee automatic feature detection always succeeds, particularly for newer CPU models and older LLVM builds (e.g. M2 CPU + LLVM 16), the result is usually inaccurate. In this case, i.e. CPU feature detection fails, we will print a warning message and return an empty dict instead.
To properly detect CPU features on macbook, the commands below provided by the system are the most accurate:
sysctl -a machdep.cpu
sysctl -a hw.optional
On linux, usually it is recommended to directly query via:
A small script that exposes host CPU name, target triple and features:
Output (AMD CPU):
Note that LLVM doesn't guarantee automatic feature detection always succeeds, particularly for newer CPU models and older LLVM builds (e.g. M2 CPU + LLVM 16), the result is usually inaccurate. In this case, i.e. CPU feature detection fails, we will print a warning message and return an empty dict instead.
To properly detect CPU features on macbook, the commands below provided by the system are the most accurate:
On linux, usually it is recommended to directly query via: