You copied the Doc URL to your clipboard.

Restrictions with link time optimization

The support for link time optimization in ARM® Compiler 6 is alpha quality. Future releases may have fewer restrictions and more features. The user interface to link time optimization may be subject to change in future releases.

Red Hat Enterprise Linux platforms
ARM Compiler does not support link time optimization on 32-bit Red Hat Enterprise Linux platforms.
armlink resolves all link time code generation before libraries are loaded. This allows bitcode files to reference code and data that resides in libraries, however this means that the link time optimizer cannot use any bitcode files in libraries or be aware of references from library objects to bitcode files as the objects from the libraries have not yet been loaded. See References to symbols in bitcode files from libraries for more information.
No bitcode libraries
armlink only supports bitcode objects on the command line. It does not support bitcode objects coming from libraries. armlink gives an error message if it encounters a bitcode file while loading from a library.
References to symbols in bitcode files from libraries

The link time optimizer may remove global symbols that have not been referenced from other bitcode or other ELF files. If there are symbols that are referenced only from objects in libraries then the link time optimizer might remove them, leading to an undefined symbol error at link time.

For example, consider the following source code:

extern void function(void);

void library_function(void)

void function(void)

extern void library_function(void);

int main(void)

The following commands compile the library source code, create a library file, compile the program source code, then link the resulting object files using link time optimization:

armclang --target=arm-arm-none-eabi -march=armv8-a -c file_in_library.c
armar --create library.a file_in_library.o
armclang --target=arm-arm-none-eabi -march=armv8-a -c -flto file.c
armlink --lto file.o library.a

The link time optimizer might remove function() as unused because it is only referenced by a library function. This results in the following error:

Error: L6218E: Undefined symbol function (referred from file_in_library.o).
Finished: 0 information, 0 warning and 1 error messages.

To prevent the link time optimizer from removing the symbol you must use one or more of the following armlink command line options:

  • --keep symbol for each symbol in bitcode objects that is referenced only from objects from libraries.
  • --lto_keep_all_symbols to prevent the optimizer from removing symbols.
Partial linking
The armlink options --partial and --ldpartial only work with ELF files. The linker will give an error message if it detects a bitcode file.
Scatter loading

The output of the link time optimizer is a single ELF object file that by default is given a temporary filename. This ELF object file contains sections and symbols just like any other ELF object file, and these will be matched by scatter loading selectors as normal.

When all the bitcode files are optimized at once there is just one ELF object file output and this can be named by the armlink option --lto_set_intermediate_filename. This ELF file name can be referenced in the scatter loading file.

We recommend that link time optimization is only performed on code and data that does not require precise placement in the scatter file. With general scatter loading selectors such as *(+RO) and .ANY(+RO) used to select sections generated by link time optimization.

It is not possible to match bitcode files by name in scatter loading.


The scatter loading interface is subject to change in future versions of ARM Compiler 6.
Limited compatibility checking
The linker does not perform extensive checks on the bitcode files before passing them to the optimizer. Extra care must be taken to present compatible bitcode files to armlink.
Executable and library compatibility
The armclang and llvm-lto executables and the libLTO library must come from the same ARM Compiler 6 installation. Any use of llvm-lto or libLTO other than those supplied with ARM Compiler 6 is unsupported.

Related information