From patchwork Fri Dec 30 19:31:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 133695 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5B190B6FC5 for ; Sat, 31 Dec 2011 06:32:02 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1325878322; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:Cc:Subject:Message-ID:References:Mime-Version: Content-Type:Content-Disposition:In-Reply-To:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=3Wsxw4Dw6z+YGaeWwLER +I2mR80=; b=NzVZZA45SQAq0n6QIN4LszloTM+4GiyRcph6HgobcUC89ZnHnt97 o7z5KmV2fIxJzrH2c7A7ftSVgeIb/7rGKwI9dMxKSm8p8GQZcncac2oimd2EqKuO ibplANg8mmeV0KTgpcu0oo7TPm3wWZa30wrMbyXKeyj6+Tri+rLKm64= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:References:Mime-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=SxFkMmTy6IIeJIS83KcMdXGl8a6OuZlrZK1qwUsTldVJPHXkILf6C7odlX3Um1 BsrvC/69h1cAsPfTqBqrt17zKv3POFNhBejbfKV64LCmEu4fMiOifikEjlligaHy Vs+NcIuqjERqirEDngLDLSrp1fqF7Wlq5PF6fP+skeBKk=; Received: (qmail 23887 invoked by alias); 30 Dec 2011 19:31:57 -0000 Received: (qmail 23872 invoked by uid 22791); 30 Dec 2011 19:31:56 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 30 Dec 2011 19:31:42 +0000 Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.5/8.14.5) with ESMTP id pBUJVfiH054972; Fri, 30 Dec 2011 11:31:41 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.5/8.14.5/Submit) id pBUJVfWI054971; Fri, 30 Dec 2011 11:31:41 -0800 (PST) (envelope-from sgk) Date: Fri, 30 Dec 2011 11:31:41 -0800 From: Steve Kargl To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix PR bootstrap/51705 Message-ID: <20111230193141.GA54761@troutmask.apl.washington.edu> References: <20111230041251.GA51358@troutmask.apl.washington.edu> <20111230093803.GA18937@tyan-ft48-01.lab.bos.redhat.com> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20111230093803.GA18937@tyan-ft48-01.lab.bos.redhat.com> User-Agent: Mutt/1.4.2.3i Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Fri, Dec 30, 2011 at 10:38:03AM +0100, Jakub Jelinek wrote: > On Thu, Dec 29, 2011 at 08:12:51PM -0800, Steve Kargl wrote: > > The audit trail in the PR pretty much sums up the problem. > > OK to commit? > > Can you tune up the comments a little bit? > If you look up http://gcc.gnu.org/gcc-4.7/cxx0x_status.html > you'll see that most of the C++11 features are already implemented > (and e.g. at_quick_exit is implemented too in some libcs), so the > __cplusplus macro isn't lying. Clang apparently defines __cplusplus > to 201103L much longer than GCC does, yet it supports much smaller subset > of C++11. Apparently it parses the C++11 generalized attribute syntax, > but at least clang 3.0 doesn't complain at all about anything between > the [[ and ]] pair, [[foobar, foobaz (bar, baz, 2, 6, 0x1z2)]] void bar (void); > is parsed just fine, and with [[noreturn]] it miscompiles even the first > [[noreturn]] trivial testcase I wrote. > See > http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02027.html > for why we set __cplusplus to the value we do. I'm sorry, but I find "clang did this, so g++ better follow suit" to be a rather uncompelling technical reason for defining __cplusplus to be 201103L [1]. The technical question is fairly simple: "Does g++ conform to the C++11 standard?" From my cursory scanning of n3242.pdf, the answer is obviously 'no' given that [[noreturn]] appears to be neither a conditionally-supported feature nor implementation-defined behavior. So, we now look at what n3242.pdf says about __cplusplus: Sec. 16.8 (p. 415) __cplusplus The name __cplusplus is defined to the value 201103L when compiling a C++ translation unit. [155] 155) It is intended that future versions of this standard will replace the value of this macro with a greater value. Non-conforming compilers should use a value with at most five decimal digits. 201103 is 6 digits! Again, a cursory scan of n3242.pdf does not reveal whether a footnote is normative or non-normative text. So, footnote [155] may simply be a suggestion rather than a requirement. [1] Interestly, in a 1334 page document, n3242.pdf does not state how one is to interpret __cplusplus nor its value. So, once again OK for trunk? 2011-12-29 Steven G. Kargl * inclhack.def: 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests that 'g++ -std=c++11' is a compiler conforming to the C++ programming language defined by ISO/IEC 14882:2011. Setting __cplusplus to 201103L appears to be a direct violation of ISO/IEC 14882:2011. The standard conforming sys/cdefs.h header file on FreeBSD 10 (and above) needs be (un)damaged, so GCC can use 'g++ -std=c++11' to build libstdc++v3 during bootstrap. * fixincl.x: Regenerated. * genfixes: Fix to version test. Index: inclhack.def =================================================================== --- inclhack.def (revision 182738) +++ inclhack.def (working copy) @@ -20,6 +20,27 @@ autogen definitions fixincl; FIXINC_DEBUG = yes; #endif +/* + * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests + * that 'g++ -std=c++11' is a compiler conforming to the C++ programming + * language defined by ISO/IEC 14882:2011. Setting __cplusplus to + * 201103L appears to be a direct violation of ISO/IEC 14882:2011 + * [as inferred from Secs. 1.4 and 16.8 in n3242.pdf (I'm not interested + * in spending CHF 352.00 for the actual standard)]. The standard + * conforming sys/cdefs.h header file on FreeBSD 10 (and above) needs be + * (un)damaged, so GCC can use 'g++ -std=c++11' to build libstdc++v3 + * during bootstrap. + */ +fix = { + hackname = cdef_cplusplus; + mach = "*-*-freebsd10.*"; + files = sys/cdefs.h; + select = "\\[\\[noreturn\\]\\]"; + sed = "s/\\[\\[noreturn\\]\\]/__attribute__\(\(__noreturn__\)\)/"; + test_text = "#include "; +}; + + /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to * fopen64 etc. and this causes problems when building with g++ * because cstdio udefs everything from stdio.h, leaving us with Index: fixincl.x =================================================================== --- fixincl.x (revision 182738) +++ fixincl.x (working copy) @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed November 7, 2011 at 01:16:39 PM by AutoGen 5.10 + * It has been AutoGen-ed December 30, 2011 at 11:21:34 AM by AutoGen 5.12 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Mon Nov 7 13:16:39 EST 2011 +/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Dec 30 11:21:34 PST 2011 * * You must regenerate it. Use the ./genfixes script. * @@ -15,7 +15,7 @@ * certain ANSI-incompatible system header files which are fixed to work * correctly with ANSI C and placed in a directory that GNU C will search. * - * This file contains 222 fixup descriptions. + * This file contains 223 fixup descriptions. * * See README for more information. * @@ -43,6 +43,42 @@ static char const sed_cmd_z[] = SED_PROG /* * * * * * * * * * * * * * * * * * * * * * * * * * * + * Description of Cdef_Cplusplus fix + */ +tSCC zCdef_CplusplusName[] = + "cdef_cplusplus"; + +/* + * File name selection pattern + */ +tSCC zCdef_CplusplusList[] = + "sys/cdefs.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzCdef_CplusplusMachs[] = { + "*-*-freebsd10.*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zCdef_CplusplusSelect0[] = + "\\[\\[noreturn\\]\\]"; + +#define CDEF_CPLUSPLUS_TEST_CT 1 +static tTestDesc aCdef_CplusplusTests[] = { + { TT_EGREP, zCdef_CplusplusSelect0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Cdef_Cplusplus + */ +static const char* apzCdef_CplusplusPatch[] = { sed_cmd_z, + "-e", "s/\\[\\[noreturn\\]\\]/__attribute__((__noreturn__))/", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * * Description of Aab_Aix_Stdio fix */ tSCC zAab_Aix_StdioName[] = @@ -9034,14 +9070,15 @@ static const char* apzX11_SprintfPatch[] * * List of all fixes */ -#define REGEX_COUNT 264 +#define REGEX_COUNT 265 #define MACH_LIST_SIZE_LIMIT 181 -#define FIX_COUNT 222 +#define FIX_COUNT 223 /* * Enumerate the fixes */ typedef enum { + CDEF_CPLUSPLUS_FIXIDX, AAB_AIX_STDIO_FIXIDX, AAB_DARWIN7_9_LONG_DOUBLE_FUNCS_FIXIDX, AAB_DARWIN7_9_LONG_DOUBLE_FUNCS_2_FIXIDX, @@ -9267,6 +9304,11 @@ typedef enum { } t_fixinc_idx; tFixDesc fixDescList[ FIX_COUNT ] = { + { zCdef_CplusplusName, zCdef_CplusplusList, + apzCdef_CplusplusMachs, + CDEF_CPLUSPLUS_TEST_CT, FD_MACH_ONLY, + aCdef_CplusplusTests, apzCdef_CplusplusPatch, 0 }, + { zAab_Aix_StdioName, zAab_Aix_StdioList, apzAab_Aix_StdioMachs, AAB_AIX_STDIO_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, Index: genfixes =================================================================== --- genfixes (revision 182738) +++ genfixes (working copy) @@ -62,7 +62,7 @@ fi AG="autogen $AG" set -e -if [ -z "`${AG} -v | fgrep 'Ver. 5.'`" ] +if [ -z "`${AG} -v | fgrep '5.'`" ] then echo "AutoGen appears to be out of date or not correctly installed." echo "Please download and install:"