Permalink
Browse files

Define several extra macros in bsd.sys.mk and sys/conf/kern.pre.mk, to

get rid of testing explicitly for clang (using ${CC:T:Mclang}) in
individual Makefiles.

Instead, use the following extra macros, for use with clang:
- NO_WERROR.clang       (disables -Werror)
- NO_WCAST_ALIGN.clang  (disables -Wcast-align)
- NO_WFORMAT.clang	(disables -Wformat and friends)
- CLANG_NO_IAS		(disables integrated assembler)
- CLANG_OPT_SMALL	(adds flags for extra small size optimizations)

As a side effect, this enables setting CC/CXX/CPP in src.conf instead of
make.conf!  For clang, use the following:

CC=clang
CXX=clang++
CPP=clang-cpp

MFC after:	2 weeks
  • Loading branch information...
DimitryAndric committed Feb 28, 2012
1 parent 68c08a0 commit fc18e4ce2d19dd1524639d9db8841c7b30038922
View
@@ -18,12 +18,10 @@ CFLAGS+=${SENDMAIL_CFLAGS}
WARNS?= 2
-.if ${CC:T:Mclang} == "clang"
# Unfortunately, clang gives warnings about sendmail code that cannot
# be turned off yet. Since this is contrib code, and we don't really
# care about the warnings, just make them non-fatal for now.
-NO_WERROR=
-.endif
+NO_WERROR.clang=
LIB= sm
@@ -16,10 +16,8 @@ SYM_MAPS+=${.CURDIR}/Symbol.map
SYMBOL_MAPS=${SYM_MAPS}
VERSION_DEF=${.CURDIR}/../libc/Versions.def
-.if ${CC:T:Mclang} == "clang"
# Unfortunately, clang gives an incorrect warning about alignment in
# arch/i386/libpthread_md.c, so turn that off for now.
-NO_WCAST_ALIGN=
-.endif
+NO_WCAST_ALIGN.clang=
.include <bsd.lib.mk>
View
@@ -47,10 +47,6 @@ ACFLAGS+= -Wa,--noexecstack
#SRCS+= gvmat64.S
#CFLAGS+= -DASMV -DNO_UNDERLINE
#ACFLAGS+= -Wa,--noexecstack
-#.if ${CC:T:Mclang} == "clang"
-## XXX: clang integrated-as doesn't grok .intel_syntax directives yet
-#ACFLAGS+= ${.IMPSRC:T:Mgvmat64.S:C/^.+$/-no-integrated-as/}
-#.endif
#.endif
VERSION_DEF= ${.CURDIR}/Versions.def
@@ -71,3 +67,7 @@ test: example minigzip
echo hello world | ./minigzip | ./minigzip -d )
.include <bsd.lib.mk>
+
+## XXX: clang integrated-as doesn't grok .intel_syntax directives yet
+#ACFLAGS.gvmat64.S= ${CLANG_NO_IAS}
+#ACFLAGS+= ${ACFLAGS.${.IMPSRC:T}}
@@ -12,12 +12,10 @@ CFLAGS+=-I${SENDMAIL_DIR}/include -I.
WARNS?= 2
WFORMAT=0
-.if ${CC:T:Mclang} == "clang"
# Unfortunately, clang gives warnings about sendmail code that cannot
# be turned off yet. Since this is contrib code, and we don't really
# care about the warnings, just make them non-fatal for now.
-NO_WERROR=
-.endif
+NO_WERROR.clang=
LIBSMDIR= ${.OBJDIR}/../../lib/libsm
LIBSM= ${LIBSMDIR}/libsm.a
View
@@ -17,12 +17,10 @@ LDADD= ${LIBSM}
WARNS?= 2
-.if ${CC:T:Mclang} == "clang"
# Unfortunately, clang gives warnings about sendmail code that cannot
# be turned off yet. Since this is contrib code, and we don't really
# care about the warnings, just make them non-fatal for now.
-NO_WERROR=
-.endif
+NO_WERROR.clang=
SRCS+= sm_os.h
CLEANFILES+=sm_os.h
View
@@ -9,10 +9,8 @@ SRCS= fsdb.c fsdbutil.c \
pass5.c setup.c utilities.c ffs_subr.c ffs_tables.c
CFLAGS+= -I${.CURDIR}/../fsck_ffs
WARNS?= 2
-.if ${CC:T:Mclang} == "clang"
# Work around a problem with format string warnings and ntohs macros.
-NO_WFORMAT=
-.endif
+NO_WFORMAT.clang=
LDADD= -ledit -ltermcap
DPADD= ${LIBEDIT} ${LIBTERMCAP}
.PATH: ${.CURDIR}/../fsck_ffs ${.CURDIR}/../../sys/ufs/ffs
View
@@ -28,7 +28,7 @@ CFLAGS += -std=${CSTD}
. if defined(WARNS)
. if ${WARNS} >= 1
CWARNFLAGS += -Wsystem-headers
-. if !defined(NO_WERROR)
+. if !defined(NO_WERROR) && (${CC:T:Mclang} != "clang" || !defined(NO_WERROR.clang))
CWARNFLAGS += -Werror
. endif
. endif
@@ -42,7 +42,7 @@ 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)
+. if !defined(NO_WCAST_ALIGN) && (${CC:T:Mclang} != "clang" || !defined(NO_WCAST_ALIGN.clang))
CWARNFLAGS += -Wcast-align
. endif
. endif
@@ -84,12 +84,12 @@ WFORMAT = 1
. if ${WFORMAT} > 0
#CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
CWARNFLAGS += -Wformat=2 -Wno-format-extra-args
-. if !defined(NO_WERROR)
+. if !defined(NO_WERROR) && (${CC:T:Mclang} != "clang" || !defined(NO_WERROR.clang))
CWARNFLAGS += -Werror
. endif
. endif
. endif
-. if defined(NO_WFORMAT)
+. if defined(NO_WFORMAT) || (${CC:T:Mclang} == "clang" && defined(NO_WFORMAT.clang))
CWARNFLAGS += -Wno-format
. endif
.endif
@@ -98,6 +98,12 @@ CWARNFLAGS += -Wno-format
CWARNFLAGS += -Wno-unknown-pragmas
.endif
+.if ${CC:T:Mclang} == "clang"
+CLANG_NO_IAS = -no-integrated-as
+CLANG_OPT_SMALL = -mllvm -stack-alignment=8 -mllvm -inline-threshold=3 \
+ -mllvm -enable-load-pre=false
+.endif
+
.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
# Don't use -Wstack-protector as it breaks world with -Werror.
@@ -19,12 +19,6 @@ SRCS= ${PROG}.S
OPTS ?= -DVOLUME_SERIAL -DPXE
CFLAGS += ${OPTS}
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+= ${.IMPSRC:T:Mboot0.S:C/^.+$/-no-integrated-as/}
-CFLAGS+= ${.IMPSRC:T:Mboot0ext.S:C/^.+$/-no-integrated-as/}
-.endif
-
# Flags used in the boot0.S code:
# 0x0f all valid partitions enabled.
# 0x80 'packet', use BIOS EDD (LBA) extensions instead of CHS
@@ -83,3 +77,8 @@ CFLAGS+=-DFLAGS=${BOOT_BOOT0_FLAGS} \
LDFLAGS=-e start -Ttext ${BOOT_BOOT0_ORG} -Wl,-N,-S,--oformat,binary
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.boot0.S= ${CLANG_NO_IAS}
+CFLAGS.boot0ext.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
@@ -40,14 +40,8 @@ CFLAGS= -Os \
-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
- -Winline --param max-inline-insns-single=100
-
-.if ${CC:T:Mclang} == "clang"
-CFLAGS+= -mllvm -stack-alignment=8 -mllvm -inline-threshold=3 \
- -mllvm -enable-load-pre=false
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+= ${.IMPSRC:T:Mboot1.S:C/^.+$/-no-integrated-as/}
-.endif
+ -Winline --param max-inline-insns-single=100 \
+ ${CLANG_OPT_SMALL}
LDFLAGS=-static -N --gc-sections
@@ -89,9 +83,7 @@ boot2.out: ${BTXCRT} boot2.o sio.o
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
boot2.o: boot2.s
-.if ${CC:T:Mclang} == "clang"
${CC} ${ACFLAGS} -c boot2.s
-.endif
SRCS= boot2.c boot2.h
@@ -115,3 +107,7 @@ machine:
.endif
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.boot1.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
@@ -13,11 +13,6 @@ BOOT_BTX_FLAGS=0x0
CFLAGS+=-DBTX_FLAGS=${BOOT_BTX_FLAGS}
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+=${.IMPSRC:T:Mbtx.S:C/^.+$/-no-integrated-as/}
-.endif
-
.if defined(BTX_SERIAL)
BOOT_COMCONSOLE_PORT?= 0x3f8
BOOT_COMCONSOLE_SPEED?= 9600
@@ -32,3 +27,7 @@ ORG= 0x9000
LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.btx.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
@@ -11,11 +11,10 @@ CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS}
CFLAGS+=-DBTXLDR_VERBOSE
.endif
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+=${.IMPSRC:T:Mbtxldr.S:C/^.+$/-no-integrated-as/}
-.endif
-
LDFLAGS=-e start -Ttext ${LOADER_ADDRESS} -Wl,-N,-S,--oformat,binary
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.btxldr.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
@@ -36,11 +36,6 @@ CFLAGS= -DBOOTPROG=\"gptboot\" \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
-Winline --param max-inline-insns-single=100
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+= ${.IMPSRC:T:Mgptldr.S:C/^.+$/-no-integrated-as/}
-.endif
-
LDFLAGS=-static -N --gc-sections
# Pick up ../Makefile.inc early.
@@ -79,3 +74,7 @@ machine:
.endif
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
@@ -34,11 +34,6 @@ CFLAGS= -DBOOTPROG=\"gptzfsboot\" \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
-Winline --param max-inline-insns-single=100
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+= ${.IMPSRC:T:Mgptldr.S:C/^.+$/-no-integrated-as/}
-.endif
-
LDFLAGS=-static -N --gc-sections
# Pick up ../Makefile.inc early.
@@ -77,3 +72,7 @@ machine:
.endif
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
@@ -54,11 +54,6 @@ CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \
# the location of libstand
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+= ${.IMPSRC:T:Mamd64_tramp.S:C/^.+$/-no-integrated-as/}
-.endif
-
.if ${MACHINE_CPUARCH} == "amd64"
CLEANFILES+= machine
machine:
@@ -67,6 +62,10 @@ machine:
.include <bsd.lib.mk>
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.amd64_tramp.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
+
.if ${MACHINE_CPUARCH} == "amd64"
beforedepend ${OBJS}: machine
.endif
@@ -23,11 +23,6 @@ CFLAGS+=-DPROBE_KEYBOARD
CFLAGS+=-DALWAYS_SERIAL
.endif
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+=${.IMPSRC:T:Mpxeldr.S:C/^.+$/-no-integrated-as/}
-.endif
-
LOADERBIN= ${.OBJDIR}/../loader/loader.bin
CLEANFILES+= ${BOOT}.tmp
@@ -46,3 +41,7 @@ ${LOADER}: ${LOADERBIN} ${BTXLDR} ${BTXKERN}
-b ${BTXKERN} ${LOADERBIN}
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.pxeldr.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
@@ -31,11 +31,6 @@ CFLAGS= -DBOOTPROG=\"zfsboot\" \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
-Winline --param max-inline-insns-single=100
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+= ${.IMPSRC:T:Mzfsldr.S:C/^.+$/-no-integrated-as/}
-.endif
-
LDFLAGS=-static -N --gc-sections
# Pick up ../Makefile.inc early.
@@ -90,3 +85,7 @@ machine:
.endif
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.zfsldr.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
@@ -13,11 +13,6 @@ BOOT_BTX_FLAGS=0x0
CFLAGS+=-DBTX_FLAGS=${BOOT_BTX_FLAGS}
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+=${.IMPSRC:T:Mbtx.S:C/^.+$/-no-integrated-as/}
-.endif
-
.if defined(BTX_SERIAL)
BOOT_COMCONSOLE_PORT?= 0x238
BOOT_COMCONSOLE_SPEED?= 9600
@@ -32,3 +27,7 @@ ORG= 0x9000
LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.btx.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
@@ -11,11 +11,10 @@ CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS}
CFLAGS+=-DBTXLDR_VERBOSE
.endif
-.if ${CC:T:Mclang} == "clang"
-# XXX: clang integrated-as doesn't grok .codeNN directives yet
-CFLAGS+=${.IMPSRC:T:Mbtxldr.S:C/^.+$/-no-integrated-as/}
-.endif
-
LDFLAGS=-e start -Ttext ${LOADER_ADDRESS} -Wl,-N,-S,--oformat,binary
.include <bsd.prog.mk>
+
+# XXX: clang integrated-as doesn't grok .codeNN directives yet
+CFLAGS.btxldr.S= ${CLANG_NO_IAS}
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
View
@@ -40,13 +40,12 @@ CFLAGS+= -fno-omit-frame-pointer
MKMODULESENV+= MACHINE=amd64
-.if ${CC:T:Mclang} == "clang"
# XXX: clang integrated-as doesn't grok .codeNN directives yet
-ASM_CFLAGS+= ${.IMPSRC:T:Macpi_wakecode.S:C/^.+$/-no-integrated-as/}
-ASM_CFLAGS+= ${.IMPSRC:T:Mia32_sigtramp.S:C/^.+$/-no-integrated-as/}
-ASM_CFLAGS+= ${.IMPSRC:T:Mlinux32_locore.s:C/^.+$/-no-integrated-as/}
-ASM_CFLAGS+= ${.IMPSRC:T:Mmpboot.S:C/^.+$/-no-integrated-as/}
-.endif
+ASM_CFLAGS.acpi_wakecode.S= ${CLANG_NO_IAS}
+ASM_CFLAGS.ia32_sigtramp.S= ${CLANG_NO_IAS}
+ASM_CFLAGS.linux32_locore.s= ${CLANG_NO_IAS}
+ASM_CFLAGS.mpboot.S= ${CLANG_NO_IAS}
+ASM_CFLAGS+= ${ASM_CFLAGS.${.IMPSRC:T}}
%BEFORE_DEPEND
View
@@ -34,11 +34,10 @@ MACHINE=i386
MKMODULESENV+= MACHINE=${MACHINE}
-.if ${CC:T:Mclang} == "clang"
# XXX: clang integrated-as doesn't grok .codeNN directives yet
-ASM_CFLAGS+= ${.IMPSRC:T:Macpi_wakecode.S:C/^.+$/-no-integrated-as/}
-ASM_CFLAGS+= ${.IMPSRC:T:Mmpboot.s:C/^.+$/-no-integrated-as/}
-.endif
+ASM_CFLAGS.acpi_wakecode.S= ${CLANG_NO_IAS}
+ASM_CFLAGS.mpboot.s= ${CLANG_NO_IAS}
+ASM_CFLAGS+= ${ASM_CFLAGS.${.IMPSRC:T}}
%BEFORE_DEPEND
Oops, something went wrong.

0 comments on commit fc18e4c

Please sign in to comment.