Solved Using gcc as a default compiler (FreeBSD 13.0) [SOLVED]

Greetings everyone and sorry for bothering the community, but I got terribly messed up and I think I need your help very much.
I have just installed FreeBSD for the first time willing to make it my default OS for music production and other working purposes, but unfortunately got confused with replacing clang compiler with gcc. There are many recipes on this forum, and I've been reading them for over two days already, but some pf them are quite old, some of them are different between each other (o_O), so now I feel dumb enough to ask you, guys. 🙃
The first thing I've done on my freshly installed copy of FreeBSD 13.0 was:
# cd /usr/ports/lang/gcc && make install clean
but then I realized that I have no idea how to make gcc my daily compiler for using the ports tree. I've been reading the manuals for make.conf file, also tried both "setenv" and other things, but it all comes back to clang after each reboot.
I would also like to add that that is my first time installing FreeBSD as a daily OS, and I thought that my GNU/Linux experience would help me. As far as you can see, it didn't. :p
Any help would be highly appreciated, and I would like to apologize both for possible mistakes (English is not my native language) & for disturbing you. Maybe, this topic would be useful for someone who's searching for the answer just like me.
Thank you!
 
Greetings everyone and sorry for bothering the community, but I got terribly messed up and I think I need your help very much.
I have just installed FreeBSD for the first time willing to make it my default OS for music production and other working purposes, but unfortunately got confused with replacing clang compiler with gcc. There are many recipes on this forum, and I've been reading them for over two days already, but some pf them are quite old, some of them are different between each other (o_O), so now I feel dumb enough to ask you, guys. 🙃
The first thing I've done on my freshly installed copy of FreeBSD 13.0 was:

but then I realized that I have no idea how to make gcc my daily compiler for using the ports tree. I've been reading the manuals for make.conf file, also tried both "setenv" and other things, but it all comes back to clang after each reboot.
I would also like to add that that is my first time installing FreeBSD as a daily OS, and I thought that my GNU/Linux experience would help me. As far as you can see, it didn't. :p
Any help would be highly appreciated, and I would like to apologize both for possible mistakes (English is not my native language) & for disturbing you. Maybe, this topic would be useful for someone who's searching for the answer just like me.
Thank you!
If a port requires a specific gcc it will pull it in and use it; there's no need to make gcc the base compiler as clang is perfectly capable. (The OS is compiled using it).
If you have some code using quirky & gcc specific non-clang requirements, then change your code. Fortunately (or unfortunately depending on your viewpoint) clang has adopted a lot of gcc functionality anyway.
 
I learned that "forcing" a specific compiler is a bad idea in general.
Yep. It's best to let the system itself figure out what it needs. Maintainers usually do a good job and there's rarely a need to muck around with it. Especially if you're not familiar with the intricate details between the various versions of GCC and Clang.
 
If a port requires a specific gcc it will pull it in and use it; there's no need to make gcc the base compiler as clang is perfectly capable. (The OS is compiled using it).
If you have some code using quirky & gcc specific non-clang requirements, then change your code. Fortunately (or unfortunately depending on your viewpoint) clang has adopted a lot of gcc functionality anyway.
OK, that's a nice answer, thank you very much! I am about to stick to clang then. Actually, that is the point which got me confused: different ways to do it for the different gcc versions...
Appreciate your help! :)
 
GCC matches his avatar picture more... ?
What's wrong with my avatar? :confused:
Yep. It's best to let the system itself figure out what it needs. Maintainers usually do a good job and there's rarely a need to muck around with it. Especially if you're not familiar with the intricate details between the various versions of GCC and Clang.
Thanks for your advice! I will stick to clang then for now. ;-)
 
I will stick to clang then for now. ;-)
A port will use whatever compiler it requires to build correctly. Most ports use the standard LLVM (on 13.0 that's 11.0.1, on 12.2 its 10.0.1), some ports might require GCC9 or GCC10, some other ports might specifically require LLVM10 or LLVM11. The port's maintainer already figured that out for you. There's around 40.000 ports, there simply is no "one-size-fits-all" compiler.
 
Agreed. Whilst it should compile with GCC (I tend to feel it is a bug if it fails), many porters / maintainers just don't have time to test on every compiler out there. So they target the system compiler (Clang) unless specific requirements on GCC.
 
Marked this topic as solved. Sticking to clang while working with ports.
Thanks everyone! Despite some offtops, it was one of the fastest community reactions I've ever seen. ;-)
 
As kpedersen alludes to there can be very significant differences between versions of both clang & gcc. You're best to stick to the one the entire OS was built with (version 11) than go adventuring into compiler accumulation.
 
I don't think it's possible to make GCC the default compiler (but AFAIK there are still platforms where GCC is the default compiler).

Even if it would be possible, it wouldn't make sense. Software compiled with GCC needs to link some runtime libraries and will therefore depend on the whole GCC port. You only do this if GCC is strictly required.

In theory, ports should be tested with GCC because there are architectures that have it as the default compiler. A port can of course also explicitly request llvm (which would then be taken from ports on a GCC architecture).

Well, short story: Use the default, it makes sense ;)
 
I don't think it's possible to make GCC the default compiler (but AFAIK there are still platforms where GCC is the default compiler).

Even if it would be possible, it wouldn't make sense. Software compiled with GCC needs to link some runtime libraries and will therefore depend on the whole GCC port. You only do this if GCC is strictly required.

In theory, ports should be tested with GCC because there are architectures that have it as the default compiler. A port can of course also explicitly request llvm (which would then be taken from ports on a GCC architecture).

Well, short story: Use the default, it makes sense ;)
Already doing that, using clang for further work. Merci!
 
And while you are at it - use scan-build make on your own projects. Then check what clang has to tell you.
 
Back
Top