This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -fPIC -fPIE
On Wed, Nov 21, 2012 at 8:56 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
> Il 14/11/2012 15:27, Ian Lance Taylor ha scritto:
>> On Wed, Nov 14, 2012 at 5:36 AM, Richard Earnshaw <rearnsha@arm.com> wrote:
>>> On 13/11/12 14:56, Ian Lance Taylor wrote:
>>>>
>>>> Currently -fPIC -fPIE seems to be the same as -fPIE. Unfortunately,
>>>> -fPIE -fPIC also seems to be the same as -fPIE. It seems to me that,
>>>> as is usual with conflicting options, we should use the one that
>>>> appears last on the command line.
>>>>
>>>> Do we have an existing mechanism in options processing for one option
>>>> to turn off another, where the options are not exact inverses? I
>>>> looked for one but I didn't see one. There is support for that for
>>>> options with the Mask property, but I don't see it for non-target
>>>> options.
>>>
>>> pic and pie are mostly the same, but the pre-emption rules are different.
>>> For fpie we don't have to permit pre-emption of global definitions.
>>>
>>> I hope we don't loose that distinction.
>>
>> No, of course not. All I'm talking about here is option processing
>> when both -fPIC and -fPIE are provided. There is no change to the
>> normal case of providing just -fPIC or just -fPIE.
>
> I think both -fPIC -fPIE and -fPIE -fPIC should be the same as -fPIC.
>
> The main advantage is that you can compile a program with CFLAGS="-O2 -g
> -fPIE", and libtool's adding of -fPIC for shared libraries will work
> reliably. If -fPIE can still override -fPIC, the result depends on
> whether -fPIC comes before or after CFLAGS.
...which is exactly how all our other options work. The last one
wins. Why should these be different? Using -fPIE in CFLAGS for
libtool seems like a very specific use case, and I don't see it as
sufficient justification for changing our ordinary option processing.
Ian