One of the optimizations performed during an IPO compilation is code layout. The analysis performed by the compiler during multi-file IPO determines a layout order for all of the routines for which it has intermediate representation (IR) information. If a single object is being generated, the compiler generates the layout simply by compiling the routines in the desired order. For a multi-object IPO compilation, the compiler must tell the linker about the desired order.
Mac OS*: Intel®-based systems running Mac OS do not support a multiple object compilation model.
If you are generating an executable in the link step, the compiler does all of this automatically. However, if you are generating object files instead of an executable, the compiler generates a layout script, which contains the correct information needed to optimally link the executable when you are ready to create it.
This linking tool script must be taken into account if you use either -ipo-c or -ipo-S (Linux*) or /Qipo-c or /Qipo-S (Windows*). With these options, the IPO compilation and actual linking are done by different invocations of the compiler. When this occurs, the compiler issues a message indicating that it is generating an explicit linker script, ipo_layout.script.
The Windows linker (link.exe) automatically collates these sections lexigraphically in the desired order.
The compiler first puts each routine in a named text section that varies depending on the platform.
Linux:
The first routine is placed in .text00001, the second is placed in .text00002, and so on. It then generates a linker script that tells the linker to first link contributions from .text00001, then .text00002.
Windows:
The first routine is placed in .text$00001, the second is placed in .text$00002, and so on.
When ipo_layout.script is generated, the typical response is to modify your link command to use this script:
Example |
---|
--script=ipo_layout.script |
If your application already requires a custom linker script, you can place the necessary contents of ipo_layout.script in your script.
The layout-specific content of ipo_layout.script is at the beginning of the description of the .text section. For example, to describe the layout order for 12 routines:
Example output |
---|
.text : |
For applications that already require a linker script, you can add this section of the .text section description to the customized linker script. If you add these lines to your linker script, it is desirable to add additional entries to account for future development. The addition is harmless, since the “*(…)” syntax makes these contributions optional.
If you choose to not use the linker script your application will still build, but the layout order will be random. This may have an adverse affect on application performance, particularly for large applications.