From b294993d630a50780b2513770315b85c11019f9e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 22 Dec 2013 17:51:33 +0000 Subject: [PATCH] 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 --- gnu/lib/csu/Makefile | 4 +--- gnu/lib/libgcc/Makefile | 4 +--- gnu/lib/libstdc++/Makefile | 4 +--- gnu/lib/libsupc++/Makefile | 4 +--- lib/atf/libatf-c/tests/Makefile | 4 +--- share/mk/bsd.sys.mk | 9 ++++++++- sys/conf/Makefile.arm | 12 ++++-------- tools/tools/ath/athstats/Makefile | 4 +--- tools/tools/net80211/wlanstats/Makefile | 4 +--- usr.bin/mkcsmapper/Makefile.inc | 4 +--- 10 files changed, 20 insertions(+), 33 deletions(-) diff --git a/gnu/lib/csu/Makefile b/gnu/lib/csu/Makefile index 05327f7e2bf1..02f540bad165 100644 --- a/gnu/lib/csu/Makefile +++ b/gnu/lib/csu/Makefile @@ -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 diff --git a/gnu/lib/libgcc/Makefile b/gnu/lib/libgcc/Makefile index 092e3219c982..d9521d44b6e6 100644 --- a/gnu/lib/libgcc/Makefile +++ b/gnu/lib/libgcc/Makefile @@ -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 diff --git a/gnu/lib/libstdc++/Makefile b/gnu/lib/libstdc++/Makefile index 935a8997a057..b0d45d63b651 100644 --- a/gnu/lib/libstdc++/Makefile +++ b/gnu/lib/libstdc++/Makefile @@ -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++ diff --git a/gnu/lib/libsupc++/Makefile b/gnu/lib/libsupc++/Makefile index 630387ab151f..acf1b58ed3c1 100644 --- a/gnu/lib/libsupc++/Makefile +++ b/gnu/lib/libsupc++/Makefile @@ -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++ diff --git a/lib/atf/libatf-c/tests/Makefile b/lib/atf/libatf-c/tests/Makefile index 0d13d9ce50dc..a5c2836f677c 100644 --- a/lib/atf/libatf-c/tests/Makefile +++ b/lib/atf/libatf-c/tests/Makefile @@ -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 diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index e297115b2bea..64815b3014cc 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -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" diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm index eacba7bb45fa..034bc4d7dc38 100644 --- a/sys/conf/Makefile.arm +++ b/sys/conf/Makefile.arm @@ -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} \ diff --git a/tools/tools/ath/athstats/Makefile b/tools/tools/ath/athstats/Makefile index a4348e533e65..d4cce3a64142 100644 --- a/tools/tools/ath/athstats/Makefile +++ b/tools/tools/ath/athstats/Makefile @@ -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 diff --git a/tools/tools/net80211/wlanstats/Makefile b/tools/tools/net80211/wlanstats/Makefile index 48df17fc1910..30067ef0e19b 100644 --- a/tools/tools/net80211/wlanstats/Makefile +++ b/tools/tools/net80211/wlanstats/Makefile @@ -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 diff --git a/usr.bin/mkcsmapper/Makefile.inc b/usr.bin/mkcsmapper/Makefile.inc index e0acc9b53f15..5a4cc6faa5ab 100644 --- a/usr.bin/mkcsmapper/Makefile.inc +++ b/usr.bin/mkcsmapper/Makefile.inc @@ -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