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.
Questions tagged [lto]
130 questions
4
votes
0 answers
Extracting LLVM bitcode embedded using `-lto-embed-bitcode`
Goal: Extract full-program (merged) post-LTO bitcode from an ELF binary.
The program happens to be written in Rust, but I don't think that's a crucial detail.
I'm able to compile a Rust program into an ELF binary with a .llvmbc section using the…
![](../../users/profiles/109414.webp)
Edd Barrett
- 2,751
- 2
- 23
- 37
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…
![](../../users/profiles/15011303.webp)
fan
- 41
- 1
4
votes
0 answers
Getting assember output from GCC/Clang in LTO mode
Normally, one can get GCC's optimized assembler output from a source file using the -S flag in GCC and Clang, as in the following example.
gcc -O3 -S -c -o foo.s foo.c
But suppose I compile all of my source files using -O3 -flto to enable link-time…
![](../../users/profiles/4480394.webp)
Mona the Monad
- 1,355
- 1
- 11
- 20
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…
![](../../users/profiles/2389160.webp)
Mettbe
- 113
- 6
4
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…
![](../../users/profiles/3479085.webp)
Snorklebort
- 103
- 9
4
votes
2 answers
Size optimization options
I am trying to sort out an embedded project where the developers took the option of including all the h and c files into a c file, then they can compile just that one file with the -whole-program option to get good size optimization.
I hate this and…
![](../../users/profiles/3982327.webp)
Chris Aaaaa
- 167
- 1
- 7
4
votes
1 answer
DLL linking failed with LTO using MinGW-W64
I failed to build a shared library for Windows x86-64 using MinGW-W64 with -flto. Here is what I get (compilation is done on a Linux box):
# ...
x86_64-w64-mingw32-g++ -c -std=gnu++11 -fvisibility=hidden -DGLEW_STATIC -Ofast -flto -frtti -pedantic…
![](../../users/profiles/1164127.webp)
lesenk
- 761
- 1
- 8
- 21
4
votes
2 answers
Building Chromium, WebRTC without LTO
I'm on Arch Linux x86_64, attempting to build the WebRTC libraries. I get compile errors when I do:
[ghilliard@diadem trunk]$ ninja -C out/Release peerconnection_server
ninja: Entering directory `out/Release'
[1/1] LINK…
![](../../users/profiles/1830736.webp)
George Hilliard
- 13,581
- 5
- 50
- 88
3
votes
0 answers
gcc 9.2: spurious -Wuninitialized
I am trying to build our code base with gcc 9.2.0, but when using -flto, I get a dozen warnings with missing information.
These issues did not arise with gcc6.3.
: In member function ‘__ct_base ’:
: error: is used…
![](../../users/profiles/1359413.webp)
Julien Vivenot
- 2,150
- 11
- 16
3
votes
0 answers
Using LTO causes undefined reference to std::basic_string destructor
Decided to try LTO in my build (CentOS 7, CMake 3.14.3, gcc 8.2.1, -std=c++17):
# this adds "-flto -fno-fat-lto-objects"
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
All projects build fine, with exception of…
![](../../users/profiles/6427477.webp)
C.M.
- 2,353
- 1
- 11
- 25
3
votes
2 answers
INTERPROCEDURAL_OPTIMIZATION not set even if check_ipo_supported() works in CMake
I've the following project in CMake 3.14.0, that builds a project for Visual Studio 2017 64 bit generator (minimum version is 3.10.0 because other developer can have previous versions of CMake, but greater than 3.9.0):
cmake_minimum_required…
![](../../users/profiles/979325.webp)
Jepessen
- 9,377
- 11
- 64
- 111
3
votes
1 answer
Are multiple source files being passed to gcc treated as a single translation unit?
I think I've read that compiling multiple files with gcc at the same time would achieve the same thing as adding all sources into a single source file, as per Single Compilation Unit, but I can't find any sources on that anymore. Is that true?
We…
![](../../users/profiles/131326.webp)
Spidey
- 2,248
- 1
- 23
- 32
3
votes
0 answers
C++ ODR Warning with lto enabled using nested structs
After enabling lto in one of my projects the compiler started to throw warnings for lto violations at me.
After a bit of testing it boils down to this construct.
typedef struct {
typedef struct {
} test_t;
std::vector t;
}…
![](../../users/profiles/3029308.webp)
Thalhammer
- 275
- 2
- 7
3
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…
![](../../users/profiles/5840652.webp)
Vinci
- 1,060
- 7
- 9
3
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…
![](../../users/profiles/853791.webp)
bobeff
- 2,800
- 1
- 26
- 51