5

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 optimization.

I've been reading to compile with the flags

gcc -Wall -g -mwindows -O3 -fprofile-generate -flto example.c -o example.exe `pkg-config --cflags --libs gtk+-3.0`

a .gcno and a .gcda file is created, then you run the compiled .exe a bunch of times then just re-compile the same .c file again but swap the "-fprofile-generate" with "-fprofile-use"? (while making sure all these files stay in the same folder/directory, and use a different name for the .exe compiled the second time)

gcc -Wall -g -mwindows -O3 -fprofile-use -flto example.c -o program.exe `pkg-config --cflags --libs gtk+-3.0`

Or do you make use of the .gcno/.gcda file somehow? Also read things about using a "benchmark".

Question:

What are the steps to use it in GCC? (Step by step guide would help :)

Snorklebort
  • 123
  • 2
  • 10
  • 4
    That's a lot of questions in one but the general procedure for invoking the compiler seems alright. Maybe you can narrow your question down a little? – 5gon12eder Feb 17 '16 at 03:05

0 Answers0