Operating System - HP-UX
1832285 Members
3659 Online
110041 Solutions
New Discussion

disadvantages of using +Z instead of +z

 
SOLVED
Go to solution
Ian Lochray
Respected Contributor

disadvantages of using +Z instead of +z

Can someone please tell me if there is any disadvantege to using the +Z compiler/linker flag compared to +z. As the size of my product increases I am geeting more messages from the compiler telling me to compile with +Z. Is there any problem with compiling all my source with +Z rather than just the ones that cannot be compiled with +z?
3 REPLIES 3
Steve Steel
Honored Contributor

Re: disadvantages of using +Z instead of +z

Hi

From
http://docs.hp.com/hpux/onlinedocs/4311/ar0903/options.htm#option+z

+z Command Line Option Syntax


+z


Description:
Causes the compiler to generate position-independent code (PIC), necessary for building a shared library.
Use -b to create a shared library.

+z is similar to the +Z option. Use +z unless the linker generates an error message indicating that you should use +Z.

Thus use +z of preference


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
H.Merijn Brand (procura
Honored Contributor

Re: disadvantages of using +Z instead of +z

+Z enables long offsets, where +z has limits IIRC. I mostly use +Z, which might cause small object size increases, but at least is safe in large/huge applications

I've never encountered problems with +Z

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Mike Stroyan
Honored Contributor
Solution

Re: disadvantages of using +Z instead of +z

The +Z option produces one extra instruction for each sequence of code that references a global symbol or calls a globally visible function. That is a small penalty in size and performance.

The +Z option is required for shared libraries that reference more than 4096 globally visible symbols. You could try using -h symbol hiding or -Bsymbolic to reduce the number of symbols that your shared libraries pu t in the procedure and data lookup tables. That could improve code size and performance, since the code to call a local symbol is smaller and faster. Symbol hiding needs a little care. You should not hide symbols that the compiler has introduced to implement features like static variable initializers or virtual function tables.