Skip to content
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

bazel: upgrade to c++23 #24444

Merged
merged 7 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ common:clang-19 --extra_toolchains=@llvm_19_toolchain//:all

build:system-clang --extra_toolchains=@local_config_cc_toolchains//:all
build:system-clang --action_env=BAZEL_COMPILER=clang
build:system-clang --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
build:system-clang --cxxopt=-std=c++23 --host_cxxopt=-std=c++23
build:system-clang --linkopt -fuse-ld=lld
# use a compiler name that doesn't symlink to ccache
build:system-clang-18 --config=system-clang
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.4.0
7.4.1
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ project(redpanda LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to do this in vtools, this is for the public build which isn't maintained.

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ single_version_override(
# NOTE: We build our toolchains on ubuntu:jammy so you're going to need a distro at least that old.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")

CXX_STANDARD = "c++20"
CXX_STANDARD = "c++23"

llvm.toolchain(
name = "llvm_19_toolchain",
Expand Down
2,457 changes: 774 additions & 1,683 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions src/v/cloud_topics/core/pipeline_stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class pipeline_stage_container {
pipeline_stage register_pipeline_stage() noexcept;

private:
// Pipeline stage counter used to assign ids to stages
int _next_stage_id_to_alloc{0};

std::vector<const pipeline_stage_id> _stages;
};

Expand Down
35 changes: 18 additions & 17 deletions src/v/cluster/tm_stm_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,41 @@ bool is_state_transition_valid(
* precursor of the requested one.
*/
switch (target_status) {
case empty:
case tx_status::empty:
// ready is an initial state a transaction can never go back to that
// state
return is_one_of(current.status, tx_status::empty);
case ongoing:
case tx_status::ongoing:
return is_one_of(current.status, tx_status::empty, tx_status::ongoing);
case preparing_commit:
case tx_status::preparing_commit:
return is_one_of(
current.status,
tx_status::empty,
tx_status::ongoing,
tx_status::preparing_commit);
case completed_commit:
case tx_status::completed_commit:
return is_one_of(
current.status,
tx_status::preparing_commit,
tx_status::completed_commit);
case preparing_abort:
case tx_status::preparing_abort:
return is_one_of(
current.status,
tx_status::empty,
tx_status::ongoing,
tx_status::preparing_abort);
case preparing_internal_abort:
case tx_status::preparing_internal_abort:
return is_one_of(
current.status,
tx_status::ongoing,
tx_status::preparing_internal_abort);
case tombstone:
case tx_status::tombstone:
return is_one_of(
current.status,
tx_status::tombstone,
tx_status::completed_commit,
tx_status::completed_abort);
case completed_abort:
case tx_status::completed_abort:
return is_one_of(
current.status,
tx_status::preparing_internal_abort,
Expand All @@ -84,7 +84,8 @@ bool is_state_transition_valid(
}

bool tx_metadata::is_finished() const {
return status == completed_commit || status == completed_abort;
return status == tx_status::completed_commit
|| status == tx_status::completed_abort;
}

std::string_view tx_metadata::get_status() const {
Expand Down Expand Up @@ -164,21 +165,21 @@ tx_metadata::try_update_status(tx_status requested) {

std::ostream& operator<<(std::ostream& o, tx_status status) {
switch (status) {
case ongoing:
case tx_status::ongoing:
return o << "ongoing";
case preparing_abort:
case tx_status::preparing_abort:
return o << "preparing_abort";
case preparing_commit:
case tx_status::preparing_commit:
return o << "preparing_commit";
case completed_commit:
case tx_status::completed_commit:
return o << "completed_commit";
case preparing_internal_abort:
case tx_status::preparing_internal_abort:
return o << "expired";
case empty:
case tx_status::empty:
return o << "empty";
case tombstone:
case tx_status::tombstone:
return o << "tombstone";
case completed_abort:
case tx_status::completed_abort:
return o << "completed_abort";
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/v/cluster/tm_stm_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace cluster {
* | |
* +---------------+
*/
enum tx_status : int32_t {
enum class tx_status : int32_t {
/**
* When transactional id to producer id mapping is added to coordinator it
* starts in this state
Expand Down
32 changes: 16 additions & 16 deletions src/v/cluster/tx_gateway_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,9 @@ ss::future<try_abort_reply> tx_gateway_frontend::do_try_abort(
}
vlog(txlog.info, "[tx_id={}] found transaction {} to abort", tx_id, tx);
switch (tx.status) {
case empty:
case tx_status::empty:
[[fallthrough]];
case ongoing: {
case tx_status::ongoing: {
vlog(txlog.trace, "[tx_id={}] aborting transaction: {}", tx_id, tx);
auto killed_tx = co_await stm->update_transaction_status(
term, tx.id, tx_status::preparing_internal_abort);
Expand All @@ -595,22 +595,22 @@ ss::future<try_abort_reply> tx_gateway_frontend::do_try_abort(
}
co_return try_abort_reply::make_aborted();
}
case preparing_commit:
case tx_status::preparing_commit:
[[fallthrough]];
case completed_commit:
case tx_status::completed_commit:
vlog(
txlog.trace,
"[tx_id={}] transaction: {} is already committed",
tx_id,
tx);
co_return try_abort_reply::make_committed();
case preparing_abort:
case tx_status::preparing_abort:
[[fallthrough]];
case preparing_internal_abort:
case tx_status::preparing_internal_abort:
[[fallthrough]];
case completed_abort:
case tx_status::completed_abort:
[[fallthrough]];
case tombstone:
case tx_status::tombstone:
vlog(
txlog.trace,
"[tx_id={}] transaction: {} is already aborted",
Expand Down Expand Up @@ -1005,7 +1005,7 @@ ss::future<cluster::init_tm_tx_reply> tx_gateway_frontend::do_init_tm_tx(
}

switch (tx.status) {
case ongoing: {
case tx_status::ongoing: {
vlog(txlog.info, "[tx_id={}] tx is ongoing, aborting", tx_id);
auto abort_result = co_await do_abort_tm_tx(term, stm, tx, timeout);
if (!abort_result) {
Expand All @@ -1019,10 +1019,10 @@ ss::future<cluster::init_tm_tx_reply> tx_gateway_frontend::do_init_tm_tx(
}
co_return init_tm_tx_reply{tx::errc::concurrent_transactions};
}
case empty:
case tombstone:
case completed_commit:
case completed_abort: {
case tx_status::empty:
case tx_status::tombstone:
case tx_status::completed_commit:
case tx_status::completed_abort: {
co_return co_await increase_producer_epoch(
tx.id,
tx.pid,
Expand All @@ -1033,9 +1033,9 @@ ss::future<cluster::init_tm_tx_reply> tx_gateway_frontend::do_init_tm_tx(
transaction_timeout_ms,
timeout);
}
case preparing_abort:
case preparing_internal_abort:
case preparing_commit:
case tx_status::preparing_abort:
case tx_status::preparing_internal_abort:
case tx_status::preparing_commit:
co_return init_tm_tx_reply{tx::errc::concurrent_transactions};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/v/cluster/tx_protocol_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ std::ostream& operator<<(std::ostream& o, const fetch_tx_reply& r) {
r.last_pid,
r.tx_seq,
r.timeout_ms.count(),
r.status,
static_cast<int32_t>(r.status),
r.partitions,
r.groups);
return o;
Expand Down
2 changes: 1 addition & 1 deletion src/v/cluster/tx_protocol_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ struct fetch_tx_reply
envelope<fetch_tx_reply, serde::version<0>, serde::compat_version<0>> {
using rpc_adl_exempt = std::true_type;

enum tx_status : int32_t {
enum class tx_status : int32_t {
ongoing,
preparing,
prepared,
Expand Down
4 changes: 2 additions & 2 deletions src/v/crypto/ossl_context_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ void finalize_worker_thread(OSSL_LIB_CTX* orig_ctx) {
}
} // namespace

ossl_context_service::~ossl_context_service() noexcept = default;

class ossl_context_service::impl final {
friend class ossl_context_test_class;

Expand Down Expand Up @@ -328,6 +326,8 @@ class ossl_context_service::impl final {
OSSL_LIB_CTX* _old_context{nullptr};
};

ossl_context_service::~ossl_context_service() noexcept = default;

ossl_context_service::ossl_context_service(
ssx::singleton_thread_worker& thread_worker,
ss::sstring config_file,
Expand Down
2 changes: 1 addition & 1 deletion src/v/serde/serde_is_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using serde_enum_serialized_t = int32_t;

template<typename T>
inline constexpr bool serde_is_enum_v =
#if __has_cpp_attribute(__cpp_lib_is_scoped_enum)
#if defined(__cpp_lib_is_scoped_enum) && __cpp_lib_is_scoped_enum >= 202011L
std::is_scoped_enum_v<T>
&& sizeof(std::decay_t<T>) <= sizeof(serde_enum_serialized_t);
#else
dotnwat marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
6 changes: 4 additions & 2 deletions src/v/utils/tests/tracking_allocator_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,18 @@ BOOST_AUTO_TEST_CASE(allocator_list_vector) {
allocator<int> alloc{tracker};
std::vector<int, allocator<int>> v{alloc};
v.push_back(1);
BOOST_REQUIRE_EQUAL(tracker->consumption(), sizeof(int));
BOOST_REQUIRE_GE(tracker->consumption(), sizeof(int));
v.push_back(2);
BOOST_REQUIRE_EQUAL(tracker->consumption(), 2 * sizeof(int));
BOOST_REQUIRE_GE(tracker->consumption(), 2 * sizeof(int));
BOOST_REQUIRE_EQUAL(v.size(), 2);
}
BOOST_REQUIRE_EQUAL(tracker->consumption(), 0);
{
allocator<int> alloc{tracker};
std::list<int, allocator<int>> v{alloc};
v.push_back(1);
BOOST_REQUIRE_GE(tracker->consumption(), 0);
BOOST_REQUIRE_EQUAL(v.size(), 1);
}
BOOST_REQUIRE_EQUAL(tracker->consumption(), 0);
}
Expand Down
8 changes: 8 additions & 0 deletions src/v/utils/tracking_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ class tracking_allocator : public allocator {
return allocator::allocate(n);
}

#if __cplusplus >= 202302L
[[nodiscard]] std::allocation_result<T*> allocate_at_least(std::size_t n) {
auto result = allocator::allocate_at_least(n);
_tracker->allocate(result.count * sizeof(T));
return result;
}
#endif
Comment on lines +124 to +130
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


void deallocate(T* p, std::size_t n) {
allocator::deallocate(p, n);
_tracker->deallocate(n * sizeof(T));
Expand Down
Loading