From owner-svn-src-head@FreeBSD.ORG Tue Oct 25 09:07:40 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 905B2106564A; Tue, 25 Oct 2011 09:07:40 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail07.syd.optusnet.com.au (mail07.syd.optusnet.com.au [211.29.132.188]) by mx1.freebsd.org (Postfix) with ESMTP id 2C99E8FC15; Tue, 25 Oct 2011 09:07:39 +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 mail07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p9P97Wir013651 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 25 Oct 2011 20:07:37 +1100 Date: Tue, 25 Oct 2011 20:07:32 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Dimitry Andric In-Reply-To: <201110241835.p9OIZGMg057013@svn.freebsd.org> Message-ID: <20111025190233.P9463@besplex.bde.org> References: <201110241835.p9OIZGMg057013@svn.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 Subject: Re: svn commit: r226698 - 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: Tue, 25 Oct 2011 09:07:40 -0000 On Mon, 24 Oct 2011, Dimitry Andric wrote: > Log: > Put in a temporary band-aid to fix kernel builds when CC=clang, after > r226665. Hrmph. It is still quite broken for clang. > Modified: head/sys/conf/kern.mk > ============================================================================== > --- head/sys/conf/kern.mk Mon Oct 24 18:29:50 2011 (r226697) > +++ head/sys/conf/kern.mk Mon Oct 24 18:35:16 2011 (r226698) > @@ -7,7 +7,7 @@ FREEBSD_GCC!= ${CC} --version | grep Fre > # > # Warning flags for compiling the kernel and components of the kernel: > # > -.if ${FREEBSD_GCC} > +.if defined(FREEBSD_GCC) && ${FREEBSD_GCC} > # FreeBSD extensions, not available in upstream GCC > format_extensions= -fformat-extensions > no_align_long_strings= -mno-align-long-strings For clang, FREEBSD_GCC is not defined. Thus -fformat-extensions is null for clang, and all files using FreeBSD format extensions fail to compile. A critical example of such a file is if_ethersubr.o. This file uses %6D, so it now correctly fails to compile. clang emits disgustingly verbose diagnostics about all 4 instances of %6D and then exits with nonzero status. Quick fix: change the ifdef to: .if !defined(FREEBSD_GCC) || ${FREEBSD_GCC} With this fix, if_ethersubr.o now incorrectly compiles. The bug is now: % clang: warning: argument unused during compilation: '-frename-registers' kern.pre.mk adds -frename-registers unconditionally on amd64. clang doesn't support this, but doesn't even fail. It emits the above error message and exits with status 0. This error message is not disgustingly verbose, but it occurs for almost every object file. Before finding if_ethersubr.o, clang seemed to be not noticing any -fformat-extensions bugs, but that was because I stopped the compile after a few -frename-registers bugs. I first tested handling of -fformat-extensions separately: % z.c: % #include % % int % main() % { % printf("%r\n", 1); % return (0); % } This showed the following bugs: cc -c z.c: works correctly (no warning) clang -c z.c: gives bogus warnings and broken color escape sequences in the warnings when the output file is "typescript" created by script(1) cc -c z.c -Wformat: works correctly (warning) clang -c z.c -Wformat: works correctly (warning) cc -c z.c -Wformat -fformat-extensions: works correctly (no warning) clang -c z.c -Wformat -fformat-extensions: works correctly (no warning) cc -c z.c -Wformat -fformat-extensions -std=c99: works correctly (no warning) clang -c z.c -Wformat -fformat-extensions -std=c99: works correctly (no warning) cc -c z.c -Wformat -fformat-extensions -std=c99 -pedantic: gives broken warnings. Now the warnings are bugs instead of just bogus, since -fformat-extensions is supposed to extend the standard. Both -std=c99 and -pedantic should only warn for extensions that are not explicitly asked for. gcc mostly gets this right. E.g., you write __asm() instead of asm() if you want to use asm() in otherwise standard code. clang -c z.c -Wformat -fformat-extensions -std=c99 -pedantic: gives broken warnings and broken color escape sequences. Bruce