diff options
author | brooks <brooks@FreeBSD.org> | 2012-09-13 16:00:46 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2012-09-13 16:00:46 +0000 |
commit | f17cb55447d48bc158b5154afa555cbb98793552 (patch) | |
tree | 026ab7b76d6035ab651e3761d73e9f9f465ed976 /share | |
parent | 1e4174de1a4f6a3cd6d80a545ec7187ecc402d68 (diff) | |
download | FreeBSD-src-f17cb55447d48bc158b5154afa555cbb98793552.zip FreeBSD-src-f17cb55447d48bc158b5154afa555cbb98793552.tar.gz |
Introduce a new make variable COMPILER_TYPE that specifies what
type of compiler is being used (currently clang or gcc). COMPILER_TYPE
is set in the new bsd.compiler.mk file based on the value of the CC
variable or, should it prove informative, by running ${CC} --version
and examining the output.
To avoid negative performance impacts in the default case and correct
value for COMPILER_TYPE type is determined and passed in the environment
of submake instances while building world.
Replace adhoc attempts at determining the compiler type by examining
CC or MK_CLANG_IS_CC with checks of COMPILER_TYPE. This eliminates
bootstrapping complications when first setting WITH_CLANG_IS_CC.
Sponsored by: DARPA, AFRL
Reviewed by: Yamaya Takashi <yamayan@kbh.biglobe.ne.jp>, imp, linimon
(with some modifications post review)
MFC after: 2 weeks
Diffstat (limited to 'share')
-rw-r--r-- | share/mk/Makefile | 3 | ||||
-rw-r--r-- | share/mk/bsd.compiler.mk | 21 | ||||
-rw-r--r-- | share/mk/bsd.sys.mk | 26 |
3 files changed, 35 insertions, 15 deletions
diff --git a/share/mk/Makefile b/share/mk/Makefile index 64c6549..5bab862 100644 --- a/share/mk/Makefile +++ b/share/mk/Makefile @@ -3,7 +3,8 @@ FILES= bsd.README FILES+= bsd.arch.inc.mk -FILES+= bsd.compat.mk bsd.cpu.mk bsd.dep.mk bsd.doc.mk bsd.dtrace.mk +FILES+= bsd.compat.mk bsd.compiler.mk bsd.cpu.mk +FILES+= bsd.dep.mk bsd.doc.mk bsd.dtrace.mk FILES+= bsd.endian.mk FILES+= bsd.files.mk bsd.crunchgen.mk bsd.incs.mk bsd.info.mk bsd.init.mk FILES+= bsd.kmod.mk diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk new file mode 100644 index 0000000..cca3968 --- /dev/null +++ b/share/mk/bsd.compiler.mk @@ -0,0 +1,21 @@ +# $FreeBSD$ + +.if !defined(COMPILER_TYPE) +. if ${CC:T:Mgcc} == "gcc" +COMPILER_TYPE:= gcc +. elif ${CC:T:Mclang} == "clang" +COMPILER_TYPE:= clang +. else +_COMPILER_VERSION!= ${CC} --version +. if ${_COMPILER_VERSION:Mgcc} == "gcc" +COMPILER_TYPE:= gcc +. elif ${_COMPILER_VERSION:M\(GCC\)} == "(GCC)" +COMPILER_TYPE:= gcc +. elif ${_COMPILER_VERSION:Mclang} == "clang" +COMPILER_TYPE:= clang +. else +.error Unable to determing compiler type for ${CC} +. endif +. undef _COMPILER_VERSION +. endif +.endif diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 28c1a18..cc752a2 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -8,6 +8,8 @@ # for GCC: http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Warning-Options.html +.include <bsd.compiler.mk> + # the default is gnu99 for now CSTD?= gnu99 @@ -28,8 +30,8 @@ CFLAGS+= -std=${CSTD} .if defined(WARNS) .if ${WARNS} >= 1 CWARNFLAGS+= -Wsystem-headers -.if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && \ - ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang)) +.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \ + || !defined(NO_WERROR.clang)) CWARNFLAGS+= -Werror .endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang) .endif # WARNS >= 1 @@ -43,8 +45,8 @@ CWARNFLAGS+= -W -Wno-unused-parameter -Wstrict-prototypes\ .if ${WARNS} >= 4 CWARNFLAGS+= -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\ -Wunused-parameter -.if !defined(NO_WCAST_ALIGN) && ((${MK_CLANG_IS_CC} == "no" && \ - ${CC:T:Mclang} != "clang") || !defined(NO_WCAST_ALIGN.clang)) +.if !defined(NO_WCAST_ALIGN) && (${COMPILER_TYPE} != "clang" \ + || !defined(NO_WCAST_ALIGN.clang)) CWARNFLAGS+= -Wcast-align .endif # !NO_WCAST_ALIGN && (!CLANG || !NO_WCAST_ALIGN.clang) .endif # WARNS >= 4 @@ -61,8 +63,7 @@ CWARNFLAGS+= -Wno-uninitialized CWARNFLAGS+= -Wno-pointer-sign # Clang has more warnings enabled by default, and when using -Wall, so if WARNS # is set to low values, these have to be disabled explicitly. -.if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \ - !defined(EARLY_BUILD) +.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) .if ${WARNS} <= 6 CWARNFLAGS+= -Wno-empty-body -Wno-string-plus-int .endif # WARNS <= 6 @@ -89,20 +90,18 @@ WFORMAT= 1 .if ${WFORMAT} > 0 #CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args -.if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \ - !defined(EARLY_BUILD) +.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) .if ${WARNS} <= 3 CWARNFLAGS+= -Wno-format-nonliteral .endif # WARNS <= 3 .endif # CLANG -.if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && \ - ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang)) +.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \ + || !defined(NO_WERROR.clang)) CWARNFLAGS+= -Werror .endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang) .endif # WFORMAT > 0 .endif # WFORMAT -.if defined(NO_WFORMAT) || ((${MK_CLANG_IS_CC} != "no" || \ - ${CC:T:Mclang} == "clang") && defined(NO_WFORMAT.clang)) +.if defined(NO_WFORMAT) || (${COMPILER_TYPE} == "clang" && defined(NO_WFORMAT.clang)) CWARNFLAGS+= -Wno-format .endif # NO_WFORMAT || (CLANG && NO_WFORMAT.clang) .endif # !NO_WARNS @@ -111,8 +110,7 @@ CWARNFLAGS+= -Wno-format CWARNFLAGS+= -Wno-unknown-pragmas .endif # IGNORE_PRAGMA -.if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \ - !defined(EARLY_BUILD) +.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) CLANG_NO_IAS= -no-integrated-as CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret |