# Newer gcc. To be or not to be?



## Bront_in_Hood (Jan 19, 2013)

Hello everybody!

Is it harmful to change FreeBSD's default compiler (to gcc48 for example) and then build and install new kernel and make all set of necessary ports (excluding dconf)? And is there some risk when I build some ports (dconf, nvidia-driver) with default gcc42? Is there probability of conflict/incompatibility between ports compiled with different compilers?

And is there real benefit to meddle with system compiler? As I understood using newer gcc compiler can give me some performance increase? And if so is that benefit so considerable to start all this study?


----------



## throAU (Jan 19, 2013)

The way forward for FreeBSD is clang.

gcc is being phased out as it is GPL software, amongst other reasons.


I wouldn't personally try upgrading gcc from the default version as it is not likely to be tested or supported for kernel/world in future.


----------



## kpa (Jan 19, 2013)

CLANG is going to be the default compiler for the base OS, it's the best alternative to the old gcc(1) right now for world and kernel. For ports it's a bit different story because there's a huge amount of code that is written with GCC in mind. It's probably quite safe to use a newer GCC for ports by default.


----------



## Bront_in_Hood (Jan 19, 2013)

Ok! Thanks!
But what about perfomance increase? Should clang give me perceptible perfomance gain?
And as I know clang can not compile some ports too. And again I want to know is there any problems between ports compiled with different compilers?


----------



## jmccue (Jan 19, 2013)

Bront_in_Hood said:
			
		

> But what about perfomance increase? Should clang give me perceptible perfomance gain?


Best to google for the answer, to me, clang vs gcc is on it's way to being like "vi vs emacs" 



			
				Bront_in_Hood said:
			
		

> And as I know clang can not compile some ports too. And again I want to know is there any problems between ports compiled with different compilers?


I have not noticed any difference

John


----------



## vertexSymphony (Jan 20, 2013)

Bront_in_Hood said:
			
		

> Ok! Thanks!
> But what about perfomance increase? Should clang give me perceptible perfomance gain?



Comparable or slightly fast results on most benchmarks and really slow compared to gcc in others (due to lack of OpenMP)
In any case, if your code is good it will compile on both compilers: test your code with both



			
				Bront_in_Hood said:
			
		

> And as I know clang can not compile some ports too. And again I want to know is there any problems between ports compiled with different compilers?



In this *particular* case (GCC/Clang) the binaries seem compatible, so you won't have problems ... but with other compilers you have to worry about name mangling.

Regards.


----------



## gordon@ (Jan 22, 2013)

I wouldn't recommend recompiling your base OS with anything other than the compiler it shipped with. Unpredictable results will probably crop up. For your system compiler, stability is generally more important than the theoretical 3% speed boost you get compared to a different compiler.


----------

