Skip to content

Commit def4181

Browse files
committed
update version (#107)
1 parent b6098b2 commit def4181

File tree

13 files changed

+1246
-146
lines changed

13 files changed

+1246
-146
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.6.1
1+
8.4.1

.github/workflows/ci.yml

Lines changed: 34 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ jobs:
1313
matrix:
1414
compiler: [{name: gcc, flag: --action_env=CC=gcc-14}, {name: clang, flag: --action_env=CC=clang-18}]
1515
mode: [{name: dbg, flag: --compilation_mode=dbg}, {name: opt, flag: --compilation_mode=opt}]
16-
std: [{name: c++20, flag: --cxxopt=-std=c++20}, {name: c++14, flag: --cxxopt=-std=c++14}]
16+
std: [{name: c++20, flag: --cxxopt=-std=c++20}, {name: c++17, flag: --cxxopt=-std=c++17}]
1717
stdlib: [{name: stdlibc++}, {name: libc++, flag: --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++}]
1818
feature: [{name: asan, flag: --features=asan}, {name: tsan, flag: --features=tsan}]
1919
exclude:
2020
- compiler: {name: gcc}
2121
stdlib: {name: libc++}
22-
- std: {name: c++14}
23-
feature: {name: tsan}
2422
runs-on: ubuntu-24.04
2523
name: basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}
2624
steps:
@@ -39,55 +37,38 @@ jobs:
3937
path: bazel-disk
4038
key: bazel-disk-basic-${{matrix.compiler.name}}-${{matrix.mode.name}}-${{matrix.std.name}}-${{matrix.stdlib.name}}-${{matrix.feature.name}}-${{github.sha}}
4139

42-
arenastring:
43-
strategy:
44-
fail-fast: false
45-
matrix:
46-
compiler: [{name: gcc, flag: --action_env=CC=gcc-14}, {name: clang, flag: --action_env=CC=clang-18}]
47-
stdlib: [{name: stdlibc++}, {name: libc++, flag: --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++}]
48-
mutable: [{name: default}, {name: half, flag: --config=arenastring}, {name: full, flag: --config=mutable-donated-string}]
49-
exclude:
50-
- compiler: {name: gcc}
51-
stdlib: {name: libc++}
52-
- compiler: {name: clang}
53-
mutable: {name: half}
54-
- compiler: {name: clang}
55-
mutable: {name: full}
56-
runs-on: ubuntu-24.04
57-
name: arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}
58-
steps:
59-
- uses: actions/checkout@v4
60-
- uses: actions/cache/restore@v4
61-
with:
62-
path: bazel-disk
63-
key: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-${{github.sha}}
64-
restore-keys: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-
65-
- if: ${{matrix.stdlib.name == 'libc++'}}
66-
run: sudo apt install libc++-18-dev libc++abi-18-dev
67-
- run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '28.3.arenastring'/" MODULE.bazel
68-
- run: bazel test --compilation_mode=opt --disk_cache=bazel-disk --verbose_failures --test_output=errors --features=asan --registry=https://bcr.bazel.build --registry=file://%workspace%/registry ${{matrix.compiler.flag}} ${{matrix.stdlib.flag}} ${{matrix.mutable.flag}} test/...
69-
- uses: actions/cache/save@v4
70-
if: always()
71-
with:
72-
path: bazel-disk
73-
key: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-${{github.sha}}
74-
75-
cpp14-coroutine:
76-
runs-on: ubuntu-24.04
77-
steps:
78-
- uses: actions/checkout@v4
79-
- uses: actions/cache/restore@v4
80-
with:
81-
path: bazel-disk
82-
key: bazel-disk-c++14-coroutine-${{github.sha}}
83-
restore-keys: bazel-disk-c++14-coroutine-
84-
- run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '27.5'/" MODULE.bazel
85-
- run: bazel test --disk_cache=bazel-disk --verbose_failures --test_output=errors --action_env=CC=gcc-12 --cxxopt=-std=c++14 --cxxopt=-fcoroutines --cxxopt=-fconcepts test/...
86-
- uses: actions/cache/save@v4
87-
if: always()
88-
with:
89-
path: bazel-disk
90-
key: bazel-disk-c++14-coroutine-${{github.sha}}
40+
#arenastring:
41+
# strategy:
42+
# fail-fast: false
43+
# matrix:
44+
# compiler: [{name: gcc, flag: --action_env=CC=gcc-14}, {name: clang, flag: --action_env=CC=clang-18}]
45+
# stdlib: [{name: stdlibc++}, {name: libc++, flag: --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++}]
46+
# mutable: [{name: default}, {name: half, flag: --config=arenastring}, {name: full, flag: --config=mutable-donated-string}]
47+
# exclude:
48+
# - compiler: {name: gcc}
49+
# stdlib: {name: libc++}
50+
# - compiler: {name: clang}
51+
# mutable: {name: half}
52+
# - compiler: {name: clang}
53+
# mutable: {name: full}
54+
# runs-on: ubuntu-24.04
55+
# name: arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}
56+
# steps:
57+
# - uses: actions/checkout@v4
58+
# - uses: actions/cache/restore@v4
59+
# with:
60+
# path: bazel-disk
61+
# key: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-${{github.sha}}
62+
# restore-keys: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-
63+
# - if: ${{matrix.stdlib.name == 'libc++'}}
64+
# run: sudo apt install libc++-18-dev libc++abi-18-dev
65+
# - run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '28.3.arenastring'/" MODULE.bazel
66+
# - run: bazel test --compilation_mode=opt --disk_cache=bazel-disk --verbose_failures --test_output=errors --features=asan --registry=https://bcr.bazel.build --registry=file://%workspace%/registry ${{matrix.compiler.flag}} ${{matrix.stdlib.flag}} ${{matrix.mutable.flag}} test/...
67+
# - uses: actions/cache/save@v4
68+
# if: always()
69+
# with:
70+
# path: bazel-disk
71+
# key: bazel-disk-arenastring-${{matrix.compiler.name}}-${{matrix.stdlib.name}}-${{matrix.mutable.name}}-${{github.sha}}
9172

