Clang

Clang is a C/C++/Objective C/CUDA compiler based on LLVM. The most recent iteration is distributed under the "Apache 2.0 License with LLVM exceptions".

Installation

Install the clang package.

Build packages with Clang

To change the default compiler for building packages, edit:

/etc/makepkg.conf
...
export CC=clang
export CXX=clang++

For LTO support: install the lld package, then add -fuse-ld=lld to LDFLAGS in your /etc/makepkg.conf.

If you are building with debug, you also need to remove -fvar-tracking-assignments from DEBUG_CFLAGS and DEBUG_CXXFLAGS, as Clang does not support it.

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 switch:

$ scan-build make -B

It is also possible to analyze specific files:

$ scan-build gcc -c t1.c t2.c

Tips and tricks

Bash completion

In order to enable Bash completion, install and source in a Bash startup file.

gollark: Well, lucky, I guess, except it's an iPhone so I don't really like it, but it has... good specs and such.
gollark: Unrelatedly, choosing a decent phone these days is hard.
gollark: Continuing on from what I said, though: I've also heard it said that house prices are high because you can borrow lots of money cheaply now because of low interest rates, and because houses are a long-term-ownership thing their demand is more affected by how much you can *borrow* more than how much you *have now*. I have no idea which of these, if any, is accurate.
gollark: Ah.
gollark: Farmers... are workers, though? Do you mean specific workers of some sort?

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.