This is an old revision of the document!
Compiler API
Introduction
Here's the proposed compiler interface for the system and for people. FreeBSD will support compiling itself with different compilers, and may support having multiple compilers in the base system. FreeBSD will support using external compilers to build the base, even if they aren't in the base (eg, building FreeBSD with gcc 4.6 or with some chip vendor's special compiler).
User Interface
Users control which compiler is used based on a few variables.
| Variable | Values | Meaning |
| SYSTEM_COMPILER | gcc or clang | The class of compiler that is installed as ${CC} |
| GCC_VERSION | 421 | gcc 4.2.1 – The version of the gcc compiler being used |
| CLANG_VERSION | 311 | clang 3.1.1 – The version of the clang compiler installed |
| EXT_COMP | armv6-freebsd- or /usr/local/fred/bin/ | Used to specify the location of the compiler (but not what kind of compiler it actually is). If this is set, then the external compiler is used. Otherwise the bootstrap default system compiler is used. The external compiler is really the entire external toolchain. |
Programmer Interface
Generally, the traditional names for the C compiler, etc are used for the defaults. The above variables would be used something like the following:
.if ${SYSTEM_COMPILER} == "gcc"
CFLAGS += -Wall
.endif
.if ${SYSTEM_COMPILER} == "clang"
CFLAGS += -Weverything
.endif
.if ${SYSTEM_COMPILER} == "gcc" && ${GCC_VERSION} < 421
CFLAGS += -Wno-turtle-graphics
.endif
Most of the yucky part of this will live in a file, bsd.compiler.mk, that will be used to keep things contained. Some individual makefiles might need tweaks, however, based on what they are compiling.