# Error compiling kernel with gcc46



## adihodos (Jan 11, 2011)

Hello, I'm trying to compile my kernel with Dtrace support enabled. I'm using gcc46 as the default compiler. The full command is `# make buildkernel KERNCONF=cat_kernel WITH_CTF=1`. But as soon as the build process starts I get this error :

```
--------------------------------------------------------------
>>> stage 2.3: build tools
--------------------------------------------------------------
cd /usr/obj/usr/src/sys/cat_kernel;  MAKESRCPATH=/usr/src/sys/dev/aic7xxx/aicasm  make SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF  -f 
/usr/src/sys/dev/aic7xxx/aicasm/Makefile
Warning: Object directory not changed from original /usr/obj/usr/src/sys/cat_kernel
gcc46 -O2 -pipe -nostdinc -I/usr/include -I. -I/usr/src/sys/dev/aic7xxx/aicasm -std=gnu99  -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -
Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-
align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wno-pointer-sign -c 
/usr/src/sys/dev/aic7xxx/aicasm/aicasm.c
gcc46: not found
*** Error code 127
```

I have these settings in /etc/make.conf :

```
# added by use.perl 2010-12-31 21:42:54
PERL_VERSION=5.10.1
.if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc46)
CC=gcc46
CXX=g++46
CPP=cpp46
CFLAGS+=-msse2
.endif
```

It looks like gcc46 fails to find something but I don't know what. Can someone help me please ?


----------



## SirDice (Jan 11, 2011)

If you're trying to use a non-standard compiler to compile the base you're pretty much on your own.

Remove all the CC and related flags and try again.


----------



## adihodos (Jan 11, 2011)

I've removed any custom flags from /etc/make.conf, but to no effect, I get the same error.


----------



## SirDice (Jan 11, 2011)

Do a `# make clean` before starting again.


----------



## adihodos (Jan 11, 2011)

Tried that, same error. Is clang supported ?


----------



## DutchDaemon (Jan 11, 2011)

clang is experimentally used in -CURRENT (FreeBSD 9).

Remove /usr/obj and run a [cmd=]make cleanworld && make cleandir[/cmd] in /usr/src to be thorough. Make sure there are no symlinks or aliases expanding gcc to the wrong (non-base) compilers.


----------



## adihodos (Jan 12, 2011)

Same error. This is driving me nuts, I really need DTrace enabled.


----------



## SirDice (Jan 12, 2011)

If it's the same error it means it's still trying to use gcc46 instead of the default.

Try removing lang/gcc46 and see if it switches back.


----------



## adihodos (Jan 12, 2011)

I haven't tried with base GCC, I wanted to use a more recent compiler, since the handbook said that it's possible to gain something like 10% more performance with recent compilers. I'll try with GCC4.2 and see if it works.


----------



## DutchDaemon (Jan 12, 2011)

Where in The Handbook does it say that? I'm pretty sure that The Handbook does not suggest anywhere that one should use anything other than the base system compilers for building the kernel and world.


----------



## adihodos (Jan 12, 2011)

My bad, not the handbook but this http://www.freebsd.org/doc/en_US.ISO8859-1/articles/custom-gcc/article.html.


----------



## SIFE (Jan 12, 2011)

As I know, FreeBSD currently does not support external compiler to build kernel or world, see this: http://forums.freebsd.org/showthread.php?t=14662


----------



## DutchDaemon (Jan 13, 2011)

adihodos, the title of that article is "Using newer version of GCC and binutils *with the FreeBSD Ports Collection*". And even there it is a gigantic minefield. But absolutely, positively: keep it away from the base system!


----------



## adihodos (Jan 13, 2011)

I've compiled it with base gcc, everything is ok and I can use DTrace. Thanks everyone.


----------



## trasz@ (Jan 17, 2011)

Just for the record - I've successfully compiled kernel (9.0-CURRENT, about six months ago) with GCC 4.5 with this in /etc/make.conf:

C
	
	



```
C=            /usr/local/bin/gcc45
CXX=           /usr/local/bin/g++45
CWARNFLAGS=    -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
               -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
               -Wno-pointer-sign -D__FreeBSD_cc_version=0 \
               -Wno-unused-function -Wno-inline -Wno-format \
               -Wno-uninitialized -Wno-array-bounds -Wno-missing-prototypes
NO_WERROR=    1
```


----------



## DutchDaemon (Jan 17, 2011)

Let's not take that as an encouragement .. we have enough problems to solve around here 

This may be a nice experiment in a developer environment (e.g. the FreeBSD mailing lists), but I truly hope not to see the forums flooded with people demolishing their systems using uninformed flags and ill-understood compiler options (simply copied without understanding them) and complaining that 'a developer said it would work'.

If anyone does demolish their systems doing this: don't complain on these forums. Please stick to the base system compilers.


----------



## SIFE (Jan 18, 2011)

> Let's not take that as an encouragement .. we have enough problems to solve around here


He just encourage me .


----------



## DutchDaemon (Jan 18, 2011)

If you encounter any problems, go to the FreeBSD dev mailing lists .... because you'll get the predictable reply here: "Use the base system compilers." ..


----------



## SIFE (Jan 18, 2011)

just to assure people who curious to use what Me trasz suggest, it will not work with FreeBSD 8.1 STABLE either with gcc44 or gcc45.


> If you encounter any problems, go to the FreeBSD dev mailing lists .... because you'll get the predictable reply here: "Use the base system compilers." ..


I am still have problem memory usage with recent gnome and you expect me ask question like this, at least when I fix my problem .


----------



## dandelion (Jan 19, 2011)

adihodos said:
			
		

> gcc46: not found
> *** Error code 127


You can remove PATH overriding from src/Makefile

```
PATH=  /sbin:/bin:/usr/sbin:/usr/bin
```
It's unlikely to break build as /usr/local/bin is *after* /usr/bin in PATH by default, so it'll not pick wrong binutils by accident.

trasz' example is boring because it excludes one from using ccache/distcc and other creative PATH tricks. And using CC=/usr/local/libexec/ccache/gcc46 won't work, guess why?


----------

