public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Support -rdynamic on darwin12 and later
@ 2015-04-28 13:49 Jack Howarth
  2015-04-28 19:45 ` Mike Stump
  0 siblings, 1 reply; 2+ messages in thread
From: Jack Howarth @ 2015-04-28 13:49 UTC (permalink / raw)
  To: GCC Patches, Mike Stump, Iain Sandoe

[-- Attachment #1: Type: text/plain, Size: 1450 bytes --]

     The attached patch adds support for the -rdynamic compiler flag
on darwin12 and later. The darwin linker, starting with Xcode 5 on
darwin12, added support for the associated new -export_dynamic linker
flag.

     -export_dynamic
                 Preserves all global symbols in main executables
during LTO.  Without this option, Link Time Optimization is
                 allowed to inline and remove global functions. This
option is used when a main executable may load a plug-in
                 which requires certain symbols from the main executable.

This patch emulates the behavior of clang from Xcode 5 and later which
accepts the -rdynamic flag. Note that the emission of -export_dynamic
by -rdynamic is unaffected by the use of -mmacosx-version-min.
       These changes are achieved by the addition of rdynamic to
gcc/config/darwin.opt, addition of a   new gcc/config/darwin12.h file
with additional spec handling for rdynamic in LINK_GCC_C_SEQUENCE_SPEC
and changes to gcc/config.gcc to use this new file on darwin12 or
later. Bootstrap tested on both x86_64-apple-darwin11 and
x86_64-apple-darwin14. Confirmed that on darwin11, the -rdynamic flag
retains the current behavior of issuing the compiler error "error:
unrecognized command line option ‘-rdynamic’". Confirmed that on
darwin12 and later, invoking -rdynamic emits the expected
-export_dynamc linker flag. Okay for gcc trunk?
            Jack

[-- Attachment #2: darwin12_rdynamic.patch --]
[-- Type: application/octet-stream, Size: 2497 bytes --]

2015-04-28  Jack Howarth  <howarth.at.gcc@gmail.com>

	* config.gcc: Use darwin9.h, darwin10.h and darwin12.h
	on darwin12 and later.
	* config/darwin12.h (LINK_GCC_C_SEQUENCE_SPEC): Add
	file to pass -rdynamic on darwin12 and later.
	* config/darwin.opt (rdynamic): Add.

Index: config/darwin.opt
===================================================================
--- config/darwin.opt	(revision 222478)
+++ config/darwin.opt	(working copy)
@@ -155,6 +155,9 @@ Driver
 pthread
 Driver
 
+rdynamic
+Driver
+
 seg_addr_table
 Driver Separate Alias(Zseg_addr_table)
 
Index: config.gcc
===================================================================
--- config.gcc	(revision 222478)
+++ config.gcc	(working copy)
@@ -605,9 +605,12 @@ case ${target} in
   *-*-darwin9*)
     tm_file="${tm_file} darwin9.h"
     ;;
-  *-*-darwin[12][0-9]*)
+  *-*-darwin[1][01]*)
     tm_file="${tm_file} darwin9.h darwin10.h"
     ;;
+  *-*-darwin[1][2-9]* | *-*-darwin[2][0-9]*)
+    tm_file="${tm_file} darwin9.h darwin10.h darwin12.h"
+    ;;
   esac
   tm_file="${tm_file} ${cpu_type}/darwin.h"
   tm_p_file="${tm_p_file} darwin-protos.h"
--- /dev/null	2015-04-27 22:44:37.000000000 -0400
+++ config/darwin12.h	2015-04-27 22:48:29.000000000 -0400
@@ -0,0 +1,27 @@
+/* Target definitions for Darwin (Mac OS X) systems.
+   Copyright (C) 2009-2015 Free Software Foundation, Inc.
+   Contributed by Jack Howarth <howarth.at.gcc@gmail.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#undef  LINK_GCC_C_SEQUENCE_SPEC
+#define LINK_GCC_C_SEQUENCE_SPEC \
+"%:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) \
+   %{rdynamic:-export_dynamic} %{!static:%{!static-libgcc: \
+      %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
+   %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \
+      %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L"

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

* Re: [PATCH] Support -rdynamic on darwin12 and later
  2015-04-28 13:49 [PATCH] Support -rdynamic on darwin12 and later Jack Howarth
@ 2015-04-28 19:45 ` Mike Stump
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Stump @ 2015-04-28 19:45 UTC (permalink / raw)
  To: Jack Howarth; +Cc: GCC Patches, Iain Sandoe

On Apr 28, 2015, at 6:39 AM, Jack Howarth <howarth.at.gcc@gmail.com> wrote:
>     The attached patch adds support for the -rdynamic compiler flag
> on darwin12 and later.

> Okay for gcc trunk?

Jack was able to confirm that this doesn’t change darwin11.

Ok.

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

end of thread, other threads:[~2015-04-28 19:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 13:49 [PATCH] Support -rdynamic on darwin12 and later Jack Howarth
2015-04-28 19:45 ` Mike Stump

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).