DragonFly kernel List (threaded) for 2011-10
Re: Clang and DragonFlyBSD
On 10/14/2011 05:33 AM, Sascha Wildner wrote:
On Fri, 14 Oct 2011 05:05:41 +0200, Juan Francisco Cantero Hurtado
Hi. I remember in the past someone tried compile DragonFlyBSD with
clang and corrected various warnings and errors. I don't know if
this person continues with this "project" but I think no. Also a
few days ago I found this old page in the wiki
Alex Hornung and I did some clang work in the past.
Yeah, the wiki page is old and not up-to-date.
DragonFlyBSD works very good with GCC but also clang is very good
reporting errors or inconsistencies in the code. This week I've
found a intermediate solution for to have the best of both worlds
without extra work.
In the "tools" directory of clang exists a tool for generate the
same reports of clang but without using clang for compile.
scan-build is a (perl) wrapper for gcc and generates html reports
with the warnings and errors of clang, but stills compiling the
code with gcc (or other compiler).
I think this tool is perfect for complement the daily snapshots
build. The developers don't need work with two compilers different
and they can look just the results in the server. scan-build
generates static html files, so you can copy the directory with
the results to http://mirror-master.dragonflybsd.org/snapshots/ .
Example: # cd /usr/src # scan-build make nativekernel
I've done many a scan-build on both our world and our kernel in the
past and fixed things.
The thing with scan-build is that you'll have to wade through all
the HTML to find the few issues that are actually _worth_ fixing.
But you also need browse for all files affected if compile with clang.
The same problem. Choose your poison :)
Not everything it reports is something we want to fix (for various
reasons), some categories are more interesting than others, and some
are simply false positive, etc.
I wouldn't want to run it daily as part of the snapshot build
though, as it takes a lot of time.
Yes, scan-build is very slow. nativekernel took me hours in my netbook.
My point is if the daily build include scan-build, the developers don't
need spend time in to compile with clang or the very big extra time in
I'm curious about how long takes the "scan-build make buildworld" in a
good computer :P
My overall experience is that people will be enthusiastic to get
such reports when you ask, but if you put them up, everyone quickly
goes on to do other things after viewing the first three reports or
so, because it really takes time to review. The issues worth fixing
are not delivered on a silver plate unfortunately. :)
This command generates the binaries with gcc but create a directory
with the reports in /tmp:
(download, decompress and open the index.html file)
The clang version in pkgsrc doesn't install scan-build. I've
reported the problem to the maintainer. Anyway, exists a temporary
solution for this problem:
I usually take clang's trunk which should build fine on dfly (though
I haven't tried lately) and copy the scan-build stuff to
- Install clang from pkgsrc. - Download the latest build for OSX
of scan-build from http://clang-analyzer.llvm.org/installation.html
. - Console: # tar -xjf checker-257.tar.bz2 # cd checker-257 # rm
-Rf bin # (with this scan-build will use the clang in PATH) #
export PATH=$PATH:`pwd` # cd /usr/src # scan-build make
Let me know if you have any question. Cheers :)
Juan Francisco Cantero Hurtado http://juanfra.info