aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2023-10-25 15:28:52 +0100
committerIain Sandoe <iain@sandoe.co.uk>2023-10-25 20:46:59 +0100
commitda9e72f80f3358bd9586e11aaf03341c1f867318 (patch)
treec4719800fda5edd13e0c39be069a3fc2fb650c7c /gcc
parent8f62ce10bc984855ca98483746ead2730eb36e2e (diff)
downloadgcc-da9e72f80f3358bd9586e11aaf03341c1f867318.zip
gcc-da9e72f80f3358bd9586e11aaf03341c1f867318.tar.gz
gcc-da9e72f80f3358bd9586e11aaf03341c1f867318.tar.bz2
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.cc (darwin_override_options): Handle fPIE. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/darwin.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index a80b6ca..621a94d 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -3325,6 +3325,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)
@@ -3495,8 +3497,17 @@ darwin_override_options (void)
&& dwarf_debuginfo_p ())
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)