Ports and Clang

This page is for ports status with the clang compiler. Below you will find some common problems and solutions to some of these problems. Also a list of ports that are known not to work and need to be investigated, like KDE for example.

This is part of the ClangBSD project.



For 10-CURRENT after OSVERSION 1000024 (svnref 242624) Clang is the default compiler on i386 and amd64. And is installed as cc, c++ and cpp. To build ports with clang on other releases, add the following lines to /etc/make.conf:


Notes on error classification

There is a script called processonelog on the build cluster that attempts to classify types of build errors. It is just a sequence of grep invocations that we keep updated with the results of various build failures over the years. You should not assume that its analysis is conclusive.

The errortypes created expressly for clang -exp runs:

Note the that following regressions might not be reported as clang, and instead as existing errors:

We know not all cases of clang will be caught by the script; the script needs to be optimized for performance reasons, and thus we cannot include all possible error cases.

Other notes:

Build failures with fixes




undefined or duplicate symbols while linking

clang defaults to gnu99, while gcc defaults to gnu89. This causes problems with the inline and restrict keywords (and possibly others). inline does different things in gnu89/gnu99

add "USE_CSTD=gnu89" to the port Makefile

Not respecting ${CC} and/or ${CXX}

Some ports have gcc/g++ hardcoded in their Makefiles.

CC ?= gcc, or reinplace line.

/usr/bin/nm: .foo.o: File format not recognized

clang produces llvm bitcode (used for LTO) when compiled with -O4.

Use -O3 or lower.

error: expected ';' at end of declaration, nested function definition

clang does not accept nested function definitions

Move the nested function to a static function at global scope.

problem with imake

See PortsAndClang/CppIssues. For an example log, see 2d-rewriter-1.4. (The classifier script guesses them all wrong, but most often as makefile.)

(!) even if you add the gnu89 stanza to the port Makefile, you still have to re-test your build with gcc because the build may break there. In that case you may have to make the gnu89 stanza conditional on compiler.

Build failures without fixes yet



Assertion failed: (something)

If you know what you're doing, reduce a testcase and report clang/llvm bug upstream. Otherwise, just explain us how to reproduce it and we'll do it for you.

UNREACHABLE executed at something

Clang crashes

Build failure false positives

Don't worry about these. They are not your problem.



port tries to fetch post-make fetch


port fails on pointyhat-west but not pointyhat


Runtime failures

Just because a port compiles, does not necessarily imply that it functions correctly:

If you're interested in helping

If you want to help with something mentioned (or not) below, join us on IRC and feel free to talk to us about it.


You may be able to save yourself some time by looking at the current ports/ PRs mentioning clang. Some already have patches.


PortsAndClang (last edited 2015-10-18 15:54:24 by MarkLinimon)