[PATCH]: Fix PR middle-end/6123, cleanup defining __pic__/__PIC__

Alan Modra amodra@bigpond.net.au
Sat Apr 3 11:45:00 GMT 2004


On Sat, Apr 03, 2004 at 02:08:47AM -0500, Kaveh R. Ghazi wrote:
> 1.  Explain why "PPC64 Linux always is PIC" without defining flag_pic
>     internally.  This appears to be how Mips Linux handles itself.
>     Why the difference?

On most other targets, -fpic, ie. flag_pic, means two things:
a) generate PIC code, and
b) generate code suitable for ELF shared libraries.
I'll not argue the wisdom of -fpic meaning two things, but that's just
how things evolved.  On PowerPC64, code generation is always PIC, but we
don't want the overhead of meeting shared library run-time symbol
resolution requirements when generating application code.  Thus, we
don't want to set flag_pic all the time.

> 2.  Explain why PPC64 Linux defines only __PIC__ and not __pic__.
>     (*Every* other target will define __pic__ also.)  Can we safely
>     define __pic__ on this target?  That alone will make it more
>     conforming.

I think you could define __pic__ without causing trouble.

> 3.  Suggest a way to clean up the macro settings without hurting PPC64
>     Linux.  Could be as simple as setting flag_pic=1 in the startup
>     routines for PPC64 Linux if that's appropriate.  Other ideas come
>     to mind, but since you know more about this platform you are in a
>     better position to suggest the best alternative.

Please don't set flag_pic all the time.  As I explained above, that
wouldn't be appropriate.

> Now it's not yet clear whether the "established meanings" for __pic__
> and __PIC__ are relevant, useful or even correct for the few targets
> where changes in behavior might occur.
> 
> You've stated "PPC64 Linux always is PIC".  Fine, I can easily rewite
> the patch to consolidate every other platform and leave the behavior
> of PPC64 Linux unchanged.  That may or may not be correct or even good
> for PPC64 Linux.

I don't really like PowerPC64 being the odd target.  As it is, there
are things that urgently need tidying, like the rs6000 backend not using
config/linux.h and instead using it's own linux*.h that don't always get
updated with Linux specific changes..

Let me do some research on which of the two meanings of __PIC__ is
most important.  If it turns out that __PIC__ is mostly used to detect
compilation in shared library mode, then the current PowerPC64 behaviour
is wrong.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Gcc-patches mailing list