From patchwork Wed Dec 7 20:20:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 130024 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 C74711007D5 for ; Thu, 8 Dec 2011 07:20:59 +1100 (EST) Received: (qmail 28679 invoked by alias); 7 Dec 2011 20:20:57 -0000 Received: (qmail 28669 invoked by uid 22791); 7 Dec 2011 20:20:56 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Dec 2011 20:20:34 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB7KKYCx024148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 7 Dec 2011 15:20:34 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pB7KKXYK024846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 7 Dec 2011 15:20:33 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id pB7KKW44003771; Wed, 7 Dec 2011 21:20:32 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id pB7KKWOX003769; Wed, 7 Dec 2011 21:20:32 +0100 Date: Wed, 7 Dec 2011 21:20:31 +0100 From: Jakub Jelinek To: Tom Tromey , Richard Henderson Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid using constructor attribute in libcpp (PR bootstrap/50237) Message-ID: <20111207202031.GE1957@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi! While this isn't real fix for this PR, which should be fixed in configury, I think avoiding ctors in host code is useful for portability and Eric agreed with that in the PR. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2011-12-07 Jakub Jelinek PR bootstrap/50237 * internal.h (_cpp_init_lexer): New prototype. * init.c (init_library): Call it. * lex.c (init_vectorized_lexer): Remove constructor attribute, add inline keyword. (HAVE_init_vectorized_lexer): Define. (_cpp_init_lexer): New function. Jakub --- libcpp/internal.h.jj 2011-11-04 07:49:56.000000000 +0100 +++ libcpp/internal.h 2011-11-28 16:01:13.467831488 +0100 @@ -653,6 +653,7 @@ extern int _cpp_equiv_tokens (const cpp_ extern void _cpp_init_tokenrun (tokenrun *, unsigned int); extern cpp_hashnode *_cpp_lex_identifier (cpp_reader *, const char *); extern int _cpp_remaining_tokens_num_in_context (cpp_context *); +extern void _cpp_init_lexer (void); /* In init.c. */ extern void _cpp_maybe_push_include_file (cpp_reader *); --- libcpp/init.c.jj 2011-10-31 20:44:15.000000000 +0100 +++ libcpp/init.c 2011-11-28 16:01:42.168044257 +0100 @@ -134,6 +134,8 @@ init_library (void) { initialized = 1; + _cpp_init_lexer (); + /* Set up the trigraph map. This doesn't need to do anything if we were compiled with a compiler that supports C99 designated initializers. */ --- libcpp/lex.c.jj 2011-10-27 08:43:10.000000000 +0200 +++ libcpp/lex.c 2011-11-28 16:04:42.624703698 +0100 @@ -477,7 +477,8 @@ search_line_sse42 (const uchar *s, const typedef const uchar * (*search_line_fast_type) (const uchar *, const uchar *); static search_line_fast_type search_line_fast; -static void __attribute__((constructor)) +#define HAVE_init_vectorized_lexer 1 +static inline void init_vectorized_lexer (void) { unsigned dummy, ecx = 0, edx = 0; @@ -638,6 +639,16 @@ search_line_fast (const uchar *s, const #endif +/* Initialize the lexer if needed. */ + +void +_cpp_init_lexer (void) +{ +#ifdef HAVE_init_vectorized_lexer + init_vectorized_lexer (); +#endif +} + /* Returns with a logical line that contains no escaped newlines or trigraphs. This is a time-critical inner loop. */ void