# LLVM or GCC for ports?



## troberts (Nov 20, 2011)

I am returning to FreeBSD, from Gentoo, and it is my understanding that FreeBSD (OS and kernel) is now built with Clang/LLVM. Is this true? If so, when FreeBSD was using GCC it made sense to use the same version of the compiler for the system and ports so everything is on the same page, so to speak, but if there are two different compilers, can we now use the latest version of GCC for ports or should we stick to the GCC compiler FreeBSD has used in the past? 

Also, I have installed FreeBSD 9, downloaded the sources, and built 9-STABLE with the following cputype in my etc/make.conf file:

```
CPUTYPE?=k8-sse3
```
The compile output that scrolled on the screen showed -march to be -march=prescott. My processor is an AMD Sempron 3400+ Palermo socket 939. I am not too worried about "presott" showing because before, using k8, it would show -march=athlon-mp but I just want to mention it in case it matters.


----------



## xibo (Nov 20, 2011)

It depends on what you're trying to setup, but for your average desktop you cannot use clang (yet), as some ports will either not build or not run properly when compiled with clang. Also, using a more recent version of gcc might end with nonworking ports (I had not-compiling audio/musicbrainz the other day).

If you want to build FreeBSD with, go ahead. But remember some of the newer marchs are quire buggy, which is also the reason why llvm-3.0 was postponed. To see what march you "should" be, compile and run the autodetection with clang++:
`# clang++ -o /tmp/whatami /usr/src/contrib/llvm/lib/Support/Host.cpp /tmp/whatami`
if you have a HEAD or 9-STABLE source tree in /usr/src, that is.


----------



## troberts (Nov 20, 2011)

xibo, thank you for your input. I had no intention of trying to compile ports with Clang/LLVM, but if FreeBSD no longer uses GCC to compile itself then I figured it should be ok to use the current version (lang/gcc) to compile ports.

I tried to use the command you gave, but a critical error was returned because:

```
'llvm/Support/Host.h' file not found
```


----------



## xibo (Nov 21, 2011)

Tried and found it's rather complicated to add all the required compiler flags/includes/macros. The one in the attachment should compile "out of the box".

EDIT:
Also, FreeBSD is still buildable by base gcc which also won't go away soon. In fact the iso files provided on the ftp contain gcc builds of FreeBSD, while a clang versions needs to be build on one's own.


----------



## troberts (Nov 26, 2011)

xibo, your file worked and it said my CPU is a k8-sse3, just like I thought it would be since that is what /proc/cpuinfo (when I had Gentoo installed) said it was. Out of curiosity, I changed the cputype in my /etc/make.conf to CPUTYPE?=k8 and the compile output showed -march=athlon-mp so I am not worried about seeing -march=prescott when using CPUTYPE?=k8-sse3.


----------

