public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-11381] Darwin: Handle the fPIE option specially.
@ 2024-04-27 16:17 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2024-04-27 16:17 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:65f028e25fd0239b0b2ba6485653fd4dce131da8

commit r11-11381-g65f028e25fd0239b0b2ba6485653fd4dce131da8
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Wed Oct 25 15:28:52 2023 +0100

    Darwin: Handle the fPIE option specially.
    
    For Darwin, PIE requires PIC codegen, but otherwise is only a link-time
    change. For almost all Darwin, we do not report __PIE__; the exception is
    32bit X86 and from Darwin12 to 17 only (32 bit is no longer supported
    after Darwin17).
    
    gcc/ChangeLog:
    
            * config/darwin.c (darwin_override_options): Handle fPIE.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    (cherry picked from commit da9e72f80f3358bd9586e11aaf03341c1f867318)

Diff:
---
 gcc/config/darwin.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 574424ac11c..61f04a1b209 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3284,6 +3284,8 @@ darwin_override_options (void)
     {
       if (strverscmp (darwin_macosx_version_min, "10.14") >= 0)
 	generating_for_darwin_version = 18;
+      else if (strverscmp (darwin_macosx_version_min, "10.8") >= 0)
+	generating_for_darwin_version = 12;
       else if (strverscmp (darwin_macosx_version_min, "10.7") >= 0)
 	generating_for_darwin_version = 11;
       else if (strverscmp (darwin_macosx_version_min, "10.6") >= 0)
@@ -3453,8 +3455,17 @@ darwin_override_options (void)
       && write_symbols == DWARF2_DEBUG)
     flag_var_tracking_uninit = flag_var_tracking;
 
-  /* Final check on PCI options; for Darwin these are not dependent on the PIE
-     ones, although PIE does require PIC to support it.  */
+  if (OPTION_SET_P (flag_pie) && flag_pie)
+    {
+      /* This is a little complicated, to match Xcode tools.
+	 For Darwin, PIE requires PIC codegen, but otherwise is only a link-
+	 time change.  For almost all Darwin, we do not report __PIE__; the
+	 exception is Darwin12-17 and for 32b only.  */
+      flag_pie = generating_for_darwin_version >= 12 && !TARGET_64BIT ? 2 : 0;
+      flag_pic = 2; /* We always set this.  */
+    }
+
+  /* Final check on PIC options.  */
   if (MACHO_DYNAMIC_NO_PIC_P)
     {
       if (flag_pic)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-27 16:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-27 16:17 [gcc r11-11381] Darwin: Handle the fPIE option specially Iain D Sandoe

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