6

FreeBSD 10 was the first release that officially released with Clang as the default, base compiler.

Most ports, unless specially marked, now compile using the base ("pre-installed") clang.

However, clang development is moderately rapid, and so the version of clang in base can be out of date frequently - not only do we have to wait for clang to be imported into base, but then we have to recompile from base (make world) to install it; the other alternative for the more enterprising operator would be to navigate the source tree and attempt to rebuild and reinstall just clang.

It would be a lot easier to just use the version of clang that's in ports under lang/clangXX. Installing that's easy enough, but then how does one modify the ports infrastructure to use that install of clang instead of the base install of clang?

migrated from serverfault.com Sep 13 '14 at 9:00

This question came from our site for system and network administrators.

8

You would treat the ports clang as an alternative compiler, just like when GCC was the default.

As per the FreeBSD wiki, add the following lines to /etc/make.conf (if you want to use clang for everything, even ports), or /etc/src.conf (if you want to use clang just for world and kernel):

CC=/path/to/clang
CXX=/path/to/clang++
CPP=/path/to/clang-cpp

Check where the ports clang binaries where installed under /usr/local and adjust accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.