From patchwork Wed May 4 12:08:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 94012 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 0B13E1007EA for ; Wed, 4 May 2011 22:08:39 +1000 (EST) Received: (qmail 12188 invoked by alias); 4 May 2011 12:08:37 -0000 Received: (qmail 12174 invoked by uid 22791); 4 May 2011 12:08:36 -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, 04 May 2011 12:08:22 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 94E2A292; Wed, 4 May 2011 14:08:20 +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 sSVFZk0FxvRg; Wed, 4 May 2011 14:08:17 +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 F33BC291; Wed, 4 May 2011 14:08:16 +0200 (CEST) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.4+Sun/8.14.4/Submit) id p44C8GKx007386; Wed, 4 May 2011 14:08:16 +0200 (MEST) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Mike Stump , David Edelsohn , Iain Sandoe Subject: [build] Define HAVE_GAS_HIDDEN on Darwin Date: Wed, 04 May 2011 14:08:16 +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 The following patch is a prerequisite for making [lto, testsuite] Don't use visibility on targets that don't support it (PR lto/47334) http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00295.html work on Darwin by defining HAVE_GAS_HIDDEN on that target, too. Instead of special-casing visibility support on Darwin all over the place, I'd rather treat it like the other targets that have at least some visibility support, even if not the full ELF range of visibility types. Doing this turned out to be astonishingly easy: * Enable gcc_cv_as_hidden and gcc_cv_ld_hidden in configure.ac. * Disable rs6000_assemble_visibility if TARGET_MACHO since Darwin has (and needs) its own version. * The code in config/i386/i386.c for USE_HIDDEN_LINKONCE now does the right thing even without TARGET_MACHO. * On the other hand, USE_LINKONCE_INDIRECT in dwarf2asm.c must be disabled for Mach-O since the code uses an explicit .hidden, which could be considered a bug in itself ;-( This patch survived bootstrap on i386-apple-darwin9.8.0 (both multilibs) and powerpc-apple-darwin9.8.0 (32-bit only). I've compared testresults with a slightly earlier build (the machines are relatively slow), but a real regtest is in progress. I'd appreciate if Darwin maintainers and other Darwin users could try this themselves since my experience with the platform is rather limited. While one could argue that HAVE_GAS_HIDDEN is complete misnomer now and should rather be HAVE_AS_VISIBILITY instead, I'd prefer to do this as a followup if at all. Ok for mainline if testing passes and no other problems show up? Thanks. Rainer 2011-04-30 Rainer Orth * 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. * config/rs6000/rs6000.c (rs6000_assemble_visibility) [TARGET_MACHO]: Don't define. (TARGET_ASM_ASSEMBLE_VISIBILITY): Likewise. * dwarf2asm.c (USE_LINKONCE_INDIRECT) [HAVE_GAS_HIDDEN]: Only if !TARGET_MACHO. 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 @@ -8787,7 +8787,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 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 @@ -916,7 +916,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); @@ -1381,7 +1381,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 @@ -16710,7 +16710,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. */ diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2174,6 +2174,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 @@ -2273,6 +2279,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. @@ -799,7 +799,7 @@ static GTY((param1_is (char *), param2_i static GTY(()) int dw2_const_labelno; #if defined(HAVE_GAS_HIDDEN) -# define USE_LINKONCE_INDIRECT (SUPPORTS_ONE_ONLY) +# define USE_LINKONCE_INDIRECT (SUPPORTS_ONE_ONLY) && !TARGET_MACHO #else # define USE_LINKONCE_INDIRECT 0 #endif