Patch RFA: Fix -fpie -fpic

Submitted by Ian Taylor on Nov. 13, 2012, 8:45 p.m.

Details

Message ID mcrmwyl8c59.fsf@google.com
State New
Headers show

Commit Message

Ian Taylor Nov. 13, 2012, 8:45 p.m.
Right now if you run "gcc -fpie -fpic" you get, in effect, "gcc -fpie".
I think you should get "gcc -fpic".  In general I think that of the
options -fpic, -fPIC, -fpie, -fPIE, -fno-pic, -fno-PIC, -fno-pie,
-fno-PIE the compiler should act as though only the last of those
options were specified.  That follows the usual formulat in which the
last option wins.

This patch implements that.  Bootstrapped and tested on
x86_64-unknown-linux-gnu.  OK for mainline?

Ian


2012-11-13  Ian Lance Taylor  <iant@google.com>

	* common.opt (fPIC, fPIE, fpic, fpie): Create a Negative loop such
	that any of these options disables the others.

Comments

H.J. Lu Nov. 13, 2012, 8:57 p.m.
On Tue, Nov 13, 2012 at 12:45 PM, Ian Lance Taylor <iant@google.com> wrote:
> Right now if you run "gcc -fpie -fpic" you get, in effect, "gcc -fpie".
> I think you should get "gcc -fpic".  In general I think that of the
> options -fpic, -fPIC, -fpie, -fPIE, -fno-pic, -fno-PIC, -fno-pie,
> -fno-PIE the compiler should act as though only the last of those
> options were specified.  That follows the usual formulat in which the
> last option wins.
>
> This patch implements that.  Bootstrapped and tested on
> x86_64-unknown-linux-gnu.  OK for mainline?
>
> Ian
>
>
> 2012-11-13  Ian Lance Taylor  <iant@google.com>
>
>         * common.opt (fPIC, fPIE, fpic, fpie): Create a Negative loop such
>         that any of these options disables the others.
>
>

Although I can't approve it, this is how it works when I introduced
the Negative feature.
Joseph S. Myers Nov. 13, 2012, 10:33 p.m.
On Tue, 13 Nov 2012, Ian Lance Taylor wrote:

> Right now if you run "gcc -fpie -fpic" you get, in effect, "gcc -fpie".
> I think you should get "gcc -fpic".  In general I think that of the
> options -fpic, -fPIC, -fpie, -fPIE, -fno-pic, -fno-PIC, -fno-pie,
> -fno-PIE the compiler should act as though only the last of those
> options were specified.  That follows the usual formulat in which the
> last option wins.
> 
> This patch implements that.  Bootstrapped and tested on
> x86_64-unknown-linux-gnu.  OK for mainline?

OK.

Patch hide | download patch | download mbox

Index: common.opt
===================================================================
--- common.opt	(revision 193484)
+++ common.opt	(working copy)
@@ -1583,19 +1583,19 @@  Common Report Var(flag_peephole2) Optimi
 Enable an RTL peephole pass before sched2
 
 fPIC
-Common Report Var(flag_pic,2)
+Common Report Var(flag_pic,2) Negative(fPIE)
 Generate position-independent code if possible (large mode)
 
 fPIE
-Common Report Var(flag_pie,2)
+Common Report Var(flag_pie,2) Negative(fpic)
 Generate position-independent code for executables if possible (large mode)
 
 fpic
-Common Report Var(flag_pic,1)
+Common Report Var(flag_pic,1) Negative(fpie)
 Generate position-independent code if possible (small mode)
 
 fpie
-Common Report Var(flag_pie,1)
+Common Report Var(flag_pie,1) Negative(fPIC)
 Generate position-independent code for executables if possible (small mode)
 
 fplugin=