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.

Contents

Quickstart

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:

CC=clang
CXX=clang++
CPP=clang-cpp

Results from the build cluster

The following results from package builds with clang turned on are available:

run

INDEX

packages built

errors

notes

20130522 run on amd64-10

24527

19227

1720

HEAD run, might include non-clang issues

20121020 run on amd64-9

24010

21043

978

with workaround enabled

20121005 run on amd64-9

23955

18908

1104

devel/qmake4 failed (transient?)

20120902 run on amd64-9

23857

19177

1141

with fixed binutils

20120814 run on amd64-9

23789

18764

1156

20120809 run on amd64-9

23776

18730

1164

20120726 run on amd64-9

23803

16722

1060

bad run via various 'depend_package' errors

20120710 run on amd64-9

23753

18715

1162

20120628 run on amd64-9

23736

18049

1170

20120609 run on amd64-9

23661

18252

1147

20120516 run on amd64-9

23544

18379

1201

20120409 run on amd64-9

23371

18507

1145

20120316 run on amd64-9

23332

18497

1145

20120301 run on amd64-9

23298

18368

1185

20120203 run on amd64-9

23096

18834

1225

20120119 run on amd64-9

23035

18582

1136

20120108 run on amd64-9

23035

18331

1153

20111224 run on amd64-9

22938

18256

1208

20111218 run on amd64-9

22938

18036

1161

20111215 run on amd64-9

22911

17235

1150

20111205 run on amd64-9

22901

17173

1169

20111126 run on amd64-9

20111122 run on amd64-9

20110723 run on amd64-9

20110616 run on amd64-9

[2]

20110223 run on amd64-9

You will note hundreds of regressions from a comparable run, e.g., 19019 vs. 21677 as of 20120902. Counting builds that are not even attempted due to the above failures, this translates to 2658 unbuildable ports, not 1141 as you might assume from the statistics above.

You will have to do some detective work to figure out which ones are actually regressions running with clang; no exactly-equivalent run exists. You should start with latest amd64-9 on pointyhat. Also see false positives, below.

(!) [2] as of 20110629, the results of the 20110616 run were updated with the latest version of the classifier script, to eliminate more false positives.

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

Failure

Why

Solution

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

Failure

Solution

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.

Problem

Reference

port tries to fetch post-make fetch

PortsFailingInJails

port fails on pointyhat-west but not pointyhat

PortsFailingOnPointyhatWest

Specific port build failures

This list is just the most major failures.

(!) As of 20121005, a workaround has been committed to bsd.gcc.mk that allows various ports to "force" use of gcc, by specifying USE_GCC=any. This workaround is a "last resort" workaround that should only be used for non-trivial build failures. MarkLinimon has started doing some of the runs with the workaround enabled. Ports that build with the workaround are flagged with Y in the W column.

(!) To disable the workaround, and thus build all your ports with clang regardless, add the following line to /etc/make.conf:

FORCE_BASE_CC_FOR_TESTING=yes

Port

Affects

Example Errorlog

Maintainer

W?

Comments

audio/nas

428 (kde3, many others)

nas-1.9.3.log

multimedia@FreeBSD.org

Y

databases/gnome-db

16

gnome-db-0.2.96_15.log

gnome@FreeBSD.org

Y

databases/libgda3

9 (gnome)

libgda3-3.0.4_2.log

gnome@FreeBSD.org

Y

devel/liboil

12 (gnome2)

liboil-0.3.17.log

mm@FreeBSD.org

Y

devel/omniORB

16

omniORB-4.1.6.log

sem@FreeBSD.org

Y

devel/p5-EV

28

p5-EV-4.11,1.log

vovkasm@gmail.com

Y

devel/py-game

43

py27-game-1.9.1.log

mva@FreeBSD.org

Y

graphics/GraphicsMagick

98 (octave-forge)

GraphicsMagick-1.1.15_3,1.log

glarkin@FreeBSD.org

N

workaround fails in self-tests

graphics/devil

16

devil-1.7.8_9,1.log

amdmi3@FreeBSD.org

Y

lang/gcc42

132

gcc-4.2.5.20090325_5.log

gerald@FreeBSD.org

Y

lang/gcc44

14

gcc-4.4.7,1.log

gerald@FreeBSD.org

Y

lang/ghc

346 (haskell)

ghc-7.0.3_1.log

haskell@FreeBSD.org

Y

math/gnuplot

117 (octave-forge, others)

gnuplot-4.4.3.log

glewis@FreeBSD.org

Y

multimedia/x264

448 (kde4, gnome2)

x264-0.125.2201.log

mm@FreeBSD.org

Y

sysutils/lsof

17 (gnome2)

lsof-4.86A,6.log

ler@lerctr.org

Y

textproc/jade

20 (freebsd-doc)

jade-1.2.1_9.log

kuriyama@FreeBSD.org

Y

textproc/openjade

29

openjade-1.3.3p1_2.log

kuriyama@FreeBSD.org

Y

textproc/scim

27

scim-1.4.9.log

lx@FreeBSD.org

Y

www/libxul19

111 (gnome)

libxul-1.9.2.24.log

gecko@FreeBSD.org

N

workaround fails: configure wrongly decides CC is clang

x11/kdelibs3

302

kdelibs-3.5.10_10.log

ports@FreeBSD.org

mtree; workaround not yet tried

x11-toolkits/Xaw3d

56 (emacs)

Xaw3d-1.5E_4.log

dinoex@FreeBSD.org

Y

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.

Useful help

Help we don't want

PRs

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

Contacts

PortsAndClang (last edited 2013-10-12 19:56:40 by EitanAdler)