Install the package.
Build packages with Clang
export CC=clang and (for C++)
export CXX=clang++ to your
/etc/makepkg.conf and for LTO support:
export LD=lld and
export AR=llvm-ar. If you are building with
debug also remove
DEBUG_CXXFLAGS as clang does not support it.
NB: For packages that specify GCC-specific build options, there may be build errors that require either editing the source package, the pkgbuild or commenting out the clang lines in
Using the Static Analyzer
To analyze a project, simply place the word
scan-build in front of your build command. For example:
$ scan-build make
If your project is already compiled,
scan-build will not rebuild and will not analyse it. To force recompilation and analysis, use
$ scan-build make -B
It is also possible to analyze specific files:
$ scan-build gcc -c t1.c t2.c
Tips and tricks
In order to enable Bash completion, install
/usr/share/clang/bash-autocomplete.sh in a Bash startup file.