Properly set flag_pie and flag_pic
commit5ec4a94978e3315cc38288d062b61d58017214df
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Mar 2016 15:11:35 +0000 (17 15:11 +0000)
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Mar 2016 15:11:35 +0000 (17 15:11 +0000)
tree17ba6d251c6be7998bf2b5fdac8d60ecdc3b210c
parent5cb6b0b9685d5c63e87abb10abac60312dab1378
Properly set flag_pie and flag_pic

We can't set flag_pie to the default when flag_pic == 0, which may be
set by -fno-pic or -fno-PIC, since the default value of flag_pie is
non-zero when GCC is configured with --enable-default-pie.  We need
to initialize flag_pic to -1 so that we can tell if -fpic, -fPIC,
-fno-pic or -fno-PIC is used.

Since Darwin defaults to PIC (__PIC__ == 2) and the PIC setting can't
be changed, skip tests of default __PIC__ and __PIE__ setting for
*-*-darwin* targets.

gcc/

PR driver/70192
* opts.c (finish_options): Don't set flag_pie to the default if
-fpic, -fPIC, -fno-pic or -fno-PIC is used.  Set flag_pic to 0
if it is -1.

gcc/testsuite/

PR driver/70192
* gcc.dg/pic-1.c: New test.
* gcc.dg/pic-2.c: Likewise.
* gcc.dg/pic-3.c: Likewise.
* gcc.dg/pic-4.c: Likewise.
* gcc.dg/pie-1.c: Likewise.
* gcc.dg/pie-2.c: Likewise.
* gcc.dg/pie-3.c: Likewise.
* gcc.dg/pie-4.c: Likewise.
* gcc.dg/pie-5.c: Likewise.
* gcc.dg/pie-6.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234295 138bc75d-0d04-0410-961f-82ee72b054a4
14 files changed:
gcc/ChangeLog
gcc/common.opt
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pic-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pic-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pic-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pic-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pie-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pie-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pie-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pie-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pie-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pie-6.c [new file with mode: 0644]