lto

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

断了今生、忘了曾经 提交于 2019-12-04 18:56:41
问题 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 output assembly file between first and second, why? OS: linux Compiler: GCC 4.7 回答1: The difference between fat and non-fat object files is that fat object files contains both intermediate language as well as the normally compiled code. At linktime, if

Mingw x64 Windows: plugin needed to handle lto object

北城以北 提交于 2019-12-04 01:28:23
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 mingw(i686-5.1.0-posix-dwarf-rt_v4-rev0), everething is OK. My flags are: CXX_FLAGS "-fno-exceptions -fno-rtti -std=c++14 -O3 -fstrict-aliasing -flto -fomit-frame-pointer -march=native -ffast-math -funroll-loops" LINKER_FLAGS "-O1 -s" I tried to add -fuse-linker-plugin and -fno-use-linker-plugin, but it didn't help. My OS is 64-bit Windows 10. I use CLion and

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

一笑奈何 提交于 2019-12-03 11:32:42
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 output assembly file between first and second, why? OS: linux Compiler: GCC 4.7 The difference between fat and non-fat object files is that fat object files contains both intermediate language as well as the normally compiled code. At linktime, if you invoke compiler without -flto, fat objects will be handled as normal object files (and LTO information

undefined reference cross compiling static libraries with LTO under GCC

跟風遠走 提交于 2019-12-01 16:53:01
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 reference errors from the linker for all symbols the target uses from the library. eg, building bar.a from bar.cpp int bar (void) {return 42;} and linking with foo.cpp extern int bar (void); int main (int, char**) {bar ();} using the command line x86_64-w64-mingw32-g++ -flto -o foo.o -c foo.cpp x86_64-w64-mingw32-g++ -flto -o bar.o -c bar.cpp x86_64-w64

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

和自甴很熟 提交于 2019-12-01 03:57:01
问题 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. Example: shared.cpp : void deleteIt(int* ptr) { delete ptr; } main.cpp : #include <cstdlib> #include <new> void* operator new(size_t size) { void* result = std::malloc(size); if (result == nullptr) { throw std::bad_alloc(); } return result; } void operator delete(void* ptr

How to write a custom intermodular pass in LLVM?

左心房为你撑大大i 提交于 2019-11-30 08:50:15
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 time. The purpose of one such pass is to construct a call graph of the entire application. The purpose of the other such pass is that I have an idea for an optimization involving function calls and their parameters. I know about interprocedural passes in LLVM, via extending the ModulePass class, but that only allows analysis within a single module.

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

半腔热情 提交于 2019-11-29 16:19:23
问题 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 glsl-optimizer, just for reference). Here is the output: ... /usr/bin/ranlib: ir_expression_flattening.cpp.o: plugin needed to handle lto object /usr/bin/ranlib: opt_function_inlining.cpp.o: plugin needed to handle lto object /usr/bin/ranlib: opt_copy

Requirements to use flto

笑着哭i 提交于 2019-11-29 09:31:26
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 According to https://gcc.gnu.org/wiki/LinkTimeOptimization#Requirements , Despite the " link time " name, LTO does not need to use any special linker features. The basic mechanism needed is the detection of GIMPLE sections inside object files. This is currently implemented in collect2 . Therefore, LTO will work on any linker already supported by GCC. Furthermore, the GCC

How can I use lto with static libraries?

核能气质少年 提交于 2019-11-28 23:18:36
When I try to build static libraries with -flto , I get undefined reference errors: library.cpp : #include <iostream> void foo() { std::cout << "Test!" << std::endl; } main.cpp : void foo(); int main() { foo(); return 0; } Compilation output : $ g++ -flto -c library.cpp $ ar rcs library.a library.o $ g++ -flto main.cpp library.a /tmp/ccZIgxCY.ltrans0.ltrans.o: In function `main': ccZIgxCY.ltrans0.o:(.text+0x5): undefined reference to `foo()' collect2: error: ld returned 1 exit status It works fine if I link with library.o instead of library.a . What am I missing? This is with GCC 4.9.1 and

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

∥☆過路亽.° 提交于 2019-11-27 18:58:36
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 documented. Information regarding link-time optimization (LTO) would be a plus! =D -fprofile-generate enables -fprofile-arcs , -fprofile-values and -fvpt . -fprofile-use enables -fbranch-probabilities , -fvpt , -funroll-loops , -fpeel-loops and -ftracer Source: http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Optimize-Options.html#Optimize-Options PS.