0

I noticed that in the default release configuration, qmake (qmake 3.1, qt 5.9.5 - whatever is installed on my Ubuntu build box) passes -Wl,O1 to g++ when linking. So the linking command line looks like

g++ -Wl,-O1 -flto -O2 -o program program.o lib1.a lib2.a ...

where -flto -O2 are the options that I'm passing via QMAKE_LFLAGS_RELEASE to enable LTO.

Now the question: why qmake has this -Wl,-O1 option and is it going to interfere with LTO?

Alexey B.
  • 1,106
  • 8
  • 17

1 Answers1

1

QMake passes -Wl,O1, because it is meant to be a good default.

It will not harm LTO, because your -O2 option comes later and overrides the -Wl,O1.

From g++'s man page:

If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.

You can remove the -Wl,-O1 from your Makefile by specifying

QMAKE_LFLAGS_RELEASE -= -Wl,-O1
jobor
  • 339
  • 1
  • 7