tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Compiler selection support



Hi all,
the attached patch allows more fine grained compiler selection.

(a) USETOOLS_GCC and USETOOLS_PCC are dropped. I don't really see the
point in them.

(b) AVAILABLE_COMPILER has a list of compilers tried in order to provide
a given language frontend. false is included as fallback to make sure
the variables always end up with something sensible.

(c) A compiler is choosen for a language if the corresponding tool
variable is set (e.g. TOOL_CC.gcc for the C frontend using GCC) and
it is not black listed in the current scope (e.g. UNSUPPORTED_COMPILER.pcc
says that PCC is not supported here). The decision is stored in
ACTIVE_CC etc, later to be used for compiler-specific flags like
COPTS_COMPILER.gcc.

Comments?

Joerg
Index: bsd.own.mk
===================================================================
RCS file: /home/joerg/repo/netbsd/src/share/mk/bsd.own.mk,v
retrieving revision 1.664
diff -u -p -r1.664 bsd.own.mk
--- bsd.own.mk  9 May 2011 14:36:48 -0000       1.664
+++ bsd.own.mk  17 May 2011 19:36:21 -0000
@@ -191,21 +191,42 @@ SIZE=             ${TOOLDIR}/bin/${MACHINE_GNU_PLAT
 STRIP=         ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip
 .endif                                                                 #  }
 
-.if defined(HAVE_GCC) && ${USETOOLS_GCC:Uyes} == "yes"                 #  {
-CC=            ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
-CPP=           ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp
-CXX=           ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++
-FC=            ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g77
-OBJC=          ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
-.endif                                                                 #  }
-
-.if defined(HAVE_PCC) && ${USETOOLS_PCC:Uyes} == "yes"
-CC=            ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc
-CPP=           ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-cpp
-CXX=           false
-FC=            ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-f77
-OBJC=          false
-.endif
+# Clang supports C, C++ and Objective C
+TOOL_CC.clang=         ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang
+TOOL_CPP.clang=                ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp
+TOOL_CXX.clang=                ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang++
+TOOL_OBJC.clang=       ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang
+
+# GCC supports C, C++, Fortran and Objective C
+TOOL_CC.gcc=   ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
+TOOL_CPP.gcc=  ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp
+TOOL_CXX.gcc=  ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++
+TOOL_FC.gcc=   ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g77
+TOOL_OBJC.gcc= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
+
+# PCC supports C and Fortran
+TOOL_CC.pcc=           ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc
+TOOL_CPP.pcc=          ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-cpp
+TOOL_FC.pcc=           ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-f77
+
+# Fallback to ensure that all variables are defined to something
+TOOL_CC.false=         false
+TOOL_CPP.false=                false
+TOOL_CXX.false=                false
+TOOL_FC.false=         false
+TOOL_OBJC.false=       false
+
+AVAILABLE_COMPILER=    ${HAVE_PCC:Dpcc} ${HAVE_LLVM:Dclang} ${HAVE_GCC:Dgcc} 
false
+
+.for _t in CC CPP CXX FC OBJC
+ACTIVE_${_t}=  ${AVAILABLE_COMPILER:@.c.@ ${ 
!defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : 
}@:[1]}
+.endfor
+# Duplicated to avoid make bugs
+CC=            ${TOOL_CC.${ACTIVE_CC}}
+CPP=           ${TOOL_CPP.${ACTIVE_CPP}}
+CXX=           ${TOOL_CXX.${ACTIVE_CXX}}
+FC=            ${TOOL_FC.${ACTIVE_FC}}
+OBJC=          ${TOOL_OBJC.${ACTIVE_OBJC}}
 
 #
 # Make sure DESTDIR is set, so that builds with these tools always


Home | Main Index | Thread Index | Old Index