# Using a newever version of Clang with ports



## ikbendeman (Aug 30, 2014)

I know in the handbook there's a whole page devoted to using a newer version of lang/gcc (https://www.freebsd.org/doc/en/articles/custom-gcc/article.html) but I'm interested in using a clang newer than 3.3 (3.3 is pretty old now). Am I correct that clang/34 is the latest "stable" clang available in the ports tree? README.hmtl shows:

```
clang32-3.2_3: C, Objective-C, and C++ compiler
clang33-3.3_7: C, Objective-C, and C++ compiler
clang34-3.4.2: C, Objective-C, and C++ compiler
clang35-3.5.0.r2: C, Objective-C, and C++ compiler
```
The r2 in lang/clang35 makes me think it stands for release candidate 2? There's also lang/clang-devel which is Clang 3.6. I have the newest binutils, but I don't know if that's even necessary with LLVM. Anyways, is there any editing of libmap.conf required as is needed for gcc? Should I jump to 3.4, 3.5, or 3.6? I would like to move forward and gain any new features or performance benefits, if stable. I suppose I could just use lang/gcc48 but I'm interested in Clang, partially because it seems like its better at automatically using the best features for your processor than GCC, where you often have to pass instruction set features. Also, in the Handbook, for using a newer GCC, it states a "minimum" of files that should be put into libmap.conf. Is it better to map all other .so files in respective directory, as well? Also, as time goes on, using GCC is going to break more ports as most people are now running Clang with the current ports tree, correct? I know Clang tries to be aware of GCCisms, but I don't think the opposite is true. Am I wrong?


----------



## Chris_H (Aug 30, 2014)

ikbendeman said:
			
		

> I know in the handbook there's a whole page devoted to using a newer version of lang/gcc (https://www.freebsd.org/doc/en/articles/custom-gcc/article.html) but I'm interested in using a clang newer than 3.3 (3.3 is pretty old now). Am I correct that clang/34 is the latest "stable" clang available in the ports tree? README.hmtl shows:
> 
> ```
> clang32-3.2_3: C, Objective-C, and C++ compiler
> ...


I too would be interested in hearing any feedback on this. But mostly from a performance improvement.


			
				ikbendeman said:
			
		

> I suppose I could just use lang/gcc48 but I'm interested in Clang, partially because it seems like its better at automatically using the best features for your processor than GCC, where you often have to pass instruction set features. Also, in the Handbook, for using a newer GCC, it states a "minimum" of files that should be put into libmap.conf. Is it better to map all other .so files in respective directory, as well? Also, as time goes on, using GCC is going to break more ports as most people are now running Clang with the current ports tree, correct? I know Clang tries to be aware of GCCisms, but I don't think the opposite is true. Am I wrong?


I wouldn't go so far as to say that. Granted, clang is default on 10+ systems. But that doesn't mean all the developers are jumping on it. Frankly, I'm currently maintaining ~12 ports, and growing. I only test against clang, but don't necessarily insist it pass. [FreeBSD] Clang, as you have no doubt noticed, has a long way to go, to catch up with Mac/OSX. Truth be told, I can get better performance on 500Mhz dual proc, Classic Mac hardware, with clang, than on a 3.2Ghz 4 core AMD, running clang on FreeBSD. Another interesting, and recent statistic; On RELENG_9, on the same hardware, I went from 0 to running new world && kernel in under 25 minutes, with GCC. Again, with all the same hardware, and 11-CURRENT && clang. I went from 0 to new world && kernel in greater that 4, and one half hours.
Point being; from all that clang _could_ offer. It's got a good ways to go, before everyone jumps ship. So I wouldn't be too hasty about dumping GCC, just yet. 

All the best.

--Chris


----------



## ikbendeman (Aug 30, 2014)

Which begs another question then as well, lang/gcc47 or lang/gcc48 and do I really need to do a full bootstrap? I have all the GCC's available in ports installed right now.  Just not using them ATM.


----------



## ikbendeman (Sep 10, 2014)

So, does anyone know, is there anything for make.conf equivelant to GCC's GCC_DEFAULT_VERSION flag? I've tried CLANG_DEFAULT_VERSION to no avail.


----------



## pkubaj (Sep 10, 2014)

There is no such a knob, but you can just set:

```
CC=clang35
CXX=clang++35
CPP=clang-cpp35
```


----------

