-
Notifications
You must be signed in to change notification settings - Fork 37.8k
build: use C++17 in depends #20471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: use C++17 in depends #20471
Conversation
This means we'll get build output like this when building with DEBUG=1: g++ -c -pipe -ffunction-sections -O2 -fPIC -std=c++11 -fno-exceptions <lots more> ../../corelib/kernel/qcoreapplication.cpp rather than just: compiling ../../corelib/kernel/qcoreapplication.cpp
Is this needed for anything or does this change anything about the binaries? I presume it is needed for qt5.15? |
I think it's safer with regard to ABI to compile them with the same standard as the application, definitely for boost. We've seen some problems in that regard in the past. And especially building with an older C++XX than the application itself could cause some things to be missing that are conditional on the C++XX version.
Glad you got it to work eventually to build the library with C++17. It doesn't matter that the intermediate tools are built with C++11. It's a bit strange though that it seems to resist being built with C++17 at every step. Would this be solved by upgrading Qt? |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Concept ACK for the reasons given by @laanwj |
It doesn't look like it. #19716 (Qt 5.15.2) still behaves in the same way when built in |
Yep, we will be able to. 5.15.x understands |
Concept ACK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 2f5dfe4, I have reviewed the code and it looks OK, I agree it can be merged.
cr ACK 2f5dfe4: patch looks correct |
Code review ACK 2f5dfe4 |
Gitian builds
|
2f5dfe4 depends: build qt in c++17 mode (fanquake) 104e859 builds: don't pass -silent to qt when building in debug mode (fanquake) e2c5006 depends: build zeromq with -std=c++17 (fanquake) 2374f2f depends: build Boost with -std=c++17 (fanquake) 2dde557 depends: build bdb with -std=c++17 (fanquake) Pull request description: 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](bitcoin@104e859) that improves debug output when building Qt for debugging (`DEBUG=1`). Now we'll get output like this: ```bash g++ -c -pipe -ffunction-sections -O2 -fPIC -std=c++11 -fno-exceptions <lots more> ../../corelib/kernel/qcoreapplication.cpp ``` rather than just: ```bash compiling ../../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: 1. `qmake` built with `-std=c++11`: ```bash Creating qmake... make[1]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qtbase/qmake' g++ -c -o project.o -std=c++11 -ffunction-sections -O2 -g <trim> <trim>/qt/5.9.8-4110fa99945/qtbase/qmake/project.cpp # when qmake, Qt also builds some of it's corelib, such as corelib/global/qmalloc.cpp g++ -c -o qmalloc.o -std=c++11 -ffunction-sections -O2 -g <trim> <trim>/qt/5.9.8-4110fa99945/qtbase/src/corelib/global/qmalloc.cpp ``` 2. `qmake` is run, and passed our build options, including `-c++std`: ```bash make[1]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qtbase' <trim>qt/5.9.8-4110fa99945/qtbase/bin/qmake -o Makefile qtbase.pro -- -bindir <trim>/native/bin -c++std c++1z -confirm-license <trim> ``` 3. After some cleaning and configuring, we actually start to build Qt, as well as it's tools and internal libs: ```bash Building qt... make[1]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qtbase/src' # build libpng, zlib etc gcc -c -m64 -pipe -pipe -O1 <trim> -o .obj/png.o png.c # build libQt5Bootstrap, using C++11, which again compiles qmalloc.cpp make[2]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qtbase/src/tools/bootstrap' g++ -c -pipe -ffunction-sections -O2 -fPIC -std=c++11 <trim> -o .obj/qmalloc.o ../../corelib/global/qmalloc.cpp # build a bunch of tools like moc, rcc, uic, qfloat16-tables, qdbuscpp2xml, using C++11 g++ -c -pipe -O2 -std=c++11 -fno-exceptions -Wall -W <trim> -o .obj/rcc.o rcc.cpp # from here, Qt is compiled with -std=c++1z, including qmalloc.cpp, for the third and final time: g++ -c -include .pch/Qt5Core <trim> -g -Og -fPIC -std=c++1z -fvisibility=hidden <trim> -o .obj/qmalloc.o global/qmalloc.cpp ``` 4. Finally, build tools like `lrelease`, `lupdate`, etc, but back to using -std=c++11 ```bash make[1]: Entering directory '<trim>/qt/5.9.8-4110fa99945/qttools/src/linguist/lrelease' g++ -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`: ```bash objdump -g bitcoin/depends/x86_64-pc-linux-gnu/lib/libQt5Core.a GNU 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 ``` ACKs for top commit: laanwj: Code review ACK bitcoin@2f5dfe4 practicalswift: cr ACK 2f5dfe4: patch looks correct fjahr: Code review ACK 2f5dfe4 hebasto: ACK 2f5dfe4, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: fc5e9d7c7518c68349c8228fb1aead829850373efc960c9b8c079096a83d1dad19c62a9730fce5802322bf07e320960fd47851420d429eda0a87c307f4e8b03a
…rove explicit usage 1e62350 refactor: Improve use of explicit keyword (Fabian Jahr) c502a6d lint: Use c++17 std in cppcheck linter (Fabian Jahr) Pull request description: I found the `extended-lint-cppcheck` linter still uses `std=c++11` when reviewing #20471. The only difference in the output after this change is one line is missing: ``` src/script/descriptor.cpp:159:5: warning: Struct 'PubkeyProvider' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] ``` After some digging, I am still not sure why this one is ignored with c++17 when 40 other`noExplicitConstructor` warnings were still appearing. In the second commit, I fix these warnings, adding `explicit` where appropriate and adding fixes to ignore otherwise. ACKs for top commit: practicalswift: cr ACK 1e62350: patch looks correct! MarcoFalke: review ACK 1e62350 Tree-SHA512: dff7b324429a57160e217cf38d9ddbb6e70c6cb3d3e3e0bd4013d88e07afc2292c3df94d0acf7122e9d486322821682ecf15c8f2724a78667764c05d47f89a12
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:
rather than just:
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
:qmake
is run, and passed our build options, including-c++std
:lrelease
,lupdate
, etc, but back to using -std=c++11If you dump the debug info from the built Qt libs, they should also tell you that they were compiled with
C++17
: