In packages where we are passing -std=c++11
switch to -std=c++17
, or, -std=c++1z
in the case of Qt.
This PR also contains a commit that improves debug output when building Qt for debugging (DEBUG=1
).
Now we’ll get output like this:
0g++ -c -pipe -ffunction-sections -O2 -fPIC -std=c++11 -fno-exceptions <lots more> ../../corelib/kernel/qcoreapplication.cpp
rather than just:
0compiling ../../corelib/kernel/qcoreapplication.cpp
Note that when you look at the DEBUG output for these changes when building Qt, you’ll see objects being compiled with a mix of C++11 and C++17. The breakdown is roughly:
qmake
built with-std=c++11
:
0Creating qmake...
1make[1]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qtbase/qmake'
2g++ -c -o project.o -std=c++11 -ffunction-sections -O2 -g <trim> <trim>/qt/5.9.8-4110fa99945/qtbase/qmake/project.cpp
3
4# when qmake, Qt also builds some of it's corelib, such as corelib/global/qmalloc.cpp
5g++ -c -o qmalloc.o -std=c++11 -ffunction-sections -O2 -g <trim> <trim>/qt/5.9.8-4110fa99945/qtbase/src/corelib/global/qmalloc.cpp
qmake
is run, and passed our build options, including-c++std
:
0make[1]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qtbase'
1<trim>qt/5.9.8-4110fa99945/qtbase/bin/qmake -o Makefile qtbase.pro -- -bindir <trim>/native/bin -c++std c++1z -confirm-license <trim>
- After some cleaning and configuring, we actually start to build Qt, as well as it’s tools and internal libs:
0Building qt...
1make[1]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qtbase/src'
2
3# build libpng, zlib etc
4gcc -c -m64 -pipe -pipe -O1 <trim> -o .obj/png.o png.c
5
6# build libQt5Bootstrap, using C++11, which again compiles qmalloc.cpp
7make[2]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qtbase/src/tools/bootstrap'
8g++ -c -pipe -ffunction-sections -O2 -fPIC -std=c++11 <trim> -o .obj/qmalloc.o ../../corelib/global/qmalloc.cpp
9
10# build a bunch of tools like moc, rcc, uic, qfloat16-tables, qdbuscpp2xml, using C++11
11g++ -c -pipe -O2 -std=c++11 -fno-exceptions -Wall -W <trim> -o .obj/rcc.o rcc.cpp
12
13# from here, Qt is compiled with -std=c++1z, including qmalloc.cpp, for the third and final time:
14g++ -c -include .pch/Qt5Core <trim> -g -Og -fPIC -std=c++1z -fvisibility=hidden <trim> -o .obj/qmalloc.o global/qmalloc.cpp
- Finally, build tools like
lrelease
,lupdate
, etc, but back to using -std=c++11
0make[1]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qttools/src/linguist/lrelease'
1g++ -c -pipe -O2 -std=c++11 -fno-exceptions -Wall -W <trim> -o .obj/translator.o ../shared/translator.cpp
If you dump the debug info from the built Qt libs, they should also tell you that they were compiled with C++17
:
0objdump -g bitcoin/depends/x86_64-pc-linux-gnu/lib/libQt5Core.a
1GNU C++17 9.3.0 -m64 -mtune=generic -march=x86-64 -g -O1 -Og -std=c++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection -fcf-protection