From patchwork Wed Jun 8 09:29:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 99386 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 F2848B7000 for ; Wed, 8 Jun 2011 19:30:01 +1000 (EST) Received: (qmail 15827 invoked by alias); 8 Jun 2011 09:29:59 -0000 Received: (qmail 15799 invoked by uid 22791); 8 Jun 2011 09:29:56 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_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; Wed, 08 Jun 2011 09:29:41 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id B0448188; Wed, 8 Jun 2011 11:29:39 +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 WjLN2Q6gdeIw; Wed, 8 Jun 2011 11:29:35 +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 15C70187; Wed, 8 Jun 2011 11:29:35 +0200 (CEST) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.4+Sun/8.14.4/Submit) id p589TXBC004823; Wed, 8 Jun 2011 11:29:33 +0200 (MEST) From: Rainer Orth To: Jason Merrill Cc: Mike Stump , gcc-patches@gcc.gnu.org, David Edelsohn , Iain Sandoe , Richard Henderson Subject: Re: [build] Define HAVE_GAS_HIDDEN on Darwin References: <4DD56699.6010607@redhat.com> Date: Wed, 08 Jun 2011 11:29:33 +0200 In-Reply-To: <4DD56699.6010607@redhat.com> (Jason Merrill's message of "Thu, 19 May 2011 14:51:05 -0400") 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 Jason Merrill writes: > On 05/19/2011 01:33 PM, Rainer Orth wrote: >> The cleanest way to account for this seems to allow overriding >> USE_LINKONCE_INDIRECT in target headers (darwin.h in this case). >> >> If Jason or Richard consider this appropriate, I'll modify the patch >> accordingly and apply after retesting. > > Not really. The use in dwarf2asm seems no different from the use in > i386.c, except that the latter has a special TARGET_MACHO case instead. As > you say, dwarf2asm shouldn't be using .hidden directly, and that's the bug > to fix. Once I got around to it, this proved to be remarkably easy, as can be seen below. One additional complication was detected during Darwin testing: with HAVE_GAS_HIDDEN defined, the 32-bit {ix86, rs6000}_stack_protect_fail would call default_hidden_stack_protect_fail. This emits calls to __stack_chk_fail_local which is missing from Darwin libc, so I had to revert to the default on Darwin. Bootstrapped without regressions on i386-apple-darwin9.8.0. powerpc-apple-darwin9.8.0 bootstrap is still running. Unfortunately, Darwin seems to be exceedingly unreliable under load: tests randomly time out and work again the next time. This doesn't happen for me on any other platform. This makes actually checking for regressions quite tedious. I've checked that any newly failing test was a timeout, not an actual failure. The patch has also been bootstrapped without regressions on i386-pc-solaris2.8 and i386-pc-solaris2.11 and the DW.ref.* symbols are still hidden as before. The Darwin parts of the previous versions have already been approved, but I'd appreciate if Mike could have a look at the changes. Ok for mainline? Thanks. Rainer 2011-04-30 Rainer Orth gcc: * configure.ac (gcc_cv_as_hidden): Enable on *-*-darwin*. (gcc_cv_ld_hidden): Likewise. * configure: Regenerate. * config/i386/i386.c (USE_HIDDEN_LINKONCE): Remove TARGET_MACHO. (ix86_stack_protect_fail): Mark unused. (TARGET_STACK_PROTECT_FAIL) [TARGET_MACHO]: Don't redefine. * config/rs6000/rs6000.c (rs6000_assemble_visibility) [TARGET_MACHO]: Don't define. (TARGET_ASM_ASSEMBLE_VISIBILITY): Likewise. (TARGET_STACK_PROTECT_FAIL): Likewise. (rs6000_stack_protect_fail): Mark unused. * dwarf2asm.c (dw2_output_indirect_constant_1): Mark decl hidden if USE_LINKONCE_INDIRECT. Don't emit .hidden expicitly. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -8725,7 +8725,7 @@ ix86_setup_frame_addresses (void) } #ifndef USE_HIDDEN_LINKONCE -# if (defined(HAVE_GAS_HIDDEN) && (SUPPORTS_ONE_ONLY - 0)) || TARGET_MACHO +# if defined(HAVE_GAS_HIDDEN) && (SUPPORTS_ONE_ONLY - 0) # define USE_HIDDEN_LINKONCE 1 # else # define USE_HIDDEN_LINKONCE 0 @@ -32207,7 +32207,7 @@ ix86_mangle_type (const_tree type) __stack_chk_fail directly. 64-bit code doesn't need to setup any PIC register, so it is better to call __stack_chk_fail directly. */ -static tree +static tree ATTRIBUTE_UNUSED ix86_stack_protect_fail (void) { return TARGET_64BIT @@ -35407,8 +35407,10 @@ ix86_autovectorize_vector_sizes (void) #undef TARGET_MANGLE_TYPE #define TARGET_MANGLE_TYPE ix86_mangle_type +#ifndef TARGET_MACHO #undef TARGET_STACK_PROTECT_FAIL #define TARGET_STACK_PROTECT_FAIL ix86_stack_protect_fail +#endif #undef TARGET_SUPPORTS_SPLIT_STACK #define TARGET_SUPPORTS_SPLIT_STACK ix86_supports_split_stack diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -884,7 +884,7 @@ static bool legitimate_lo_sum_address_p static struct machine_function * rs6000_init_machine_status (void); static bool rs6000_assemble_integer (rtx, unsigned int, int); static bool no_global_regs_above (int, bool); -#ifdef HAVE_GAS_HIDDEN +#if defined (HAVE_GAS_HIDDEN) && !defined (TARGET_MACHO) static void rs6000_assemble_visibility (tree, int); #endif static int rs6000_ra_ever_killed (void); @@ -1349,7 +1349,7 @@ static const struct default_options rs60 #undef TARGET_ASM_INTEGER #define TARGET_ASM_INTEGER rs6000_assemble_integer -#ifdef HAVE_GAS_HIDDEN +#if defined (HAVE_GAS_HIDDEN) && !defined (TARGET_MACHO) #undef TARGET_ASM_ASSEMBLE_VISIBILITY #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility #endif @@ -1558,8 +1558,10 @@ static const struct default_options rs60 #define TARGET_DEFAULT_TARGET_FLAGS \ (TARGET_DEFAULT) +#ifndef TARGET_MACHO #undef TARGET_STACK_PROTECT_FAIL #define TARGET_STACK_PROTECT_FAIL rs6000_stack_protect_fail +#endif /* MPC604EUM 3.5.2 Weak Consistency between Multiple Processors The PowerPC architecture requires only weak consistency among @@ -16390,7 +16392,7 @@ rs6000_assemble_integer (rtx x, unsigned return default_assemble_integer (x, size, aligned_p); } -#ifdef HAVE_GAS_HIDDEN +#if defined (HAVE_GAS_HIDDEN) && !defined (TARGET_MACHO) /* Emit an assembler directive to set symbol visibility for DECL to VISIBILITY_TYPE. */ @@ -27323,7 +27325,7 @@ invalid_arg_for_unprototyped_fn (const_t calling __stack_chk_fail directly. Otherwise it is better to call __stack_chk_fail directly. */ -static tree +static tree ATTRIBUTE_UNUSED rs6000_stack_protect_fail (void) { return (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT && flag_pic) diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2192,6 +2192,12 @@ EOF gcc_cv_as_hidden=yes ;; esac]) +case "${target}" in + *-*-darwin*) + # Darwin as has some visibility support, though with a different syntax. + gcc_cv_as_hidden=yes + ;; +esac # gnu_indirect_function type is an extension proposed at # http://groups.google/com/group/generic-abi/files. It allows dynamic runtime @@ -2291,6 +2297,10 @@ else fi else case "${target}" in + *-*-darwin*) + # Darwin ld has some visibility support. + gcc_cv_ld_hidden=yes + ;; hppa64*-*-hpux* | ia64*-*-hpux*) gcc_cv_ld_hidden=yes ;; diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c --- a/gcc/dwarf2asm.c +++ b/gcc/dwarf2asm.c @@ -1,5 +1,5 @@ /* Dwarf2 assembler output helper routines. - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -915,14 +915,13 @@ dw2_output_indirect_constant_1 (splay_tr { TREE_PUBLIC (decl) = 1; make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); + if (USE_LINKONCE_INDIRECT) + DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN; } else TREE_STATIC (decl) = 1; sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym); - sym = targetm.strip_name_encoding (sym); - if (TREE_PUBLIC (decl) && USE_LINKONCE_INDIRECT) - fprintf (asm_out_file, "\t.hidden %sDW.ref.%s\n", user_label_prefix, sym); assemble_variable (decl, 1, 1, 1); assemble_integer (sym_ref, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);