# FAVORITE_COMPILER and gcc version



## ikbendeman (Dec 1, 2013)

Running FreeBSD 9.2-STABLE and 9.2-RELEASE:

UPDATING:

```
20131008:
  AFFECTS: all users
  AUTHOR: bapt@FreeBSD.org

  A new USES has been added: compiler.mk, this uses allows porters to
  select a compiler for a given port based on the features the port needs
  By default this will always try to find Clang > 3.3.
  If the user prefers using GCC then the following macro should be added
  to user's make.conf: FAVORITE_COMPILER=gcc
```

Here is my make.conf:

```
CPUTYPE=athlon64
WITH_NEW_XORG=YES
#FAVORITE_COMPILER=gcc
#USE_GCC=4.9
WITH_KMS=YES
FORCE_MAKE_JOBS=YES
FORCE_JOBS_NUMBER=7
MAKE_JOBS_NUMBER=7
WITHOUT_DEBUG=YES
WITH_VDPAU=YES
QT4_OPTIONS=	CUPS QGTKSTYLE
WITH_PKGNG=YES
WITH_NLS=NO

.if empty(.CURDIR:M/usr/ports/multimedia/mplayer2*)
.if empty(.CURDIR:M/usr/ports/devel/llvm34*)
.if empty(.CURDIR:M/usr/ports/lang/clang34*)
.if empty(.CURDIR:M/usr/ports/devel/doxygen*) 
.if empty(.CURDIR:M/usr/ports/editors/abiword*)
.if empty(.CURDIR:M/usr/ports/net/asio*)
.if empty(.CURDIR:M/usr/ports/graphics/giflib*)
.if empty(.CURDIR:M/usr/ports/emulators/rtc*)
.if empty(.CURDIR:M/usr/ports/lang/python27*)
.if empty(.CURDIR:M/usr/ports/mail/thunderbird*)
.if empty(.CURDIR:M/usr/ports/www/firefox*)
CC=gcc49
CXX=g++49
CPP=cpp49
FAVORITE_COMPILER=gcc
USE_GCC=4.9
CFLAGS+= 	-mmmx -msse -msse2 -msse3 -mssse3 -m3dnow -msse4a -msse4.1 -msse4.2 -msse4 -mavx -mavx2
COPTFLAGS+=	-mmmx -msse -msse2 -msse3 -mssse3 -m3dnow -msse4a -msse4.1 -msse4.2 -msse4 -mavx -mavx2
CXXFLAGS+=	-mmmx -msse -msse2 -msse3 -mssse3 -m3dnow -msse4a -msse4.1 -msse4.2 -msse4 -mavx -mavx2

#WITH_SSP_PORTS=YES
BUILD_OPTIMIZED=YES
OPTIMIZED_CFLAGS=YES
.endif
.endif
.endif
.endif
.endif
.endif
.endif
.endif
.endif
.endif
.endif
```

When I try to use USE_GCC= it doesn't work. I have to set CC, CPP, and CXX the old way. Does anyone know why?


----------



## ikbendeman (Dec 1, 2013)

I should add that when I comment out CC, CXX, and CPP, instead of using gcc49 or g++49, etc. it just uses the system cc etc and that I have also tried the following:



			
				kpa said:
			
		

> Try setting these:
> 
> ```
> FAVORITE_COMPILER=gcc
> ...


----------



## ShelLuser (Dec 1, 2013)

What do you mean exactly with "_it doesn't work_"? If you could specify an example then that would help. Now, I assume that you're building a port and have determined that it doesn't use GCC, it might also shed some light if you could share how you checked for this.

Still, the way I understand it is that you can specify a preference but in the end it's still up to the port you're building to determine what compiler it uses (or requires). Most of the times it should use your preference, but whenever the port specifies which compiler is to be used then this could supersede your settings.

Personally I prefer clang over gcc, and therefore I don't specify any preference, but I still see GCC messages pop up every once in a while. I know you can override the whole thing with manually specifying flags such as CC, CPP and CXX but I'm not too sure anymore if that's a good idea (I used to define those to force my system to use Clang).


----------



## jb_fvwm2 (Dec 1, 2013)

I am also perplexed by these questions.  Perchance someone well-versed in an answer could put together a freebsd FreeBSD wiki page with working examples of all the things one can set in make.conf, and maybe a fully-commented one that one could uncomment parts of, so one could have a make.conf with Clang, a make.conf with aria2c vs fetch,  a make.conf with gcc47 rather than base, etc. simply by downloading the code, renaming it locally per revision. Not only that, but working examples (maybe within the make.conf itself) of how to set the variables at the command line definitively to override make.conf, if that is possible. 

I am (here) most of the way there to understanding it all, but that is not enough to write authoritatively about it, and probably wastes a few hours weekly with failing rebuilds that might otherwise complete.


----------

