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
Update C++ standard to 14 and clean up #19490
Conversation
src/common/backport_std.h
Outdated
#ifndef CEPH_COMMON_BACKPORT14_H | ||
#define CEPH_COMMON_BACKPORT14_H | ||
|
||
// Library code from C++14 that can be implemented in C++11. |
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.
nit: this comment can be updated
src/common/backport14.h
Outdated
using remove_reference_t = typename std::remove_reference<T>::type; | ||
template<typename T> | ||
using result_of_t = typename std::result_of<T>::type; | ||
// Template variable aliases from C++17 <type_traits> |
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.
can we guard this with #if __cplusplus < 201703L
, and just put these templates into namespace std
?
4730bcc
to
73d692d
Compare
@tchaikov Maaaaybe? It's Undefined Behavior and Bad and Naughty and so I'd rather not, but it would probably work. I have a /better/ solution for this sort of problem I've been working on from time to time. Generally, if we put everything in core inside the ceph namespace And encapsulated things like this in a few inline namespaces so we could easily pull them into RGW and RBD and whatnot Then we could easily change definitions to usings and things like that, but it's a fairly large project and I haven't had a chance to work on it recently. |
that's my feeling as well. it might make our transitions between c++ versions a bit easier, but i don't think we do that often enough to get so adventurous |
Yeah, once we go to 17, whenever the CentOS people get their thing done, we won't have to change this sort of thing until …2020? |
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.
@adamemerson @cbodley makes sense to me!
Fix a couple problems. Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
73d692d
to
dd927b8
Compare
@tchaikov One minor error crept in during a rebase, just fixed it. |
Well, major in that it broke everything, but minor in terms of scope and fix and complexity. |
template<typename T> | ||
using remove_reference_t = typename std::remove_reference<T>::type; | ||
template<typename T> | ||
using result_of_t = typename std::result_of<T>::type; |
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.
In file included from /home/jenkins-build/build/workspace/ceph-pull-requests/src/common/dout.h:22:0,
from /home/jenkins-build/build/workspace/ceph-pull-requests/src/common/debug.h:18,
from /home/jenkins-build/build/workspace/ceph-pull-requests/src/compressor/Compressor.cc:22:
/home/jenkins-build/build/workspace/ceph-pull-requests/src/common/config.h:171:11: error: 'result_of_t' in namespace 'ceph' does not name a template type
ceph::result_of_t<Callback(const T&, Args...)> {
^~~~~~~~~~~
/home/jenkins-build/build/workspace/ceph-pull-requests/src/common/config.h:171:22: error: expected initializer before '<' token
ceph::result_of_t<Callback(const T&, Args...)> {
^
src/compressor/CMakeFiles/compressor_objs.dir/build.make:62: recipe for target 'src/compressor/CMakeFiles/compressor_objs.dir/Compressor.cc.o' failed
@@ -14,7 +14,7 @@ | |||
* | |||
*/ | |||
|
|||
#include "common/backport14.h" // include first: tests that header is standalone |
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.
@adamemerson we need to rename this source file. see https://github.com/ceph/ceph/pull/19490/files#diff-a67cc84c25b8865adfc63fed42d6ceffR268
C++14 provides the ability to define template variables, which the C++17 library puts to good use. We define those same aliases. Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
dd927b8
to
c29d42b
Compare
Oops. My own merged patch did me in. Fixed and pushed. Will run a local compile to check anything else. |
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Since we're on C++14, we're just backporting from future standards generally. Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
c29d42b
to
e08a1cd
Compare
@tchaikov All right, got the problems I introduced by rebasing cleared away. |
exciting! 🎉 you are my heroes, @tchaikov and @adamemerson! |
Very cool!! |
Awesome! |
@adamemerson @chardan Could you help me diagnose the build failure we are seeing in nautilus? Here are some instances of it: It blurts out a gazillion errors, but the first one is:
which would appear to be related to this PR? Also, at https://en.cppreference.com/w/cpp/types/result_of I saw that this feature added by C++14 is now deprecated and due to be removed in C++20... not sure what should be done (if anything) about that. |
@tchaikov Looks like "make check" is broken in nautilus? (See the previous comment - all of the "make check" failures in nautilus seem to be caused by this same issue, i.e. ostensibly "'result_of_t' is not a member of 'std'"...) |
@smithfarm thanks for looking into this. yeah, i am afraid "rëtest this please" won't work this time. will investigate this early tomorrow. |
@smithfarm Yeah, for C++17 result_of was deprecated, and removed in C++20 (see the "resolved issues" section here: https://tinyurl.com/km5tkhu). Chances are good that you can just replace it with "std::invoke_result" and "std::invoke_result_t". |
I also saw the earlier part of the conversation related to feature testing, and wanted to point out that there are lots of new feature-test macros made available: |
@smithfarm i failed to reproduce the FTBFS in my own xenial container and in #30083 . the only thing i can think of is to use GCC-8. see #30089. but i think the root cause is still unknown. as the error message put
and we do pass Line 115 in e1f6710
|
in the VERBOSE output, i see that an extra |
@cbodley thanks a lot! that explains. i ran into the same issue couple weeks ago before switching over to cmake 3.10. i believe that's the root cause. |
but we need to either use cmake 3.10 for addressing this issue or hack libfmt to prevent it from falling back to C++11. |
what do we need from cmake 3.10? is that what adds 17 as an option for CXX_STANDARD? |
yeah, 3.8 introduced the support of CXX_STANDARD=17. |
i am working on a fix for libfmt and dmclock. |
Still an improvement!