public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [build] Define HAVE_GAS_HIDDEN on Darwin
@ 2011-05-04 12:17 Rainer Orth
  2011-05-10  7:45 ` Mike Stump
  0 siblings, 1 reply; 9+ messages in thread
From: Rainer Orth @ 2011-05-04 12:17 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mike Stump, David Edelsohn, Iain Sandoe

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  <ro@CeBiTec.Uni-Bielefeld.DE>

	* 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)
 }
 \f
 #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

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-06-08 21:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-04 12:17 [build] Define HAVE_GAS_HIDDEN on Darwin Rainer Orth
2011-05-10  7:45 ` Mike Stump
2011-05-19 18:50   ` Rainer Orth
2011-05-19 22:13     ` Jason Merrill
2011-06-08  9:45       ` Rainer Orth
2011-06-08 10:08         ` IainS
2011-06-08 19:54         ` Mike Stump
2011-06-08 20:09         ` Mike Stump
2011-06-08 21:32         ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).