https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116642

--- Comment #17 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Joshua from comment #16)
> I took out -fpie and the output assembly was different and the binary
> started working. That is contrary to the documentation which says you need
> -fpie for position independent executables.
> 
> I suppose it would be according to the documentation if I compiled with
> -fpic -fno-pie and linked with -fpie but it doesn't make sense to me why the
> difference *matters*.
> 
> Still feels very weird; like it's a different version of arbitrary changes
> that randomly caused it to not generate the relocation; like so many
> hundreds of changes trying to produce the minimal case that generated it.
> 
> If I *knew* it was sse that's generating relocations behind my back I'd just
> turn it off and be done with it, but I don't. I only know it's one of many
> CPU features.

Do you mean -fpie or -pie?  They are different options.  -pie is passed to the
linker, but -fpie affects the code generation.

In your "Build Command" there are -fpic -pie, but not -fpie.

You *may* use -fpic -pie for linking a pie, but -fpic disables more
optimizations (doing so is necessary for a shared library, but not necessary
for a PIE) so it's not a good idea to use it for a pie.  (As I've said many
times -fpic should really be named -fshared-library or something.)

And -fpie, -fpic, and -fno-pie/-fno-pic are tri-state.  I.e. if you say -fpie
-fpic -fno-pie -fno-pic -fpic -fno-pic -fpie -fno-pie -fpie -fpic ... ... -fpie
-fpic, only -fpic (the last one) will have an effect.

Reply via email to