LLVM (Clang, etc.)

The LLVM is a collection of compiler and toolchain tools and libraries, which includes its own compiler Clang (clang and clang++) and is the foundation on which many other compilers are built. This page has information only on the compilers that are officially part of LLVM, not 3rd party compilers built on top of it. The Clang C and C++ compilers are intentionally quite compatible with the GCC compilers; supporting many of the same extensions beyond the official language standards, having similar compiler options, and often being able mix C++ code compiled by both. In all software stacks, the module name is llvm. To load a specific version, run

module load llvm/VERSION

To load the default version, run

module load llvm

Languages

The supported languages and the names of their compiler programs are in the table below.

LanguageCompiler Program
Cclang
C++clang++

OpenMP

Clang supports the OpenMP (Open Multi-Processing) extension for C and C++. Enable it by adding the -fopenmp option to the compiler. Additionally, the -fopenmp-simd option enables using the OpenMP simd directive.

Targeting CPU Architecture

By default, the Clang compilers will compile code targeting the generic version of the CPU the compilers are run on. On an x86-64 node, this means being compatible with the original 64-bit AMD and Intel processors from 2003 and thus no AVX/AVX2/AVX-512 without SSE fallback. The compilers use the following options to control the target architecture:

Compiler OptionDefault ValueMeaning
-march=ARCHgenericGenerate instructions targeting ARCH
-mtune=ARCHgenericTune performance for ARCH but don’t generate instructions not supported by -march=ARCH
-mcpu=ARCHAlias for -march=ARCH -mtune=ARCH

The ARCH values for the different CPU architectures (Spack naming) we provide are

Architecture/Target (Spack naming)ARCH value for the compilers
Most generic version of node compiler is running ongeneric
The CPU of the node the compiler is running onnative (not available before LLVM 16)
haswellhaswell
broadwellbroadwell
skylake_avx512skylake-avx512
cascadelakecascadelake
sapphirerapidssapphirerapids (use icelake-client for LLVM 11 and older)
zen2znver2
zen3znver3 (use znver2 for LLVM 11 and older)