Section F.3. Compiling and Linking


F.3. Compiling and Linking

F.3.1. Compiler Options

GCC and the binary utilities provide some options supporting zSeries. You can find a detailed description of all GCC options in the manual Using the GNU Compiler Collection.[4] This manual provides a section exclusively devoted to the zSeries-specific options. We do not describe these options in full detail but rather give an overview. Also, it is likely that additional compiler options will be provided for new zSeries models and improvements might be offered for existing models. Check the most recent version of the GCC manual (see footnote 4) for details.

[4] GCC manual, www.gnu.org/software/gcc/gcc.html

Figure F-3 shows a summary of the performance improvements achieved between 1999 and 2004 that suggests it is really worth exploiting GCC's zSeries-specific optimization options. Note that all data given in Figure F-3 was taken on the latest zSeries model available in the particular year and is normalized. Overlapping measurements have been used to scale when the measurements were taken on a new zSeries model. The publication "Contributions to the GNU Compiler Collection"[5] details how the measurements were conducted.

[5] www.research.ibm.com/journal/sj/442/edelsohn.pdf

Figure F-3. Performance increase due to improved compiler optimization


Table F-3 shows the zSeries-specific code optimization options.

Table F-3. zSeries-Specific Code Optimization Compiler Options

Options

Function

-march=cpu-type

Exploits all instructions provided by cpu-type, including those not available on older models. In general, code compiled with this option does not execute on older CPUs. See the GCC manual (footnote 4) for a list of supported CPU types.

-mtune=cpu-type

Schedules instructions to best exploit the internal structure of cpu-type. This option does not introduce any incompatibility with older CPUs, but code tuned for a different CPU might execute more slowly.

-mzarch and mesa

Generate code exploiting the instruction set of the ESA/390 or the z/Architecture, respectively. See the GCC manual (see footnote 4) for default values and interaction with other options.

-m64 and -m31

Control whether the generated code is compliant to the Linux for S/390 ABI (-m31) or the Linux for zSeries ABI (-m64).[6],[7]

-msmall-exec and -mno-small-exec

A switch to optimize jump instructions in executables with a total size not exceeding 64K. Some options exist to control and optimize stack growth.


[6] For details on the ABI, see LINUX for S/390 ELF Application Binary Interface Supplement, http://oss.software.ibm.com/linux390/docu/l390abi0.pdf.

[7] For details on the ABI, see LINUX for zSeries ELF Application Binary Interface Supplement, http://oss.software.ibm.com/linux390/docu/lzsabi0.pdf.

Table F-4 shows some options available to control and optimize stack growth.

Table F-4. Compiler Options to Control and Optimize Stack Growth

Options

Function

-mwarn-framesize=framesize and -mwarn-dynamicstack

Cause a compile-time check of whether a function exceeds a given stack frame size, or uses dynamically sized stack frames. These options help when stack space is rare, as is the case in the Linux kernel, or when application programs fail during a stack overflow.

-mstack-guard=stack-guard and -mstack-size=stack-size

Help debugging stack size problems. The checks are, however, performed during runtime by executing some extra code inserted into the binary.

-mpacked-stack and -mno-packed-stack

Control whether the stack frame uses a space-optimized, dense packing scheme for register save slots. See the GCC manual (footnote 4) for details concerning compatibility with other options and for call compatibility with binary code generated by pre-3.0 versions of GCC.

-mbackchain and mno-backchain

Control whether the address of the caller's frame is stored as a so-called backchain pointer into the callee's stack frame. See the GCC manual (footnote 4) for details concerning the compatibility with other options, and for details related to debugging.


Linux for zSeries has an important difference from other systems concerning shared libraries. The -fpic and -fPIC options cause the compiler to generate positioning-dependent code (pic) for use in shared or reentrant libraries. On zSeries, -fpic causes the Global Offset Table to be rather small, so you should instead use -fPIC for large shared libraries.

If the linker reports a "relocation overflow" bug, check whether the project in question uses the -fpic option. Changing it to -fPIC might fix the problem. Note that you must use the same variant of this option for all compiler runs related to the same project.

Last but not least, the options -mfused-madd, -mno-fused-madd, -mhard-float, and -msoft-float control the usage of floating-point operations. See the "Principles of Operation"[8],[9] for a complete description of the zSeries instruction set and architecture. In addition, some technical papers describe the internals of how GCC generates code for zSeries, available for download.[10],[11],[12]

[8] "ESA/390 Principles of Operation", http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9ar007

[9] "z/Architecture Principles of Operation", http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr001

[10] "The GNU 64-bit PL8 compiler: Towards an open standard environment for Firmware development", www.research.ibm.com/journal/rd/483/gellerich.pdf

[11] "Porting GCC to the IBM S/390 Platform", www.gccsummit.org/2003/

[12] "Contributions to the GNU Compiler Collection", www.research.ibm.com/journal/sj/442/edelsohn.pdf

F.3.2. Assembler Code

Any assembler code must, of course, be rewritten. See ESA/390 Principles of Operation[13] and z/Architecture Principles of Operation[14] for a complete description of the zSeries architecture and instruction set.

[13] http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9ar007

[14] http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr001

F.3.3. Stack Frame Layout and Linkage

Although not immediately required for the development of application programs in C and C++, you might occasionally need detailed information about certain implementation issues such as register usage conventions or the stack frame layout. This information is found in the ELF Application Binary Interface Supplement (see footnotes 6 and 7). More conventions used when compiling for zSeries are described in "Porting GCC to the IBM S/390 Platform" (see footnote 11).

F.3.4. Predefined Symbols

If some code needs to be platform-dependent, you can use two predefined symbols in preprocessor expressions. __s390__ is set when compiling for zSeries in 31-bit or 64-bit mode, or when compiling for S/390. __s390x__ is set when compiling for zSeries in 64-bit mode.

F.3.5. Debugging

Many Linux debugging tools are available on Linux for zSeries. One additional feature is available for Linux running under VM. Using VM's trACE command offers a convenient and powerful way to debug the whole Linux system. See the book z/VM CP Command and Utility Reference[15] for a reference on the trACE command. An introduction to debugging is given in Chapter 22 of the book Linux on the Mainframe.[16] A detailed description of how to debug is included in most Linux distributions in the file /usr/src/linux/Documentation/s390/debugging390.txt. For debugging more difficult problems, you can find information about register usage, stack frame layout, and other conventions in the ELF Application Binary Interface Supplement (see footnotes 6 and 7).

[15] IBM publication number SC24-5967

[16] Eilert, John, et al. Linux on the Mainframe. Prentice Hall, 2003




UNIX to Linux Porting. A Comprehensive Reference
UNIX to Linux Porting: A Comprehensive Reference
ISBN: 0131871099
EAN: 2147483647
Year: 2004
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net