# can not switch to gcc 4.8



## Bront_in_Hood (Oct 5, 2012)

I've installed FreeBSD 9.1 and am trying to switch to the GCC 4.8 compiler. I've complete instructions http://www.freebsd.org/doc/en/articles/custom-gcc/article.html.

But building chromium fails. And when I type *gcc -v* in the console I see 4.2.1 GCC version. Why? FreeBSD uses Clang by default? How did GCC 4.2.1 appear in my system? I only installed GCC 4.8 after installing FreeBSD.


----------



## freemason (Oct 5, 2012)

Bront_in_Hood said:
			
		

> FreBSD uses clang by default? How gcc 4.2.1 did appear in my system? I only installed gcc 4.8 after installing FReeBSD.


Old gcc is part of base system by default.
System is compiled with this old gcc by default.


----------



## Bront_in_Hood (Oct 5, 2012)

So. What do I need to force portmaster(8) to use new GCC to compile chromium and other ports? How to force "make" tool to use new gcc? /etc/make.conf is not enough?


----------



## Bront_in_Hood (Oct 5, 2012)

Is there any way to check which compiler used when running make command? May be gcc4.8 is currently used with portmaster and make in my system. But why it cannot build chromium? I want to ensure that I successfully switched to new gcc..


----------



## SNK (Oct 5, 2012)

Install lang/gcc48 and add to make.conf:


```
.if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc48)
CC=gcc48
CXX=g++48
CPP=cpp48
.endif
```


----------



## SNK (Oct 5, 2012)

www/chromium has been failing here as well though. But with clang.


----------



## break19 (Oct 6, 2012)

FYI. chromium builds fine with gcc46+ just fails with clang..


----------



## Bront_in_Hood (Oct 8, 2012)

SNK said:
			
		

> Install lang/gcc48 and add to make.conf:
> 
> 
> ```
> ...



Yes. This was done from the very beginning. But still installing chromium fails. May be it fails with gcc48. That is why I need an answer to the question. How to check which compiler command "make" uses when I install some port?


----------



## Bront_in_Hood (Oct 10, 2012)

Still waiting for answer..
If there is no any way to check which compiler used by make utility - this is an answer too. Please! I need clear and unambiguous statement!


----------



## kpa (Oct 10, 2012)

The make(1) command defaults to cc for C compiler. The port Makefiles can override the default and the quickest way to check what command is used as the C compiler is to run 
`$ make -V CC` in the port directory. For example


```
whitezone /usr/src % cd /usr/ports/www/chromium/      
whitezone /usr/ports/www/chromium % make -V CC
gcc46
whitezone /usr/ports/www/chromium %
```

In my case it returned gcc46.


----------



## Bront_in_Hood (Oct 10, 2012)

kpa said:
			
		

> The make(1) command defaults to cc for C compiler. The port Makefiles can override the default and the quickest way to check what command is used as the C compiler is to run
> `$ make -V CC` in the port directory. For example
> 
> 
> ...



Thank you! Now I see that it is gcc48. But if I comment every line in make.conf "make -V CC" still returns gcc48. Even after reboot. Why?


----------



## kpa (Oct 10, 2012)

I bet the port Makefile uses a form of USE_GCC=4.x+ that causes the ports build system to select the newest installed GCC on the system.

See /usr/ports/Mk/bsd.gcc.mk for details.


----------



## Bront_in_Hood (Jan 13, 2013)

kpa said:
			
		

> I bet the port Makefile uses a form of USE_GCC=4.x+ that causes the ports build system to select the newest installed GCC on the system.
> 
> See /usr/ports/Mk/bsd.gcc.mk for details.



I looked at this file. Actually did not get any usefull information from it. Actually it is a script written in language I don't know.

I have resumed my experiments with compilers.. I have installed gcc 4.8 and now can not force make utility use default compiler for dconf package. Yes. I tried to remove make.conf totally and tried to write this line in make.conf:

```
.if empty(.CURDIR:M/usr/ports/devel/dconf*)
```

And compiling process uses gcc48 and being terminated. Please! I need some bright and clear explanation what's wrong?

I have an idea to remove gcc 4.8 and compile dconf. And then intall gcc 4.8 back. But I believe there should be more plain method...


----------



## SNK (Jan 14, 2013)

```
.if ${.CURDIR:M*/devel/dconf}
USE_GCC?=4.2
.endif
```

Put this in your make.conf?


----------



## Bront_in_Hood (Jan 15, 2013)

Thanks!!
I found that the problem was in 'work' folder in /usr/ports/devel/dconf. After I ran command "make clean" installation started further with correct gcc version...
It failed again. But error message signals that compiler was not cause of this failure. My system is in inconsistent state I guess. But this is off topic...


----------

