To avoid having to explicitly test COMPILER_TYPE for setting

clang-specific or gcc-specific flags, introduce the following new
variables for use in Makefiles:

CFLAGS.clang
CFLAGS.gcc
CXXFLAGS.clang
CXXFLAGS.gcc

In bsd.sys.mk, these get appended to the regular CFLAGS or CXXFLAGS for
the right compiler.

MFC after:	1 week
This commit is contained in:
dim 2013-12-22 17:51:33 +00:00
parent 47ed2e7236
commit b8e518528f
10 changed files with 20 additions and 33 deletions

View File

@ -15,9 +15,7 @@ OBJS= crtbegin.o crtend.o crtbeginT.o
SOBJS= crtbeginS.o crtendS.o
CSTD?= gnu89
CFLAGS+= -DIN_GCC -DHAVE_LD_EH_FRAME_HDR -DDT_CONFIG -D__GLIBC__=3
.if ${COMPILER_TYPE} == "gcc"
CFLAGS+= -finhibit-size-directive -fno-toplevel-reorder
.endif
CFLAGS.gcc+= -finhibit-size-directive -fno-toplevel-reorder
CFLAGS+= -fno-inline-functions -fno-exceptions \
-fno-zero-initialized-in-bss -fno-asynchronous-unwind-tables \
-fno-omit-frame-pointer

View File

@ -112,9 +112,7 @@ LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
.if ${TARGET_CPUARCH} == "arm"
# from config/arm/t-strongarm-elf
CFLAGS+= -Dinhibit_libc -fno-inline
.if ${COMPILER_TYPE} == "clang"
CFLAGS+= -fheinous-gnu-extensions
.endif
CFLAGS.clang+= -fheinous-gnu-extensions
LIB1ASMSRC = lib1funcs.asm
LIB1ASMFUNCS = _dvmd_tls _bb_init_func

View File

@ -637,6 +637,4 @@ CLEANFILES+= ${VERSION_MAP}
# Filter out libc++-specific flags, and -std= flags above c++98 or gnu++98.
CXXFLAGS:= ${CXXFLAGS:N-stdlib=libc++:N-std=c++[01][13x]:N-std=gnu++[01][13x]}
.if ${COMPILER_TYPE} == "clang"
CXXFLAGS+= -stdlib=libstdc++
.endif
CXXFLAGS.clang+= -stdlib=libstdc++

View File

@ -57,6 +57,4 @@ VERSION_MAP= ${.CURDIR}/Version.map
# Filter out libc++-specific flags, and -std= flags above c++98 or gnu++98.
CXXFLAGS:= ${CXXFLAGS:N-stdlib=libc++:N-std=c++[01][13x]:N-std=gnu++[01][13x]}
.if ${COMPILER_TYPE} == "clang"
CXXFLAGS+= -stdlib=libstdc++
.endif
CXXFLAGS.clang+= -stdlib=libstdc++

View File

@ -10,12 +10,10 @@ ATF= ${.CURDIR:H:H:H:H}/contrib/atf
CFLAGS+= -I${ATF}
.if ${COMPILER_TYPE} == "clang"
# macros_test.c contains a double 'const const' which will be gone with
# the import of atf-0.18.
# TODO(jmmv): Remove this workaround once we do that update.
CFLAGS+= -Wno-duplicate-decl-specifier
.endif
CFLAGS.clang+= -Wno-duplicate-decl-specifier
FILESDIR= ${TESTSDIR}
FILES= macros_h_test.c

View File

@ -114,12 +114,19 @@ CWARNFLAGS+= -Wno-format
CWARNFLAGS+= -Wno-unknown-pragmas
.endif # IGNORE_PRAGMA
.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD)
.if !defined(EARLY_BUILD)
.if ${COMPILER_TYPE} == "clang"
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
CFLAGS+= -Qunused-arguments
CFLAGS+= ${CFLAGS.clang}
CXXFLAGS+= ${CXXFLAGS.clang}
.else # !CLANG
CFLAGS+= ${CFLAGS.gcc}
CXXFLAGS+= ${CXXFLAGS.gcc}
.endif # CLANG
.endif # !EARLY_BUILD
.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"

View File

@ -39,20 +39,16 @@ SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/ldscript.$M=ldscript.$M}
STRIP_FLAGS = -S
.endif
.if ${COMPILER_TYPE} != "clang"
CFLAGS += -mno-thumb-interwork
.endif
CFLAGS.gcc += -mno-thumb-interwork
.if empty(DDB_ENABLED)
.if defined(WITHOUT_ARM_EABI) && ${COMPILER_TYPE} != "clang"
CFLAGS += -mno-apcs-frame
.if defined(WITHOUT_ARM_EABI)
CFLAGS.gcc += -mno-apcs-frame
.endif
.elif !defined(WITHOUT_ARM_EABI)
CFLAGS += -funwind-tables
.if ${COMPILER_TYPE} == "clang"
# clang requires us to tell it to emit assembly with unwind information
CFLAGS += -mllvm -arm-enable-ehabi
.endif
CFLAGS.clang += -mllvm -arm-enable-ehabi
.endif
SYSTEM_LD_ = ${LD} -Bdynamic -T ldscript.$M.noheader ${LDFLAGS} \

View File

@ -21,9 +21,7 @@ CLEANFILES+= opt_ah.h
CFLAGS+=-DATH_SUPPORT_ANI
CFLAGS+=-DATH_SUPPORT_TDMA
.if (${COMPILER_TYPE} == "clang")
CFLAGS+=-fbracket-depth=512
.endif
CFLAGS.clang+= -fbracket-depth=512
opt_ah.h:
echo "#define AH_DEBUG 1" > opt_ah.h

View File

@ -7,8 +7,6 @@ BINDIR= /usr/local/bin
NO_MAN=
SRCS= statfoo.c wlanstats.c main.c
.if ${COMPILER_TYPE} == "clang"
CFLAGS+= -fbracket-depth=512
.endif
CFLAGS.clang+= -fbracket-depth=512
.include <bsd.prog.mk>

View File

@ -6,6 +6,4 @@ SRCS+= lex.l yacc.y
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../mkcsmapper \
-I${.CURDIR}/../../lib/libc/iconv \
-I${.CURDIR}/../../lib/libiconv_modules/mapper_std
.if ${COMPILER_TYPE} == "gcc"
CFLAGS+= --param max-inline-insns-single=64
.endif
CFLAGS.gcc+= --param max-inline-insns-single=64