9273
aarch64:
9374
runs-on: ubuntu-24.04
@@ -118,7 +99,7 @@ jobs:
11899
path: bazel-disk
119100
key: bazel-disk-workspace-${{github.sha}}
120101
restore-keys: bazel-disk-workspace-
121-
- run: bazel test --disk_cache=bazel-disk --verbose_failures --test_output=errors --enable_bzlmod=false test/...
102+
- run: USE_BAZEL_VERSION=7.6.1 bazel test --disk_cache=bazel-disk --verbose_failures --test_output=errors --enable_bzlmod=false test/...
122103
- uses: actions/cache/save@v4
123104
if: always()
124105
with:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.14)
22

3-
project(babylon VERSION 1.4.3)
3+
project(babylon VERSION 1.4.4)
44

55
include(CTest) # for BUILD_TESTING option
66
include(CMakePackageConfigHelpers) # for write_basic_package_version_file

MODULE.bazel

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module(
22
name = 'babylon',
3-
version = '1.4.3',
3+
version = '1.4.4',
44
compatibility_level = 1,
55
)
66

@@ -11,19 +11,23 @@ module(
1111
bazel_dep(name = 'abseil-cpp', version = '20220623.1', repo_name = 'com_google_absl')
1212
bazel_dep(name = 'bazel_skylib', version = '1.0.3')
1313
bazel_dep(name = 'boost.preprocessor', version = '1.83.0.bcr.1')
14-
bazel_dep(name = 'boost.spirit', version = '1.83.0')
14+
bazel_dep(name = 'boost.spirit', version = '1.83.0.bcr.2')
1515
bazel_dep(name = 'fmt', version = '8.1.1')
1616
bazel_dep(name = 'protobuf', version = '3.19.6', repo_name = 'com_google_protobuf')
1717
################################################################################
1818

1919
################################################################################
2020
# test only dependency
21-
single_version_override(module_name = 'abseil-cpp', version = '20240722.0')
22-
single_version_override(module_name = 'protobuf', version = '28.3')
23-
bazel_dep(name = 'googletest', version = '1.15.2', repo_name = 'com_google_googletest', dev_dependency = True)
24-
bazel_dep(name = 'platforms', version = '0.0.10', dev_dependency = True)
25-
bazel_dep(name = 'rules_cc', version = '0.0.13', dev_dependency = True)
26-
bazel_dep(name = 'rules_cuda', version = '0.2.3', dev_dependency = True)
21+
single_version_override(module_name = 'abseil-cpp', version = '20250814.0')
22+
single_version_override(module_name = 'bazel_skylib', version = '1.8.1')
23+
single_version_override(module_name = 'boost.preprocessor', version = '1.87.0')
24+
single_version_override(module_name = 'boost.spirit', version = '1.87.0')
25+
single_version_override(module_name = 'fmt', version = '11.2.0.bcr.1')
26+
single_version_override(module_name = 'protobuf', version = '32.1')
27+
bazel_dep(name = 'googletest', version = '1.17.0', repo_name = 'com_google_googletest', dev_dependency = True)
28+
bazel_dep(name = 'platforms', version = '1.0.0', dev_dependency = True)
29+
bazel_dep(name = 'rules_cc', version = '0.2.8', dev_dependency = True)
30+
bazel_dep(name = 'rules_cuda', version = '0.2.5', dev_dependency = True)
2731

2832
# cuda toolchain
2933
cuda = use_extension('@rules_cuda//cuda:extensions.bzl', 'toolchain', dev_dependency = True)

bazel/cross_toolchain.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load('@bazel_tools//tools/cpp:cc_configure.bzl', 'cc_autoconf_impl')
1+
load("@rules_cc//cc/private/toolchain:cc_configure.bzl", 'cc_autoconf_impl')
22

33
def cross_config_cc_impl(repository_ctx):
44
cc_autoconf_impl(repository_ctx,

src/babylon/absl_base_internal_invoke.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#include "babylon/environment.h"
44

55
// clang-format off
6-
#include BABYLON_EXTERNAL(absl/base/config.h)
7-
#include BABYLON_EXTERNAL(absl/base/internal/invoke.h)
6+
#include BABYLON_EXTERNAL(absl/meta/type_traits.h)
87
// clang-format on
98

109
// add some essential features for old LTS abseil-cpp
@@ -39,9 +38,6 @@
3938
#endif // !ABSL_LTS_RELEASE_VERSION
4039

4140
#if BABYLON_TMP_NEED_INVOKE_RESULT_R || BABYLON_TMP_NEED_INVOKE_RESULT_T
42-
// clang-format off
43-
#include BABYLON_EXTERNAL(absl/meta/type_traits.h)
44-
// clang-format on
4541

4642
// very old abseil-cpp dont have these macros
4743
#ifndef ABSL_NAMESPACE_BEGIN

src/babylon/reusable/allocator.hpp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,20 @@
55
#include <memory> // std::allocator_traits
66

77
#if GOOGLE_PROTOBUF_VERSION >= 3000000
8-
namespace google {
9-
namespace protobuf {
10-
namespace internal {
118
// protobuf为了避免用户错误地在非Arena内存上调用Arena版本的构造函数
129
// 将其设置了protected访问控制,并且从3.12开始将protoc生成的Message子类设置为final
1310
// 但是为了实现SwissAllocator的兼容分配,需要在已经分配好的内存上调用Arena版本的构造函数
14-
// 这里利用了Arena对GenericTypeHandler<T>的friend声明来绕过访问了控制
15-
// 通过Arena::CreateInArenaStorageInternal来达到目的,这也是protobuf::Map所使用的方法
11+
// 这里利用了Message子类对google::protobuf::Arena::InternalHelper<T>的friend声明来绕过访问了控制
1612
// 采用了NeverUsed这个内部定义类型来特化GenericTypeHandler,确保这个特化不会产生副作用
1713
template <>
18-
class GenericTypeHandler<::babylon::NeverUsed> {
14+
class google::protobuf::Arena::InternalHelper<::babylon::NeverUsed> {
1915
public:
2016
template <typename T, typename... Args>
2117
inline static void construct(T* ptr, ::google::protobuf::Arena* arena,
2218
Args&&... args) {
23-
#if GOOGLE_PROTOBUF_VERSION >= 3006000
24-
::google::protobuf::Arena::CreateInArenaStorageInternal(
25-
ptr, arena, std::true_type(), ::std::forward<Args>(args)...);
26-
#else // GOOGLE_PROTOBUF_VERSION < 3006000
27-
::google::protobuf::Arena::CreateInArenaStorageInternal(
28-
ptr, arena, true_type(), ::std::forward<Args>(args)...);
29-
#endif // GOOGLE_PROTOBUF_VERSION < 3006000
19+
new (ptr) T {arena, ::std::forward<Args>(args)...};
3020
}
3121
};
32-
} // namespace internal
33-
} // namespace protobuf
34-
} // namespace google
3522
#endif // GOOGLE_PROTOBUF_VERSION >= 3000000
3623

3724
BABYLON_NAMESPACE_BEGIN
@@ -664,16 +651,14 @@ template <typename T>
664651
template <typename U, typename>
665652
inline void SwissAllocator<T>::construct(U* ptr) {
666653
::google::protobuf::Arena& arena = *this->resource();
667-
::google::protobuf::internal::GenericTypeHandler<NeverUsed>::construct(
668-
ptr, &arena);
654+
::google::protobuf::Arena::InternalHelper<NeverUsed>::construct(ptr, &arena);
669655
}
670656

671657
template <typename T>
672658
template <typename U, typename V, typename>
673659
inline void SwissAllocator<T>::construct(U* ptr, V&& other) {
674660
::google::protobuf::Arena& arena = *this->resource();
675-
::google::protobuf::internal::GenericTypeHandler<NeverUsed>::construct(
676-
ptr, &arena);
661+
::google::protobuf::Arena::InternalHelper<NeverUsed>::construct(ptr, &arena);
677662
*ptr = ::std::forward<V>(other);
678663
}
679664
#endif // GOOGLE_PROTOBUF_VERSION >= 3000000

src/babylon/reusable/message.cpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -117,60 +117,6 @@ void MessageAllocationMetadata::initialize(
117117
_initialized = true;
118118
}
119119

120-
void MessageAllocationMetadata::FieldAllocationMetadata::update_repeated_field(
121-
const ::google::protobuf::Message& message,
122-
const ::google::protobuf::Reflection* reflection) noexcept {
123-
switch (descriptor->cpp_type()) {
124-
#define __BABYLON_TMP_CASE(case_enum, type) \
125-
case ::google::protobuf::FieldDescriptor::case_enum: { \
126-
auto capacity = static_cast<size_t>( \
127-
reflection->GetRepeatedField<type>(message, descriptor).Capacity()); \
128-
if (repeated_reserved < capacity) { \
129-
repeated_reserved = capacity; \
130-
} \
131-
break; \
132-
}
133-
__BABYLON_TMP_CASE(CPPTYPE_INT32, int32_t)
134-
__BABYLON_TMP_CASE(CPPTYPE_UINT32, uint32_t)
135-
__BABYLON_TMP_CASE(CPPTYPE_INT64, int64_t)
136-
__BABYLON_TMP_CASE(CPPTYPE_UINT64, uint64_t)
137-
__BABYLON_TMP_CASE(CPPTYPE_DOUBLE, double)
138-
__BABYLON_TMP_CASE(CPPTYPE_FLOAT, float)
139-
__BABYLON_TMP_CASE(CPPTYPE_BOOL, bool)
140-
case ::google::protobuf::FieldDescriptor::CPPTYPE_ENUM: {
141-
auto capacity = static_cast<size_t>(
142-
get_repeated_enum_field(message, reflection, descriptor).Capacity());
143-
if (repeated_reserved < capacity) {
144-
repeated_reserved = capacity;
145-
}
146-
break;
147-
}
148-
#undef __BABYLON_TMP_CASE
149-
#define __BABYLON_TMP_CASE(case_enum, type) \
150-
case ::google::protobuf::FieldDescriptor::case_enum: { \
151-
auto& repeated_field = \
152-
reflection->GetRepeatedPtrField<type>(message, descriptor); \
153-
auto capacity = static_cast<size_t>(repeated_field.size() + \
154-
repeated_field.ClearedCount()); \
155-
if (repeated_reserved < capacity) { \
156-
repeated_reserved = capacity; \
157-
} \
158-
auto begin = repeated_field.cbegin(); \
159-
auto end = repeated_field.cbegin() + static_cast<ssize_t>(capacity); \
160-
for (; begin != end; ++begin) { \
161-
update(*begin); \
162-
} \
163-
break; \
164-
}
165-
__BABYLON_TMP_CASE(CPPTYPE_STRING, ::std::string)
166-
__BABYLON_TMP_CASE(CPPTYPE_MESSAGE, ::google::protobuf::Message)
167-
#undef __BABYLON_TMP_CASE
168-
default:
169-
assert(false);
170-
break;
171-
}
172-
}
173-
174120
void MessageAllocationMetadata::FieldAllocationMetadata::reserve_repeated_field(
175121
::google::protobuf::Message& message,
176122
const ::google::protobuf::Reflection* reflection,

src/babylon/reusable/message.trick.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,67 @@ MessageAllocationMetadata::FieldAllocationMetadata::get_repeated_enum_field(
160160
::google::protobuf::FieldDescriptor::CPPTYPE_ENUM, -1, nullptr));
161161
}
162162

163+
#pragma GCC diagnostic push
164+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
165+
void MessageAllocationMetadata::FieldAllocationMetadata::update_repeated_field(
166+
const ::google::protobuf::Message& message,
167+
const ::google::protobuf::Reflection* reflection) noexcept {
168+
switch (descriptor->cpp_type()) {
169+
#define __BABYLON_TMP_CASE(case_enum, type) \
170+
case ::google::protobuf::FieldDescriptor::case_enum: { \
171+
auto capacity = static_cast<size_t>( \
172+
reflection->GetRepeatedField<type>(message, descriptor).Capacity()); \
173+
if (repeated_reserved < capacity) { \
174+
repeated_reserved = capacity; \
175+
} \
176+
break; \
177+
}
178+
__BABYLON_TMP_CASE(CPPTYPE_INT32, int32_t)
179+
__BABYLON_TMP_CASE(CPPTYPE_UINT32, uint32_t)
180+
__BABYLON_TMP_CASE(CPPTYPE_INT64, int64_t)
181+
__BABYLON_TMP_CASE(CPPTYPE_UINT64, uint64_t)
182+
__BABYLON_TMP_CASE(CPPTYPE_DOUBLE, double)
183+
__BABYLON_TMP_CASE(CPPTYPE_FLOAT, float)
184+
__BABYLON_TMP_CASE(CPPTYPE_BOOL, bool)
185+
case ::google::protobuf::FieldDescriptor::CPPTYPE_ENUM: {
186+
auto capacity = static_cast<size_t>(
187+
get_repeated_enum_field(message, reflection, descriptor).Capacity());
188+
if (repeated_reserved < capacity) {
189+
repeated_reserved = capacity;
190+
}
191+
break;
192+
}
193+
#undef __BABYLON_TMP_CASE
194+
#define __BABYLON_TMP_CASE(case_enum, type) \
195+
case ::google::protobuf::FieldDescriptor::case_enum: { \
196+
auto& repeated_field = \
197+
reflection->GetRepeatedPtrField<type>(message, descriptor); \
198+
auto capacity = static_cast<size_t>( \
199+
repeated_field.size() + \
200+
reinterpret_cast< \
201+
const ::google::protobuf::internal::RepeatedPtrFieldBase&>( \
202+
repeated_field) \
203+
.ClearedCount()); \
204+
if (repeated_reserved < capacity) { \
205+
repeated_reserved = capacity; \
206+
} \
207+
auto begin = repeated_field.cbegin(); \
208+
auto end = repeated_field.cbegin() + static_cast<ssize_t>(capacity); \
209+
for (; begin != end; ++begin) { \
210+
update(*begin); \
211+
} \
212+
break; \
213+
}
214+
__BABYLON_TMP_CASE(CPPTYPE_STRING, ::std::string)
215+
__BABYLON_TMP_CASE(CPPTYPE_MESSAGE, ::google::protobuf::Message)
216+
#undef __BABYLON_TMP_CASE
217+
default:
218+
assert(false);
219+
break;
220+
}
221+
}
222+
#pragma GCC diagnostic pop
223+
163224
BABYLON_NAMESPACE_END
164225

165226
#endif // GOOGLE_PROTOBUF_VERSION >= 3000000

0 commit comments

Comments
 (0)