From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 461853849AC5; Fri, 19 Apr 2024 13:18:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 461853849AC5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713532729; bh=u0YByPAz+bNk5UdU33DgL4+S2o+3Jk4BR9E2+Zq2ZG4=; h=From:To:Subject:Date:From; b=ilR4bYgbhZlAcqoXFJepuEpCbMJhWd8IQZRAs3Xm7FNyCjnfOSkCw1oMSj03eaqYg lZgIBxLHd9NePRT9gA+dzR9K0rhaARRY4UzRqUWv/JA5hS10HFYKoxyo9xQRwHWsvt iLLouPID3+spa2mtF/qbvmjkODIBNP30Iu0RDVHo= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-10352] Darwin: Handle the fPIE option specially. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: f1ef7143fba7e09ec10a60227ebb46eb5d6553f9 X-Git-Newrev: 30766064e4f88bca3909ecd9737eeb5f4d36be81 Message-Id: <20240419131849.461853849AC5@sourceware.org> Date: Fri, 19 Apr 2024 13:18:49 +0000 (GMT) List-Id: https://gcc.gnu.org/g:30766064e4f88bca3909ecd9737eeb5f4d36be81 commit r12-10352-g30766064e4f88bca3909ecd9737eeb5f4d36be81 Author: Iain Sandoe 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.cc (darwin_override_options): Handle fPIE. Signed-off-by: Iain Sandoe (cherry picked from commit da9e72f80f3358bd9586e11aaf03341c1f867318) Diff: --- gcc/config/darwin.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 129250a48fd..3cbdc97662d 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3299,6 +3299,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) @@ -3469,8 +3471,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)