From patchwork Tue Aug 9 09:44:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 109186 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 C82CDB6F84 for ; Tue, 9 Aug 2011 19:44:35 +1000 (EST) Received: (qmail 1349 invoked by alias); 9 Aug 2011 09:44:31 -0000 Received: (qmail 1332 invoked by uid 22791); 9 Aug 2011 09:44:29 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Aug 2011 09:44:14 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id A673F7E7; Tue, 9 Aug 2011 11:44:12 +0200 (CEST) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id I1xekq-LfYXY; Tue, 9 Aug 2011 11:44:09 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id A19DA7E6; Tue, 9 Aug 2011 11:44:09 +0200 (CEST) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id p799i9mv004383; Tue, 9 Aug 2011 11:44:09 +0200 (MEST) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Marc Glisse , libstdc++@gcc.gnu.org Subject: [c++] Keep tm, div_t, ldiv_t, lconv mangling on Solaris (PR libstdc++-v3/1773) Date: Tue, 09 Aug 2011 11:44:08 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes 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 While checking how to fix PR libstdc++-v3/1773 __cplusplus defined to 1, should be 199711L it was discovered that without countermeasures, changing __cplusplus from 1 to 199711L breaks the Solaris ABI by moving tm from the global namespace to std, among others, e.g. -FUNC:std::__timepunct::_M_put(char*, unsigned long, char const*, tm const*) const@@GLIBCXX_3.4 +FUNC:std::__timepunct::_M_put(char*, unsigned long, char const*, std::tm const*) const@@GLIBCXX_3.4 -FUNC:std::__timepunct::_M_put(wchar_t*, unsigned long, wchar_t const*, tm const*) const@@GLIBCXX_3.4 +FUNC:std::__timepunct::_M_put(wchar_t*, unsigned long, wchar_t const*, std::tm const*) const@@GLIBCXX_3.4 This patch (entirely Marc's work, I've only added the ChangeLog entry and fixed some formatting issues) avoids that. Together with the companion patches (already posted or in the process of being so), it allowed successful i386-pc-solaris2.{8, 9, 10, 11} bootstraps without regressions. I have no idea if the approach is right, but something needs to be done here. Comments? Rainer 2011-08-07 Marc Glisse PR libstdc++-v3/1773 * mangle.c (substitution_identifier_index_t): Define SUBID_TM, SUBID_DIV_T, SUBID_LDIV_T, SUBID_LCONV. (is_std_substitution2): New function. (write_unscoped_name): Don't emit tm, div_t, ldiv_t, lconv in ::std. (init_mangle): Cache tm, div_t, ldiv_t, lconv identifies. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -127,6 +127,10 @@ typedef enum SUBID_BASIC_ISTREAM, SUBID_BASIC_OSTREAM, SUBID_BASIC_IOSTREAM, + SUBID_TM, + SUBID_DIV_T, + SUBID_LDIV_T, + SUBID_LCONV, SUBID_MAX } substitution_identifier_index_t; @@ -163,6 +167,8 @@ static inline tree canonicalize_for_subs static void add_substitution (tree); static inline int is_std_substitution (const tree, const substitution_identifier_index_t); +static inline int is_std_substitution2 (const tree, + const substitution_identifier_index_t); static inline int is_std_substitution_char (const tree, const substitution_identifier_index_t); static int find_substitution (tree); @@ -437,6 +443,33 @@ is_std_substitution (const tree node, == subst_identifiers[index])); } +static inline int +is_std_substitution2 (const tree node, + const substitution_identifier_index_t index) +{ + tree type = NULL; + tree decl = NULL; + + if (DECL_P (node)) + { + type = TREE_TYPE (node); + decl = node; + } + else if (CLASS_TYPE_P (node)) + { + type = node; + decl = TYPE_NAME (node); + } + else + /* These are not the droids you're looking for. */ + return 0; + + return (DECL_NAMESPACE_STD_P (CP_DECL_CONTEXT (decl)) + && TYPE_LANG_SPECIFIC (type) + && (DECL_NAME (decl) == subst_identifiers[index])); +} + + /* Helper function for find_substitution. Returns nonzero if NODE, which may be a decl or a CLASS_TYPE, is the template-id ::std::identifier, where identifier is @@ -864,6 +897,10 @@ write_unscoped_name (const tree decl) /* Is DECL in ::std? */ if (DECL_NAMESPACE_STD_P (context)) { + if (!is_std_substitution2 (decl, SUBID_TM) + && !is_std_substitution2 (decl, SUBID_DIV_T) + && !is_std_substitution2 (decl, SUBID_LDIV_T) + && !is_std_substitution2 (decl, SUBID_LCONV)) write_string ("St"); write_unqualified_name (decl); } @@ -3095,6 +3132,10 @@ init_mangle (void) subst_identifiers[SUBID_BASIC_ISTREAM] = get_identifier ("basic_istream"); subst_identifiers[SUBID_BASIC_OSTREAM] = get_identifier ("basic_ostream"); subst_identifiers[SUBID_BASIC_IOSTREAM] = get_identifier ("basic_iostream"); + subst_identifiers[SUBID_TM] = get_identifier ("tm"); + subst_identifiers[SUBID_DIV_T] = get_identifier ("div_t"); + subst_identifiers[SUBID_LDIV_T] = get_identifier ("ldiv_t"); + subst_identifiers[SUBID_LCONV] = get_identifier ("lconv"); } /* Generate the mangled name of DECL. */