CLANG to GCC and back again

1-- There is a command that tells you *which jail*, for example. What would be the command that can tells you which compiler is being used?

2-- How do I make GCC the default compiler?

3-- Than how do I reconfigure CLANG back to being the default compiler?

I read this link but it don't refer to a CLANG solution and I don't want to make any at mistakes at guesting how it should be done. I'm running FreeBSD 10.1

https://www.freebsd.org/doc/en/articles/custom-gcc/article.html
 
1-- There is a command that tells you *which jail*, for example. What would be the command that can tells you which compiler is being used?
If you are asking which compiler the generic /usr/bin/cc is then cc -v would show you the full version info. Generally if a program requires a specific compiler, then it may specify something more specific like gcc48 or the like. It's a bit hard determine this just looking at the file system because /usr/bin/cc is a hard link that multiple files share. You can see this by running find /usr/bin -inum `ls -i /usr/bin/cc | cut -d ' ' -f 1` to see all the binaries that are the same file.

2-- How do I make GCC the default compiler?

3-- Than how do I reconfigure CLANG back to being the default compiler?

I read this link but it don't refer to a CLANG solution and I don't want to make any at mistakes at guesting how it should be done. I'm running FreeBSD 10.1

https://www.freebsd.org/doc/en/articles/custom-gcc/article.html

The guidance shown at the article you mentioned would be correct. Setting the /etc/make.conf entries for CC, CXX, and CPP would ensure GCC gets used. You can just remove the entries to switch back to clang(1).

Alternately, I'll point out that src.conf(5) shows that you can set the WITHOUT_CLANG_IS_CC and WITH_CLANG_IS_CC variables to determine what compiler that system actually uses. This may be useful if you have a very specific need and are compiling your system from scratch as the ports lang/gcc is probably the easier route to go and the one that allows you to change back and forth without changing the system.
 
Thanks 100-times junovitch@ That explain everything that the handbook was saying and more. I'm going to be a CLANG guy but I need GCC for a minute.
 
Glad that was helpful. If you are doing things within the confines of ports and just need it for one port you can also define it within the port. See /usr/ports/Mk/bsd.gcc.mk for details. Here's an excerpt:

# If your port needs a specific (minimum) version of GCC, you can easily
# specify that with a USE_GCC= statement. Unless absolutely necessary
# do so by specifying USE_GCC=X.Y+ which requests at least GCC version
# X.Y. To request a specific version omit the trailing + sign.
#
# Examples:
# USE_GCC= yes # port requires a current version of GCC
# # as defined in bsd.default-versions.mk.
# USE_GCC= any # port requires GCC 4.2 or later.
# USE_GCC= 4.9+ # port requires GCC 4.9 or later.
# USE_GCC= 4.9 # port requires GCC 4.9.
 
Since "default compiler" is another way of saying "whatever compiler make uses" one could ask make directly. The compiler being used also depends on the directory since the Makefile in there might override any defaults (i.e. redefine "CC" and/or "CXX"):

Code:
% make -f /dev/null -V CC -V CXX
cc
c++
% make -C /usr/src -V CC -V CXX
cc
c++
% make -C /usr/ports/lang/ghc -V CC -V CXX
gcc48
g++48
%
 
Back
Top