I was wondering if it is possible/recommended to build Blender with clang rather than gcc on Linux?
There is some mention of clang on Building Blender - Blender Developer Wiki, but it’s not clear to me if it’s really supported and how to configure the build to use clang.
My use case is indexing the blender code with clangd or lsif-clang.
You generally don’t need to build Blender with clang to use clang based indexing tools. For how to setup the indexing check the documentation of the specific tool or plugin that you are using.
For building Blender it’s mostly a matter of personal preference, there some differences in warning/error messages, compile times, performance … but either works fine.
To build Blender with clang, one way is to set these environment variables used by CMake configuration.
CC=/usr/bin/clang CXX=/usr/bin/clang++ make
A caveat is that you can’t switch an existing build setup to another compiler easily, so remove any existing
build_linux folder before doing this.