From: Iain Sandoe Date: Wed, 4 Sep 2019 19:30:44 +0000 (+0000) Subject: [Darwin] Make a final check on PIC options. X-Git-Tag: releases/gcc-7.5.0~165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c62fcdbb856deed4a782fdcd9c6d1eed7534ccf;p=thirdparty%2Fgcc.git [Darwin] Make a final check on PIC options. Final check on PCI 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'. This is a workaround for the situation in which a 'stock-built' GCC is unable to bootstrap m32 Darwin unless it's done '-mdynamic-no-pic'. So this fixes a bootstrap fail in that case. 2019-09-04 Iain Sandoe Backport from mainline 2019-07-07 Iain Sandoe * config/darwin.c (darwin_override_options): Make a final check on PIC options. From-SVN: r275386 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 12ad854dca4f..06dfed12c377 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -3,6 +3,13 @@ Backport from mainline 2019-07-07 Iain Sandoe + * config/darwin.c (darwin_override_options): Make a final check on PIC + options. + +2019-09-04 Iain Sandoe + + Backport from mainline + 2019-07-07 Iain Sandoe * config/darwin.c (darwin_override_options): Don't jam symbol stubs on for kernel code. diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 6159b38acd70..26875e97a6c9 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -3204,6 +3204,8 @@ 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 (MACHO_DYNAMIC_NO_PIC_P) { if (flag_pic) @@ -3212,9 +3214,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; }