FreeBSD and LLVM

Ed Schouten ed at
Wed May 21 17:23:54 UTC 2008

Hello Stefan,

(CC'ing this back to the list)

* Stefan Esser <se at> wrote:
> this is great news! Can you provide your patches to upgrade the port
> to 2.3-pre?

I could, but I patched the ports rather poorly. The plists are
incorrect. I just incremented the version numbers, updated the distinfo
and made some changes to the llvm-gcc4 port to use the proper wrksrc.

> Did you, by chance, record build times with llvm-gcc compared to the
> system compiler?
> What about the quality of generated code (size, runtime)?
> Did you manage to get a meaning-ful program built that could be used
> as a benchmark?

I was able to compile a kernel with SMP disabled and PAE enabled. Other
combinations will not work. LLVM doesn't seem to be properly capable of
dealing with the xchg instruction in inline asm statements. A non-SMP
PAE kernel doesn't seem to use them :-)

Below are some build stats:

| llvm:
| 	114.04s user 24.86s system 176% cpu 1:18.73 total
	^ output of time(1)
| 	-rwxr-xr-x  1 ed  wheel  4456839 May 21 12:59
	^ output of ls -l kernel before stripping
| 	-rwxr-xr-x  1 ed  wheel  3596008 May 21 13:16
	^ output of ls -l kernel after stripping
| 	   text    data     bss     dec     hex
| 	3286323  229605  462280 3978208  3cb3e0
	^ output of size(1) after stripping

| gcc:
| 	119.04s user 22.64s system 178% cpu 1:19.27 total
| 	-rwxr-xr-x  1 ed  wheel  4098317 May 21 12:33
| 	-rwxr-xr-x  1 ed  wheel  3463448 May 21 12:57
| 	   text    data     bss     dec     hex
| 	3185574  220965  460216 3866755  3b0083

As you can see, compilation time is about the same, but the kernel image
is a little bigger. I don't know anything about the quality of the
generated code.

> If 2.3-pre allows the kernel to boot and run, then many user-land
> programs should work as well. Testing a make world (and preparing
> the infrastructure to support llvm in addition to gcc and icc might
> be worthwhile ...).

We should really try that. Unfortunately I'm quite busy, hacking on the
TTY layer. ;-)

> You probably know about the clang project, which tries to completely
> replace the gcc parts needed for llvm-gcc ...

Yes. I haven't looked at it yet. It doesn't seem to be in Ports yet. Any
takers? ;-)

 Ed Schouten <ed at>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url :

More information about the freebsd-hackers mailing list