# A few questions about GCC



## mroberts23 (Sep 15, 2009)

Hello World!

I would to preface this post by saying that I am very new to FreeBSD.  In the past I have been known to use source based linux distros like LFS, Arch, and Gentoo.  I have switched to FreeBSD because of my curiosity and a large amount of free time.  Currently I am running FreeBSD 8 Beta 4.

My main question is where can I find information about upgrading GCC to the latest stable version (4.4.1 at the time of this writing) and if I do so what potential problems will I have to deal with?

I understand that the install process is as simple typing "sudo make install clean" from the proper ports dir, but the Handbook and FAQ have very little else to say on the subject.  I have seen no warnings about breaking "buildworld" or "buildkernel" but I would like to ask those of you have have more experience than myself before I compile myself into a corner.


Thank you for your time,

MRoberts23


----------



## DutchDaemon (Sep 15, 2009)

AFAIK, buildworld/kernel uses the base system's gcc (/usr/bin/gcc), not any gcc installed by a port (which would end up in /usr/local/bin/gcc). You'll just have to call the correct gcc depending on what you want to compile. Replacing the base system's gcc is probably not advisable, as it will be replaced by the next OS update, and it may break the OS/kernel build process. I'm assuming you know that FreeBSD's base system is a centrally designed, developed, coherent whole that needs to remain intact (some exceptions exist, mostly in the 'contrib' part of the base system, where ports like Sendmail, Bind and Openssl can replace the base system's counterparts without much ado).


----------



## phoenix (Sep 15, 2009)

mroberts23 said:
			
		

> I have seen no warnings about breaking "buildworld" or "buildkernel" but I would like to ask those of you have have more experience than myself before I compile myself into a corner.



Unless you plan on fixing all the errors that will show up, and then submitting patches back to the FreeBSD Project for those, and work out a plan to upgrade the base GCC for everyone ...  then don't bother upgrading the base GCC.

Leave the base GCC (/usr/bin/cc and whatnot) alone.  There's a lot of work that goes into integrating a specific version of GCC into the core of FreeBSD, and to make it build the world and kernel correctly.  It's nowhere near as simple as "remove GCC X, install GCC Y".

Unless you just want to play of course.    Then have at her.

Note also that there are licensing issues, due to the stupid change to GPLv3 for the latest versions of GCC.  This is one of the main reasons that GCC in FreeBSD is at the version its at, and no newer.

If you want to use a more current version of GCC for your own projects, or for compiling ports, then you can install any of the /usr/ports/lang/gcc* ports.  Just be sure to edit your Makefiles to point to /usr/local/bin/cc* instead of /usr/bin/cc*.


----------



## morbit (Sep 16, 2009)

Put 
	
	



```
CC=/usr/local/bin/gcc44
CXX=/usr/local/bin/g++44
```
in /etc/make.conf to override base gcc, and see for yourself errors/warnings that will come up while buildworld. 

If you want to play with some fancy CFLAGS like -march=core2 -msse4.1 you will also need to replace as (there is quite fresh port of binutils that provides it). After that, it may be possible to even build some ports! 

//All informations provided for amusement only.


----------

