Questions tagged [lto]

LTO abbreviates Link-Time Optimization. LTO is a phase of optimization applied to a compiled program at the linkage step, with the advantage that all of the compiled object files comprising the program can then be analysed together. Conventional optimization is performed by the compiler alone, which can generate and optimize only one object file at a time.

156 questions
5
votes
1 answer

Does gcc have thin lto?

Clang allows to use a thin lto to speed up compilation time while still keeping most of the advantages of using lto with the option -flto=thin. Does gcc have an equivalent of clang's thin lto?
aganm
  • 1,245
  • 1
  • 11
  • 30
5
votes
1 answer

GCC 8 for ARM in LTO mode is removing interrupt handlers and weak functions - how to prevent it?

My target device is an EFM32 Cortex-M3 based device. My toolchain is the official ARM GNU toolchain gcc-arm-none-eabi-8-2018-q4-major. Everything works fine without LTO, but to make LTO work I have to mark all interrupt handler code with -fno-lto. I…
RushPL
  • 4,732
  • 1
  • 34
  • 44
5
votes
1 answer

Interoperability between Clang, GCC and LTO

I know that Clang and GCC are more or less compatible C/C++ compilers as long as one takes care of things like architecture flags, predefines and linking the right libraries. Creating libraries with one compiler and linking them with objects created…
Vinci
  • 1,382
  • 10
  • 12
5
votes
2 answers

autoconf recipe to use gcc-ar and gcc-ranlib

I'm using link-time optimisation (LTO) in a project that compiles under both GCC and Clang and builds a static library. It's working with GCC 4.8, but GCC 5.4 makes thin LTO objects and when automake tries to build the static library with ar it…
Bruce Merry
  • 751
  • 3
  • 11
5
votes
0 answers

Enabling link-time optimizations causes a linker error?

I have code which compiles and links fine. I'm now trying to enable link-time optimizations, but adding -flto to my compiler and linker flags is causing a linker error: /usr/local/lib/libboost_thread.a(thread.o): \ In function `void…
Steve Lorimer
  • 27,059
  • 17
  • 118
  • 213
5
votes
1 answer

Debugging linkage warning "type of symbol does not match original declaration"

I'm trying to systematically debug the following problem: % gcc -fPIC -flto -o try1.o -c try1.c % gcc -fPIC -flto -o try2.o -c try2.c % gcc -shared -flto -fPIC -o try.so try1.o try2.o try2.c:1:14: warning: type of 'aaaaaaaa' does not match original…
ugoren
  • 16,023
  • 3
  • 35
  • 65
5
votes
0 answers

How do you use PGO + LTO optimization with GCC

I've been researching a lot lately on how PGO and LTO can significantly optimize a programs speed (some say around 20%). I currently just program in C and build GUI's with GTK+ in Windows (compiling everything through GCC) and only use -O2 for…
Snorklebort
  • 123
  • 2
  • 10
5
votes
1 answer

Clang link-time optimization with replaced operator new causes mismatched free()/delete in valgrind

When using clang 3.5.0 with -flto and linking with a shared library, it seems that calls to operator delete in the shared library don't follow the same symbol resolution order as calls to operator new from the main objects. …
Tavian Barnes
  • 12,477
  • 4
  • 45
  • 118
5
votes
2 answers

C++11 enum with class members and constexpr link-time optimization

In my project I have a lot of enumerations that need to have additional attributes associated with the enumeration members and auxiliary static methods associated with the enumeration type. As much as I know, this is not possible to have with the…
David L.
  • 3,149
  • 2
  • 26
  • 28
4
votes
1 answer

iOS 14 linking module flags 'Dwarf Version': IDs have conflicting behaviors

I'm trying to make my app compatible with iOS 14 (Xcode 12.3). The build failed on linking stage with following error: ld: linking module flags 'Dwarf Version': IDs have conflicting behaviors in 'xxx.o' and 'ld-temp.o' clang: error: linker command…
fan
  • 41
  • 1
4
votes
0 answers

"plugin needed to handle lto object" problem when creat python wrapper with MinGW 32 bits

I'm trying to build a python wrapper of a shared C++ library using pybind11, with MinGW 32 bits. It seems pybind11 enabled LTO, see the configure result from CMake bellow: The C compiler identification is GNU 9.2.0 The CXX compiler identification is…
Fay
  • 105
  • 1
  • 5
4
votes
2 answers

Which is the correct way to build a static library with link time code generation on Linux?

I'm wandering which is the right way to compile static library on Linux with GCC in such way that when link time optimizations (LTO) be applied to the executable the library to be consumable and possibly to be achieved optimal performance. When…
bobeff
  • 3,543
  • 3
  • 34
  • 62
4
votes
1 answer

Undefined References with Link-Time Optimization

I am trying to link a static library with an executable file, following this example, but on MinGW-w64. My CMakeLists file: (note that this is identical to the one in that answer) cmake_minimum_required (VERSION 2.6) project…
tomb
  • 1,817
  • 4
  • 21
  • 40
4
votes
0 answers

gcc static linking with LTO flag with boost filesystem fails

boost version 1.64 gcc version 6.4.1 Linux OpenSuse x64 42.2 Cmake 3.5.2 [linking, no LTO] works: -std=gnu++11 -O2 -fopenmp -static /opt/lib64/libboost_filesystem.a /opt/lib64/libboost_system.a [linking, with LTO] does not work: -std=gnu++11…
Mettbe
  • 101
  • 1
  • 6
4
votes
1 answer

How to write LTO-enabled code?

What are the caveats and gotchas needed to keep in mind when writing code or build scripts for compilation with LTO? The motivation behind this question is to understand better why some projects do not compile cleanly when LTO is enabled. In…
alecov
  • 4,882
  • 2
  • 29
  • 55
1 2
3
10 11