Martin Drozdik Martin Drozdik - 12 days ago 9
C++ Question

Why does qmake add -O1 and -O2 optimization flags in this case?

I am trying to pass optimization flags to gcc using the qmake .pro file:

hello.pro:

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

QMAKE_CXXFLAGS += -O3 \


main.cpp:

#include <iostream>

int main()
{
std::cout << "Hi!" << std::endl;
return 0;
}


compilation output:


15:14:34: Running steps for project TestGrounds...

15:14:34: Starting:

"/usr/bin/make" clean rm -f main.o

rm -f *~ core *.core

15:14:34: The process "/usr/bin/make" exited normally.

15:14:34: Configuration unchanged, skipping qmake step.

15:14:34: Starting: "/usr/bin/make"

g++ -c -pipe -O3 -O2 -Wall -W -fPIE -I/opt/Qt5.2.0/5.2.0/gcc/mkspecs/linux-g++ -I../../Projects/TestGrounds -I. -o main.o ../../Projects/TestGrounds/main.cpp

g++ -Wl,-O1 -Wl,-rpath,/opt/Qt5.2.0/5.2.0/gcc -o TestGrounds main.o

15:14:35: The process "/usr/bin/make" exited normally.

15:14:35: Elapsed time: 00:01.


But why are the -O1 and -O2 optimization flags passed too?

I tried to clean the project and rebuild it and the result is the same.

Answer

Try this

QMAKE_CXXFLAGS_RELEASE -= -O1
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CXXFLAGS_RELEASE *= -O3
Comments