rippled icon indicating copy to clipboard operation
rippled copied to clipboard

Enable c++-20

Open seelabs opened this issue 3 years ago • 14 comments

High Level Overview of Change

This PR enables C++-20 support in rippled. It also ups the minimum supported compilers to gcc 11. We need to determine what the minimum supported clang and visual studio should be as well and update the docs and build scripts.

@legleux Can I ask you to patch the docs that build scripts that need to be updated so we can add them to this PR? Thanks!

seelabs avatar Jun 13 '22 14:06 seelabs

@scottschurr Fixed comments in: 06ea306092 [fold] Reword some comments

seelabs avatar Jun 14 '22 13:06 seelabs

With Boost 1.77, it's a different set of errors. https://gist.github.com/ximinez/ab7783cee57da1b9aa2b2507adcc3925 It looks like unique() just needs to be replaced with use_count() == 1, and I think result_of_t can be replaced with invoke_result_t.

ximinez avatar Jun 16 '22 14:06 ximinez

@ximinez I just pushed a patch that might fix the boost 1.77 errors, can you try this ( [fold] Fixes for visual studio: shared_ptr unique and type_traits

seelabs avatar Jun 16 '22 15:06 seelabs

The unique() error is fixed, but result_of_t is still broken. It looks like that was removed entirely from the C++-20 spec. https://en.cppreference.com/w/cpp/types/result_of

ximinez avatar Jun 16 '22 16:06 ximinez

@ximinez Can you try it now? I replaced the result_of with invoke_result. (This patch: 3ef203daea [fold] Replace result_of with invoke_result)

seelabs avatar Jun 17 '22 15:06 seelabs

Quick note that it builds now. Tests are running. Edit: Tests passed, too.

ximinez avatar Jun 19 '22 20:06 ximinez

Squashed and reworded. Not marking as passed until we get the docs updated.

seelabs avatar Jun 22 '22 14:06 seelabs

@ximinez, if I'm recalling correctly , the explicit this captures that you removed to make VS17 happy were added to prevent warnings from clang in C++20 mode. Should we consider abandoning VS17? Or do we need a more complicated solution?

scottschurr avatar Jun 22 '22 15:06 scottschurr

if I'm recalling correctly , the explicit this captures that you removed to make VS17 happy were added to prevent warnings from clang in C++20 mode. Should we consider abandoning VS17? Or do we need a more complicated solution?

I have no objection to abandoning VS17. We've fixed the issues with VS19 (and thus 21), and I've completely migrated my workflow. I don't know of any other devs that are using 17 either, but I could be wrong. The only significant downside is that our only VS documentation is for 17 (AFAIK), so that'll have to be updated.

ximinez avatar Jun 22 '22 15:06 ximinez

The only significant downside is that our only VS documentation is for 17 (AFAIK), so that'll have to be updated.

otoh that doc is correct for 2019/2022 so it is just a matter of changing the version.

greg7mdp avatar Jun 22 '22 16:06 greg7mdp

I re-tested the most recent (squashed) version of this pull request on Mac/clang. I used boost 1.77.0. Worked great, no issues. Specifically, I did not see the RocksDBFactory.cpp issue that @ximinez reported. I'm guessing the reason I did not see that error is that I'm using an older version of clang, but that's just a guess.

scottschurr avatar Jun 22 '22 16:06 scottschurr

To clarify, the clang failures I'm seeing are on your unmodified branch. I've tried both boost 1.75 and 1.77.

ximinez avatar Jun 22 '22 17:06 ximinez

Unfortunately it will be hard to compare versions of clang. Clang on Mac uses its own versioning scheme. Here's what I get:

Apple clang version 11.0.0 (clang-1100.0.33.17)

scottschurr avatar Jun 22 '22 17:06 scottschurr

Then just for completeness, I tried building on gcc (11.2.0) and clang (14.0.0). gcc worked without a hitch. clang complained about

/home/eah/dev/rippled/merge/src/ripple/nodestore/backend/RocksDBFactory.cpp:313:44: error: arithmetic between different enumeration types ('ripple::NodeStore::Status' and 'rocksdb::Status::Code') is deprecated [-Werror,-Wdeprecated-enum-enum-conversion]
                status = Status(customCode + getStatus.code());
                                ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~
1 error generated.

The fix for this was pretty simple, and seems cross-compatible. https://github.com/ximinez/rippled/commit/3554ab61e1f2bd26b81afc1824b5d321ed7497f0

ximinez avatar Jun 28 '22 13:06 ximinez

@ximinez Added a patch that should fix the enum issue. Also rebased onto the latest develop. Can you retest when you get a chance?

seelabs avatar Aug 16 '22 16:08 seelabs

Squashing and marking this as passed

seelabs avatar Aug 19 '22 12:08 seelabs

This was merged as 92d35e54c7de6bbe44ff6c7c52cc0765b3f78258

nbougalis avatar Aug 29 '22 23:08 nbougalis