concord-bft icon indicating copy to clipboard operation
concord-bft copied to clipboard

Workarounds for Building with Clang on Ubuntu 22

Open upshaw-alex opened this issue 1 year ago • 2 comments

This PR introduces workarounds for building Concord-BFT with Clang after the Ubuntu 22 upgrade.

These workarounds include:

  • Removal of the local variable totalVal from the function libutt::Factory::randomWallets, as this variable is unused and (with -Werror) Clang generates an error for that.
  • Changing usage of std::optional<::rocksdb::PinnableSlice> to std::unique_ptr<::rocksdb::PinnableSlice>, as Clang generates an error with this particular template instantiation. Some additional context on this one: (1) std::optional<::rocksdb::PinnableSlice> is used in Concord-BFT only as a return type for concord::storage::rocksdb::NativeClient::getSlice; (2) the particular error I saw is /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/optional:158:7: error: the parameter for this explicitly-defaulted copy assignment operator is const, but a member or base requires it to be non-const operator=(const _Optional_payload_base&) = default;. Of possible interest for this error is that I think ::rocksdb::PinnableSlice is not copy constructable, though this documentation suggests std::optional's copy constructor should be defined as deleted if the base type is not copy constructable, so I am still not entirely sure about the nature of this error; (3) I am aware this type change may be a pessimization with respect to memory management (moving objects from the stack to the heap); (4) I chose this over other possible workarounds I thought of as it required fewer code changes.
  • Problem Overview
    Building Concord-BFT with Clang (specifically Clang 14) seems to be broken as of the transition to Ubuntu 22; this is a problem for consumers of Concord-BFT that currently rely on Clang-specific instrumentation.
  • Testing Done
    I have confirmed a Concord-BFT-dependent project I have been involved in builds with the fixes I have here, using Clang on Ubuntu 22. I am hoping Concord-BFT's GitHub CI will show whether these changes are breaking to Concord-BFT's default build settings.

upshaw-alex avatar May 05 '23 22:05 upshaw-alex

I have force-pushed a rebase of my commit for this PR off of latest master in the interest of keeping it up-to-date.

upshaw-alex avatar May 08 '23 18:05 upshaw-alex

I have force-pushed a rebase of my commit for this PR off of latest master in the interest of keeping it up to date.

upshaw-alex avatar May 09 '23 17:05 upshaw-alex