LLVM or GCC for ports?

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:
Code:
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.
 
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.
 
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:
Code:
'llvm/Support/Host.h' file not found
 
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.
 

Attachments

  • host.cpp
    10.1 KB · Views: 226
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.
 
Back
Top