2023-06-14 Clang on Arm Tags: clang armGet Clang + prerequisites: ``` git clone https://github.com/llvm/llvm-project.git --depth 1 --branch llvmorg-16.0.5 sudo apt install build-essential ninja-build cmake ``` Build clang: ``` cmake -G Ninja ../llvm \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$HOME/clang \ -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" \ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;compiler-rt;libunwind" \ -DLLVM_TARGETS_TO_BUILD="AArch64" \ -DLIBCXX_USE_COMPILER_RT=YES \ -DLIBCXXABI_USE_COMPILER_RT=YES \ -DLIBCXXABI_USE_LLVM_UNWINDER=YES ninja -j4 ninja install ``` Compile example: ``` export PATH=/home/krupkat/clang/bin:$PATH clang++ main.cpp -o main -g \ -std=c++2b \ -fuse-ld=lld \ -stdlib=libc++ \ -Wl,-rpath,/home/krupkat/clang/lib/aarch64-unknown-linux-gnu \ -rtlib=compiler-rt \ -fsanitize=hwaddress,undefined,leak \ -fno-omit-frame-pointer ``` To get llvm-symbolizer support, run example like this: ``` PATH=/home/krupkat/clang/bin:$PATH ./main ```