From owner-svn-src-head@FreeBSD.ORG Mon Oct 24 04:40:09 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B647106564A; Mon, 24 Oct 2011 04:40:09 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail01.syd.optusnet.com.au (mail01.syd.optusnet.com.au [211.29.132.182]) by mx1.freebsd.org (Postfix) with ESMTP id ABE898FC0A; Mon, 24 Oct 2011 04:40:08 +0000 (UTC) Received: from c122-106-165-191.carlnfd1.nsw.optusnet.com.au (c122-106-165-191.carlnfd1.nsw.optusnet.com.au [122.106.165.191]) by mail01.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p9O4e4w8012220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 24 Oct 2011 15:40:05 +1100 Date: Mon, 24 Oct 2011 15:40:04 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Dimitry Andric In-Reply-To: <4EA473CA.8050104@FreeBSD.org> Message-ID: <20111024145107.R994@besplex.bde.org> References: <201110231627.p9NGR47P046269@svn.freebsd.org> <4EA473CA.8050104@FreeBSD.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Robert Millan Subject: Re: svn commit: r226665 - head/sys/conf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2011 04:40:09 -0000 On Sun, 23 Oct 2011, Dimitry Andric wrote: > On 2011-10-23 18:27, Robert Millan wrote: >> Log: >> Conditionalize a pair of FreeBSD GCC extensions so that its CFLAGS are >> only >> used with FreeBSD GCC. Bug in non-FreeBSD gcc. >> Modified: head/sys/conf/kern.mk >> ============================================================================== >> --- head/sys/conf/kern.mk Sun Oct 23 16:04:07 2011 (r226664) >> +++ head/sys/conf/kern.mk Sun Oct 23 16:27:03 2011 (r226665) >> @@ -1,11 +1,21 @@ >> # $FreeBSD$ >> >> +.if ${CC:T:Mclang} != "clang" >> +FREEBSD_GCC!= ${CC} --version | grep FreeBSD || true >> +.endif >> + Runtime tests like this should never be used in central makefiles since they are slow. This one doesn't even work. Use some user-defined-macro like NON_FREEBSD_GCC. >> # >> # Warning flags for compiling the kernel and components of the kernel: >> # >> +.if ${FREEBSD_GCC} >> +# FreeBSD extensions, not available in upstream GCC >> +format_extensions= -fformat-extensions >> +no_align_long_strings= -mno-align-long-strings >> +.endif How can this help? Builds should still fail due to -Wformat (-Werror) errors when the FreeBSD format extensions are used, and kernel code uses them a lot. You can turn off -Werror or -Wformat but then the non-FreeBSD gcc is even more unsuitable for development. > Note: this breaks builds where CC=clang, with: > >>>> Kernel build for GENERIC started on Sun Oct 23 22:01:23 CEST 2011 > ... > make KERNEL=kernel cleandir > "/usr/src/sys/conf/kern.mk", line 10: Malformed conditional (${FREEBSD_GCC}) > "/usr/src/sys/conf/kern.mk", line 14: if-less endif > make: fatal errors encountered -- cannot continue > ... > > Since our base 'clang --version' also has 'FreeBSD' in its output, you > might want to drop the first .if ${CC:T:Mclang} != "clang" test. E.g. > just unconditionally set the FREEBSD_GCC macro (although it's then no > longer correctly named, but that aside). clang is broken for -mno-align-long-strings too. This is worked around using a static test on ${CC}. clang also doesn't support -mpreferred-stack-boundary. This handled using using a static test on ${MACHINE_CPUARCH}. This is correct for clang, since it handles stack alignment better than gcc and uses the minimal alignment. clang doesn't properly fail when 1 or both of -mno-align-long-strings or -mpreferred-stack-boundary. It prints a diagnostic, but exits with status 0 even with -Werror, and even if the -mpreferred-stack- boundary arg is invalid so that it would case a fatal error with gcc. amd64 never used -preferred-stack-boundary even for gcc. It is avoided using the same static test on ${MACHINE_CPUARCH}. I'm not sure if this is a bug, of if the ABI requires 16-byte alignment even in the freestanding case. Certainly, the hardware only prefers 8-byte alignment for most args, like it only prefers 4-byte alignment on i386. Both amd64 and i386 require 16-byte alignment for some SSE args. This should be implemented by aligning the stack only if such args exists, like clang does on i386. amd64 never used -mno-align-long-strings even for FreeBSD gcc where it is supported. Bruce