[PATCH] configure: Allow a host makefile fragment to override PIE flag settings.

Richard Sandiford richard.sandiford@arm.com
Fri Aug 20 10:29:21 GMT 2021


Iain Sandoe <iain@sandoe.co.uk> writes:
> Hi Richard,
>> Maybe it would be easier to have the makefile fragments determine
>> something like CODE_MODEL_CFLAGS, which can be "-fPIC", "-mdynamic-no-pic",
>> etc., and use:
>> 
>> COMPILER += $(NO_PIE_CFLAGS) $(CODE_MODEL_CFLAGS)
>
> OK. I have misgivings about this - the problem is that:
>
> -fPIC -fno-PIE != -fno-PIE -fPIC,  which is not obvious to many folks - who expect that
> the “last edition of a flag will be the one in force”.
>
> So the PIE-ness and the PIC-ness are decoupled in the configury but they need to be
> ordered specifically for targets that want PIC code by default (FWIW, I don’t think Darwin
> is the only default-PIC case here, from discussions on irc).

Yeah, that's what the above was supposed to achieve.  In other words,
if you force non-PIE, you also need to follow that by $(CODE_MODEL_CFLAGS),
which restates whatever the base code model is.

If it's the decoupling you're worried about, then an alternative would
be to have:

  NO_PIE_CFLAGS="-fno-PIE \$(CODE_MODEL_CFLAGS)"

I was going to suggest that originally, but thought the above might
be simpler to follow later.

Thanks,
Richard


More information about the Gcc-patches mailing list