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.

130 questions
44
votes
2 answers

What information does GCC Profile Guided Optimization (PGO) collect and which optimizations use it?

Which information does GCC collect when I enable -fprofile-generate and which optimization does in fact uses the collected information (when setting the -fprofile-use flag) ? I need citations here. I've searched for a while but didn't found anything…
JohnTortugo
  • 5,435
  • 7
  • 33
  • 63
39
votes
4 answers

How do I enable link time optimization (LTO) with CMake?

I have the most recent cmake build and trying all build configurations (Debug, MinSizeRel, RelWithDebugInfo, Release, General) I see nowhere (text search) in generated makefiles the string -lto, so or the functionality is still not present, or it…
CoffeDeveloper
  • 6,929
  • 2
  • 31
  • 58
32
votes
1 answer

Using GCC's link-time optimization with static linked libraries

I'm trying to use link-time optimizations with the -flto flag of GCC (6.1.1). While it works fine with my code, it doesn't link with a static linked library I'm also building and linking with my project (which is Engine and the library is…
CpCd0y
  • 590
  • 1
  • 6
  • 16
23
votes
3 answers

LTO with LLVM and CMake

I am trying to apply Link Time Optimization with LLVM on a CMake Project, that creates a shared library. My question is pretty much the same as this one: Switching between GCC and Clang/LLVM using CMake. However, the answers do not seem to be…
SPMP
  • 1,079
  • 1
  • 8
  • 21
22
votes
2 answers

How can I use lto with static libraries?

When I try to build static libraries with -flto, I get undefined reference errors: library.cpp: #include void foo() { std::cout << "Test!" << std::endl; } main.cpp: void foo(); int main() { foo(); return 0; } Compilation…
Tavian Barnes
  • 11,679
  • 3
  • 41
  • 107
17
votes
2 answers

Why does using LTO increase the size of my Rust binary?

Introduction I finished a small Rust project (about 300 lines of code) with the following dependencies: rumqtt signal log env_logger Problem When using cargo build --release without further configuration, a 2.942.744 bytes (= 2,8 MiB) binary is…
PEAR
  • 627
  • 2
  • 9
  • 17
17
votes
1 answer

What is GCC lto wrapper?

I am using buildroot to prepare images for embedded system. I want to export buildroots internal cross compiler so others can use same version, After command checking GCC version: arm-linux-gcc -vI see configured COLLECT_LTO_WRAPPER to static…
Mihalko
  • 493
  • 1
  • 5
  • 14
16
votes
1 answer

Clang link-time optimization doesn't work properly on Fedora 18

I'm a newcomer to clang, so it's likely I'm doing something silly. But I've spent several hours looking for solutions, including searching here, where I haven't found questions addressing -flto with distro-provided packages. The detail of this…
SnoopyLane
  • 179
  • 1
  • 6
16
votes
2 answers

What is the difference in gcc between lto and fat-lto-objects

I have tried to compile to assembler my source code with next flags: 1. -flto 2. -flto -ffat-lto-objects 3. -flto -fno-fat-lto-objects Third one provides optimized slim LTO code as written in documentation, but I don't see any difference in the…
Laser
  • 5,915
  • 5
  • 45
  • 76
15
votes
3 answers

gcc LTO appears to strip debugging symbols

I have project, running on an ARM Cortex-M4 processor, where I'm trying to include the gcc link-time optimization (LTO) feature. Currently my compilation and linking flags are: CFLAGS = -ggdb -ffunction-sections -Og LDFLAGS =…
swineone
  • 920
  • 7
  • 19
13
votes
1 answer

Requirements to use flto

If I want to compile my project with -flto is it enough to have built gcc with --enable-gold or do I also need to build gold and replace ld with it? And do I need any other flags? Ie I'm doing this gcc -flto one.c two.c
chew socks
  • 1,306
  • 1
  • 13
  • 31
12
votes
1 answer

Mingw x64 Windows: plugin needed to handle lto object

When I'm trying to compile my project with 64-bit mingw (x86_64-5.1.0-posix-seh-rt_v4-rev0) I got messages: BFD: my/project/dir/filename.cpp.obj: plugin needed to handle lto object for each source file. Yet when I compile with 32-bit…
EvgeniyZh
  • 829
  • 8
  • 17
11
votes
3 answers

How to write a custom intermodular pass in LLVM?

I've written a standard Analysis pass in LLVM, by extending the FunctionPass class. Everything seems to make sense. Now what I'd like to do is write a couple of intermodular passes, that is, passes that allows me to analyze more than one module at a…
stepthom
  • 1,362
  • 1
  • 15
  • 24
10
votes
4 answers

Prevent GCC LTO from deleting function

I work with GCC-ARM-Embedded and FreeRTOS. FreeRTOS has the function vTaskSwitchContext() which is used only in some inline assembler code. The problem is: When I use LTO, GCC does not consider the inline assembler code and thinks the function is…
Jan Hieber
  • 125
  • 8
10
votes
1 answer

undefined reference cross compiling static libraries with LTO under GCC

I am attempting to use GCC 4.9.2 to cross compile an application from Linux (x86_64-pc-linux-gnu) for Windows (x86_64-w64-mingw32). When building targets that link against static libraries and also using link-time optimisation I get undefined…
dcro
  • 141
  • 1
  • 5
1
2 3
8 9