* [Darwin] Make a final check on PIC options.
@ 2019-07-07 17:12 Iain Sandoe
0 siblings, 0 replies; only message in thread
From: Iain Sandoe @ 2019-07-07 17:12 UTC (permalink / raw)
To: GCC Patches
In some cases the cascaded settings for pic/pie/PIC/PIE can cause a confusing
scenario for Darwin where "fPIC fno-PIE” produces a wrong code generation
setting.
So we make a final check on PIC options; for Darwin these are not dependent on
the PIE ones, although PIE does require PIC to support it. Specifically, for Darwin,
"fPIC fno-PIE" should result in the same as "-fno-PIE -fPIC”.
tested on x86-64-darwin16,
applied to mainline
Iain
2019-07-07 Iain Sandoe <iain@sandoe.co.uk>
* config/darwin.c (darwin_override_options): Make a final check on PIC
options.
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 02bcf01..5ac0925 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3241,6 +3241,8 @@ darwin_override_options (void)
&& write_symbols == DWARF2_DEBUG)
flag_var_tracking_uninit = flag_var_tracking;
+ /* Final check on PIC options; for Darwin these are not dependent on the PIE
+ ones, although PIE does require PIC to support it. */
if (MACHO_DYNAMIC_NO_PIC_P)
{
if (flag_pic)
@@ -3249,9 +3251,11 @@ darwin_override_options (void)
" %<-fpie%> or %<-fPIE%>");
flag_pic = 0;
}
- else if (flag_pic == 1)
+ else if (flag_pic == 1
+ || (flag_pic == 0 && !(flag_mkernel || flag_apple_kext)))
{
- /* Darwin's -fpic is -fPIC. */
+ /* Darwin's -fpic is -fPIC.
+ We only support "static" code in the kernel and kernel exts. */
flag_pic = 2;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-07-07 17:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-07 17:12 [Darwin] Make a final check on PIC options Iain 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).