diff options
Diffstat (limited to 'share/mk/bsd.sys.mk')
-rw-r--r-- | share/mk/bsd.sys.mk | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index ca59d0b693806..a587b0d28b15d 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -24,7 +24,6 @@ CFLAGS+= -std=iso9899:1999 .else # CSTD CFLAGS+= -std=${CSTD} .endif # CSTD -.if !defined(NO_WARNS) # -pedantic is problematic because it also imposes namespace restrictions #CFLAGS+= -pedantic .if defined(WARNS) @@ -52,9 +51,8 @@ CWARNFLAGS+= -Wcast-align .if ${WARNS} >= 6 CWARNFLAGS+= -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls\ -Wold-style-definition -.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) && \ - !defined(NO_WMISSING_VARIABLE_DECLARATIONS) -CWARNFLAGS+= -Wmissing-variable-declarations +.if !defined(NO_WMISSING_VARIABLE_DECLARATIONS) +CWARNFLAGS.clang+= -Wmissing-variable-declarations .endif .endif # WARNS >= 6 .if ${WARNS} >= 2 && ${WARNS} <= 4 @@ -65,27 +63,25 @@ 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 ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) .if ${WARNS} <= 6 -CWARNFLAGS+= -Wno-empty-body -Wno-string-plus-int +CWARNFLAGS.clang+= -Wno-empty-body -Wno-string-plus-int .if ${COMPILER_VERSION} > 3.3 -CWARNFLAGS+= -Wno-unused-const-variable +CWARNFLAGS.clang+= -Wno-unused-const-variable .endif .endif # WARNS <= 6 .if ${WARNS} <= 3 -CWARNFLAGS+= -Wno-tautological-compare -Wno-unused-value\ +CWARNFLAGS.clang+= -Wno-tautological-compare -Wno-unused-value\ -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion .endif # WARNS <= 3 .if ${WARNS} <= 2 -CWARNFLAGS+= -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter +CWARNFLAGS.clang+= -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter .endif # WARNS <= 2 .if ${WARNS} <= 1 -CWARNFLAGS+= -Wno-parentheses +CWARNFLAGS.clang+= -Wno-parentheses .endif # WARNS <= 1 .if defined(NO_WARRAY_BOUNDS) -CWARNFLAGS+= -Wno-array-bounds +CWARNFLAGS.clang+= -Wno-array-bounds .endif # NO_WARRAY_BOUNDS -.endif # CLANG .endif # WARNS .if defined(FORMAT_AUDIT) @@ -95,11 +91,9 @@ WFORMAT= 1 .if ${WFORMAT} > 0 #CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args -.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) .if ${WARNS} <= 3 -CWARNFLAGS+= -Wno-format-nonliteral +CWARNFLAGS.clang+= -Wno-format-nonliteral .endif # WARNS <= 3 -.endif # CLANG .if !defined(NO_WERROR) && !defined(NO_WERROR.${COMPILER_TYPE}) CWARNFLAGS+= -Werror .endif # !NO_WERROR && !NO_WERROR.${COMPILER_TYPE} @@ -108,32 +102,29 @@ CWARNFLAGS+= -Werror .if defined(NO_WFORMAT) || defined(NO_WFORMAT.${COMPILER_TYPE}) CWARNFLAGS+= -Wno-format .endif # NO_WFORMAT || NO_WFORMAT.${COMPILER_TYPE} -.endif # !NO_WARNS .if defined(IGNORE_PRAGMA) CWARNFLAGS+= -Wno-unknown-pragmas .endif # IGNORE_PRAGMA -.if !defined(EARLY_BUILD) .if ${COMPILER_TYPE} == "clang" +# Would love to do this unconditionally, but can't due to its use in +# kernel build coupled with CFLAGS.${TARGET} feature CLANG_NO_IAS= -no-integrated-as +.endif CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret -CFLAGS+= -Qunused-arguments +CFLAGS.clang+= -Qunused-arguments .if ${MACHINE_CPUARCH} == "sparc64" # Don't emit .cfi directives, since we must use GNU as on sparc64, for now. -CFLAGS+= -fno-dwarf2-cfi-asm +CFLAGS.clang+= -fno-dwarf2-cfi-asm .endif # SPARC64 # The libc++ headers use c++11 extensions. These are normally silenced because # they are treated as system headers, but we explicitly disable that warning # suppression when building the base system to catch bugs in our headers. # Eventually we'll want to start building the base system C++ code as C++11, # but not yet. -CXXFLAGS+= -Wno-c++11-extensions -.endif # CLANG -CFLAGS+= ${CFLAGS.${COMPILER_TYPE}} -CXXFLAGS+= ${CXXFLAGS.${COMPILER_TYPE}} -.endif # !EARLY_BUILD +CXXFLAGS.clang+= -Wno-c++11-extensions .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \ ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" @@ -142,9 +133,19 @@ SSP_CFLAGS?= -fstack-protector CFLAGS+= ${SSP_CFLAGS} .endif # SSP && !IA64 && !ARM && !MIPS -# Allow user-specified additional warning flags -CFLAGS+= ${CWARNFLAGS} +# Allow user-specified additional warning flags, plus compiler specific flag overrides. +# Unless we're early in the build, in which case don't (which is lame, this should +# be handled by NO_WARNS which needs to migrate to something else. +.if !defined(NO_WARNS) && !defined(EARLY_BUILD) +CFLAGS+= ${CWARNFLAGS} ${CWARNFLAGS.${COMPILER_TYPE}} +.endif +# Not sure this is 100% kosher, but I think that EARLY_BUILD must be only +# defined when we're not building programs that use the CFLAGS.foo feature. +.if !defined(EARLY_BUILD) +CFLAGS+= ${CFLAGS.${COMPILER_TYPE}} +CXXFLAGS+= ${CXXFLAGS.${COMPILER_TYPE}} +.endif # Tell bmake not to mistake standard targets for things to be searched for # or expect to ever be up-to-date. |