From owner-freebsd-toolchain@FreeBSD.ORG Thu Sep 13 15:06:49 2012 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 25130106566B; Thu, 13 Sep 2012 15:06:49 +0000 (UTC) (envelope-from yamayan@kbh.biglobe.ne.jp) Received: from rcpt-expgw.biglobe.ne.jp (rcpt-expgw.biglobe.ne.jp [IPv6:2001:260:401:16::3]) by mx1.freebsd.org (Postfix) with ESMTP id 0A5058FC12; Thu, 13 Sep 2012 15:06:47 +0000 (UTC) Received: from vc-gw.biglobe.ne.jp by rcpt-expgw.biglobe.ne.jp (shby/5910021009) with SMTP id q8DF6j7o025903; Fri, 14 Sep 2012 00:06:45 +0900 Received: from smtp-gw.biglobe.ne.jp ([172.21.175.156]) by vc-gw.biglobe.ne.jp (kbkr/0716090908) with ESMTP id q8DF6jho005456; Fri, 14 Sep 2012 00:06:45 +0900 X-Biglobe-Sender: Received: from [192.168.0.100] (KD027083060020.ppp-bb.dion.ne.jp [27.83.60.20]) by smtp-gw.biglobe.ne.jp id AAJQAC15AFDC; Fri, 14 Sep 2012 00:06:45 +0900 (JST) Message-ID: <5051F68F.4000807@kbh.biglobe.ne.jp> Date: Fri, 14 Sep 2012 00:06:55 +0900 From: Yamaya Takashi User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:15.0) Gecko/20120911 Thunderbird/15.0 MIME-Version: 1.0 To: Brooks Davis , freebsd-toolchain@freebsd.org References: <20120912163822.GA86491@lor.one-eyed-alien.net> In-Reply-To: <20120912163822.GA86491@lor.one-eyed-alien.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: Re: improving bootstrapping of WITH_CLANG_IS_CC X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Sep 2012 15:06:49 -0000 you send to wrong address, "\"freebsd-toolchain@freebsd.orgo\":" On 2012/09/13 01:38, Brooks Davis wrote: > On Wed, Sep 12, 2012 at 10:01:14AM -0500, Brooks Davis wrote: >> On Wed, Sep 12, 2012 at 09:49:51PM +0900, Yamaya Takashi wrote: >>> In Makefile.inc1, >>> both WMAKECOMPILER_TYPE and WMAKE_COMPILER_TYPE exist. >>> It's maybe bug. >> It is. I'm not actually sure why it didn't result in more invocations >> of gcc in my test. I'm testing a fix now. > Here's a fixed version. Thank you for the review! > > -- Brooks > > Index: share/mk/Makefile > =================================================================== > --- share/mk/Makefile (revision 240210) > +++ share/mk/Makefile (working copy) > @@ -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 > Index: share/mk/bsd.compiler.mk > =================================================================== > --- share/mk/bsd.compiler.mk (revision 0) > +++ share/mk/bsd.compiler.mk (working copy) > @@ -0,0 +1,20 @@ > +# $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 > +. endif > +.endif > Index: share/mk/bsd.sys.mk > =================================================================== > --- share/mk/bsd.sys.mk (revision 240210) > +++ share/mk/bsd.sys.mk (working copy) > @@ -8,6 +8,8 @@ > > # for GCC: http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Warning-Options.html > > +.include > + > # the default is gnu99 for now > CSTD?= gnu99 > > @@ -28,8 +30,8 @@ > .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 @@ > .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-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 @@ > .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-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 > Index: Makefile.inc1 > =================================================================== > --- Makefile.inc1 (revision 240210) > +++ Makefile.inc1 (working copy) > @@ -46,6 +46,7 @@ > > .include > .include > +.include > > # We must do share/info early so that installation of info `dir' > # entries works correctly. Do it first since it is less likely to > @@ -235,7 +236,8 @@ > PATH=${BPATH}:${PATH} \ > WORLDTMP=${WORLDTMP} \ > VERSION="${VERSION}" \ > - MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" > + MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ > + COMPILER_TYPE=${COMPILER_TYPE} > BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \ > ${BMAKEENV} ${MAKE} -f Makefile.inc1 \ > DESTDIR= \ > @@ -270,6 +272,16 @@ > .if ${MK_CDDL} == "no" > WMAKEENV+= NO_CTF=1 > .endif > +.if ${CC:T:Mgcc} == "gcc" > +WMAKE_COMPILER_TYPE= gcc > +.elif ${CC:T:Mclang} == "clang" > +WMAKE_COMPILER_TYPE= clang > +.elif ${MK_CLANG_IS_CC} == "no" > +WMAKE_COMPILER_TYPE= gcc > +.else > +WMAKE_COMPILER_TYPE= clang > +.endif > +WMAKEENV+= COMPILER_TYPE=${WMAKE_COMPILER_TYPE} > WMAKE= ${WMAKEENV} ${MAKE} -f Makefile.inc1 DESTDIR=${WORLDTMP} > > .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64" > @@ -313,7 +325,8 @@ > CC="${CC} ${LIB32FLAGS}" \ > CXX="${CXX} ${LIB32FLAGS}" \ > LIBDIR=/usr/lib32 \ > - SHLIBDIR=/usr/lib32 > + SHLIBDIR=/usr/lib32 \ > + COMPILER_TYPE=${WMAKE_COMPILER_TYPE} > > LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \ > -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \ > Index: sys/conf/kmod.mk > =================================================================== > --- sys/conf/kmod.mk (revision 240210) > +++ sys/conf/kmod.mk (working copy) > @@ -73,6 +73,7 @@ > .endif > > .include > +.include > > .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S > > @@ -108,7 +109,7 @@ > # for example. > CFLAGS+= -I@/contrib/altq > > -.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang" > +.if ${COMPILER_TYPE} != "clang" > CFLAGS+= -finline-limit=${INLINE_LIMIT} > CFLAGS+= --param inline-unit-growth=100 > CFLAGS+= --param large-function-growth=1000 > Index: sys/conf/kern.pre.mk > =================================================================== > --- sys/conf/kern.pre.mk (revision 240210) > +++ sys/conf/kern.pre.mk (working copy) > @@ -4,6 +4,7 @@ > # of the definitions that need to be before %BEFORE_DEPEND. > > .include > +.include > > # backwards compat option for older systems. > MACHINE_CPUARCH?=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc64/powerpc/} > @@ -34,7 +35,7 @@ > .endif > .endif > .if ${MACHINE_CPUARCH} == "amd64" > -.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang" > +.if ${COMPILER_TYPE} != "clang" > COPTFLAGS?=-O2 -frename-registers -pipe > .else > COPTFLAGS?=-O2 -pipe > @@ -84,7 +85,7 @@ > > CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS} > CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h > -.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang" > +.if ${COMPILER_TYPE} != "clang" > CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT} > .if ${MACHINE_CPUARCH} != "mips" > CFLAGS+= --param inline-unit-growth=100 > @@ -101,7 +102,7 @@ > # XXX LOCORE means "don't declare C stuff" not "for locore.s". > ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} > > -.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang" > +.if ${COMPILER_TYPE} == "clang" > CLANG_NO_IAS= -no-integrated-as > .endif > > Index: sys/conf/kern.mk > =================================================================== > --- sys/conf/kern.mk (revision 240210) > +++ sys/conf/kern.mk (working copy) > @@ -15,7 +15,7 @@ > # Disable a few warnings for clang, since there are several places in the > # kernel where fixing them is more trouble than it is worth, or where there is > # a false positive. > -.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang" > +.if ${COMPILER_TYPE} == "clang" > NO_WCONSTANT_CONVERSION= -Wno-constant-conversion > NO_WARRAY_BOUNDS= -Wno-array-bounds > NO_WSHIFT_COUNT_NEGATIVE= -Wno-shift-count-negative > @@ -52,7 +52,7 @@ > # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42 > # > .if ${MACHINE_CPUARCH} == "i386" > -.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang" > +.if ${COMPILER_TYPE} != "clang" > CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2 > .else > CFLAGS+= -mno-aes -mno-avx > @@ -100,7 +100,7 @@ > # (-mfpmath= is not supported) > # > .if ${MACHINE_CPUARCH} == "amd64" > -.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang" > +.if ${COMPILER_TYPE} == "clang" > CFLAGS+= -mno-aes -mno-avx > .endif > CFLAGS+= -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \