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

add ci.yml #3

Merged
merged 72 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
5ff3c57
add ci.yml
oathdruid Apr 26, 2024
d92c573
add ci.yml
oathdruid Apr 26, 2024
15d676c
add ci.yml
oathdruid Apr 26, 2024
1afd4cf
add ci.yml
oathdruid Apr 26, 2024
17b9e79
add ci.yml
oathdruid Apr 26, 2024
1f93d67
add ci.yml
oathdruid Apr 26, 2024
dc48c81
add ci.yml
oathdruid Apr 26, 2024
28c0a62
add ci.yml
oathdruid Apr 26, 2024
c6c6172
add ci.yml
oathdruid Apr 26, 2024
38beedf
add ci.yml
oathdruid Apr 26, 2024
137fbba
add ci.yml
oathdruid Apr 26, 2024
0bea49b
add ci.yml
oathdruid Apr 26, 2024
628e9b6
add ci.yml
oathdruid Apr 26, 2024
73fcac8
add ci.yml
oathdruid Apr 26, 2024
bc0842b
add ci.yml
oathdruid Apr 26, 2024
d681124
add ci.yml
oathdruid Apr 26, 2024
22ed97b
add ci.yml
oathdruid Apr 26, 2024
a98d5c5
add ci.yml
oathdruid Apr 26, 2024
d3b92be
add ci.yml
oathdruid Apr 26, 2024
94db8ca
add ci.yml
oathdruid Apr 26, 2024
113f146
add ci.yml
oathdruid Apr 26, 2024
ef26e21
add ci.yml
oathdruid Apr 26, 2024
285a3dd
add ci.yml
oathdruid Apr 27, 2024
d9559ed
add ci.yml
oathdruid Apr 27, 2024
3972db1
add ci.yml
oathdruid Apr 27, 2024
5132944
add ci.yml
oathdruid Apr 27, 2024
d2f75d4
add ci.yml
oathdruid Apr 27, 2024
d04dda0
add ci.yml
oathdruid Apr 27, 2024
e3b7b7c
add ci.yml
oathdruid Apr 27, 2024
1b27779
add ci.yml
oathdruid Apr 27, 2024
b881a2d
add ci.yml
oathdruid Apr 27, 2024
a22af13
add ci.yml
oathdruid Apr 28, 2024
49309a1
add ci.yml
oathdruid Apr 28, 2024
8c9d97e
add ci.yml
oathdruid Apr 28, 2024
cbe7df9
add ci.yml
oathdruid Apr 28, 2024
fb6bccd
add ci.yml
oathdruid Apr 28, 2024
b1e1824
add ci.yml
oathdruid Apr 28, 2024
545dd07
add ci.yml
oathdruid Apr 28, 2024
f08edf8
add ci.yml
oathdruid Apr 28, 2024
7160b41
add ci.yml
oathdruid Apr 28, 2024
a0a413c
add ci.yml
oathdruid Apr 28, 2024
814710d
add ci.yml
oathdruid Apr 28, 2024
8184160
add ci.yml
oathdruid Apr 28, 2024
d4dd21d
add ci.yml
oathdruid Apr 28, 2024
11b9965
add ci.yml
oathdruid Apr 28, 2024
0863ee2
add ci.yml
oathdruid Apr 28, 2024
f6e485c
add ci.yml
oathdruid Apr 28, 2024
0a3e45a
add ci.yml
oathdruid Apr 28, 2024
f639d9e
add ci.yml
oathdruid Apr 28, 2024
f570157
add ci.yml
oathdruid Apr 28, 2024
54ac44b
add ci.yml
oathdruid Apr 28, 2024
707f29f
add ci.yml
oathdruid Apr 28, 2024
f944afa
add ci.yml
oathdruid Apr 28, 2024
fc34801
add ci.yml
oathdruid Apr 28, 2024
5bc5a59
add ci.yml
oathdruid Apr 28, 2024
26b93f4
add ci.yml
oathdruid Apr 28, 2024
2c8c253
add ci.yml
oathdruid Apr 28, 2024
f22f9ba
add ci.yml
oathdruid Apr 28, 2024
cf9f99b
add ci.yml
oathdruid Apr 28, 2024
ad53300
add ci.yml
oathdruid Apr 28, 2024
6519251
add ci.yml
oathdruid Apr 28, 2024
6916c31
add ci.yml
oathdruid Apr 28, 2024
0c705c8
add ci.yml
oathdruid Apr 28, 2024
1d4cf8f
add ci.yml
oathdruid Apr 28, 2024
e00dbff
add ci.yml
oathdruid Apr 28, 2024
bc6c18e
add ci.yml
oathdruid Apr 28, 2024
80e33b2
add ci.yml
oathdruid Apr 28, 2024
8cd7a89
add ci.yml
oathdruid Apr 28, 2024
8e9bf03
add ci.yml
oathdruid Apr 28, 2024
fa0a902
add ci.yml
oathdruid Apr 28, 2024
569bcdb
add ci.yml
oathdruid Apr 28, 2024
6a4a0ec
add ci.yml
oathdruid Apr 28, 2024
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
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ build:mutable-donated-string --config=arenastring --copt=-DGOOGLE_PROTOBUF_MUTAB

test --//:werror --features external_include_paths
test:asan --copt=-fsanitize=address --host_copt=-fsanitize=address --linkopt=-fsanitize=address --host_linkopt=-fsanitize=address
# SwissMemoryResource的Arena patch机制违背了odr,但是要保证尺寸一致,修改detect_odr_violation检测等级
test:asan --test_env ASAN_OPTIONS=detect_odr_violation=1
test:tsan --copt=-fsanitize=thread --host_copt=-fsanitize=thread --linkopt=-fsanitize=thread --host_linkopt=-fsanitize=thread

build:ci --disk_cache=bazel-disk
build:ci --repository_cache=bazel-repo
184 changes: 184 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
gcc12-basic-asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: bazel-repo
key: bazel-repo-${{hashFiles('WORKSPACE')}}
restore-keys: |
bazel-repo-
- uses: actions/cache@v4
with:
path: bazel-disk
key: bazel-disk-gcc12-basic-asan-${{github.sha}}
restore-keys: |
bazel-disk-gcc12-basic-asan-
bazel-disk-
- run: bazel test --config ci --action_env=CC=gcc-12 --config asan ...

gcc12-basic-tsan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: bazel-repo
key: bazel-repo-${{hashFiles('WORKSPACE')}}
restore-keys: |
bazel-repo-
- uses: actions/cache@v4
with:
path: bazel-disk
key: bazel-disk-gcc12-basic-tsan-${{github.sha}}
restore-keys: |
bazel-disk-gcc12-basic-tsan-
bazel-disk-
- run: bazel test --config ci --action_env=CC=gcc-12 --config tsan ...

gcc12-arenastring-asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: bazel-repo
key: bazel-repo-${{hashFiles('WORKSPACE')}}
restore-keys: |
bazel-repo-
- uses: actions/cache@v4
with:
path: bazel-disk
key: bazel-disk-gcc12-arenastring-${{github.sha}}
restore-keys: |
bazel-disk-gcc12-arenastring-
bazel-disk-
- run: bazel test --config ci --action_env=CC=gcc-12 --config arenastring --config asan ...

gcc12-mutable-donated-string-asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: bazel-repo
key: bazel-repo-${{hashFiles('WORKSPACE')}}
restore-keys: |
bazel-repo-
- uses: actions/cache@v4
with:
path: bazel-disk
key: bazel-disk-gcc12-mutable-donated-string-${{github.sha}}
restore-keys: |
bazel-disk-gcc12-mutable-donated-string-
bazel-disk-
- run: bazel test --config ci --action_env=CC=gcc-12 --config mutable-donated-string --config asan ...

clang14-basic-asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: bazel-repo
key: bazel-repo-${{hashFiles('WORKSPACE')}}
restore-keys: |
bazel-repo-
- uses: actions/cache@v4
with:
path: bazel-disk
key: bazel-disk-clang14-basic-asan-${{github.sha}}
restore-keys: |
bazel-disk-clang14-basic-asan-
bazel-disk-
- run: bazel test --config ci --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --config asan ...

clang14-basic-tsan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: bazel-repo
key: bazel-repo-${{hashFiles('WORKSPACE')}}
restore-keys: |
bazel-repo-
- uses: actions/cache@v4
with:
path: bazel-disk
key: bazel-disk-clang14-basic-tsan-${{github.sha}}
restore-keys: |
bazel-disk-clang14-basic-tsan-
bazel-disk-
- run: bazel test --config ci --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --config tsan ...

clang14-arenastring-asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: bazel-repo
key: bazel-repo-${{hashFiles('WORKSPACE')}}
restore-keys: |
bazel-repo-
- uses: actions/cache@v4
with:
path: bazel-disk
key: bazel-disk-clang14-arenastring-${{github.sha}}
restore-keys: |
bazel-disk-clang14-arenastring-
bazel-disk-
- run: bazel test --config ci --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --config arenastring --config asan ...

clang14-mutable-donated-string-asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: bazel-repo
key: bazel-repo-${{hashFiles('WORKSPACE')}}
restore-keys: |
bazel-repo-
- uses: actions/cache@v4
with:
path: bazel-disk
key: bazel-disk-clang14-mutable-donated-string-${{github.sha}}
restore-keys: |
bazel-disk-clang14-mutable-donated-string-
bazel-disk-
- run: bazel test --config ci --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --config mutable-donated-string --config asan ...

coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: bazel-repo
key: bazel-repo-${{hashFiles('WORKSPACE')}}
restore-keys: |
bazel-repo-
- uses: actions/cache@v4
with:
path: bazel-disk
key: bazel-disk-coverage-${{github.sha}}
restore-keys: |
bazel-disk-coverage-
bazel-disk-
- run: bazel coverage --config ci --combined_report=lcov --instrumentation_filter='src/babylon,-src/babylon/reusable/patch' test/...
- uses: coverallsapp/github-action@v2
with:
github-token: ${{github.token}}
file: bazel-out/_coverage/_coverage_report.dat
format: lcov
2 changes: 1 addition & 1 deletion copts.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BABYLON_GCC_COPTS = ['-Wall', '-Wextra']
BABYLON_CLANG_COPTS = ['-Weverything', '-faligned-new',
BABYLON_CLANG_COPTS = ['-faligned-new', '-Weverything', '-Wno-unknown-warning-option',
# 不保持老版本c++语法兼容
'-Wno-c++98-compat', '-Wno-c++98-compat-pedantic',
# Boost Preprocessor中大量使用
Expand Down
122 changes: 36 additions & 86 deletions patches/protobuf-25.3.patch
Original file line number Diff line number Diff line change
Expand Up @@ -439,89 +439,6 @@ index 2421d98c0..d1f6e72ce 100644
case 290: {
ObjcClassPrefix = input.ReadString();
break;
diff --git a/global_compile_flags.json b/global_compile_flags.json
new file mode 100644
index 000000000..1b08d22c7
--- /dev/null
+++ b/global_compile_flags.json
@@ -0,0 +1,77 @@
+{
+ "gcc940-x86_64-ubuntu20-gnu": {
+ "global_cppflags": [
+ "-g0 -UNDEBUG"
+ ],
+ "global_cflags": [
+ "-fsanitize=address"
+ ],
+ "global_cxxflags": [
+ "-fsanitize=address"
+ ],
+ "global_ldflags": [
+ "-fsanitize=address"
+ ]
+ },
+ "gcc940-aarch64-ubuntu20-gnu": {
+ "global_cppflags": [
+ "-g0 -UNDEBUG"
+ ]
+ },
+ "gcc10": {
+ "global_cppflags": [
+ "-g0 -UNDEBUG"
+ ],
+ "global_cflags": [
+ "-fsanitize=address"
+ ],
+ "global_cxxflags": [
+ "-fsanitize=address"
+ ],
+ "global_ldflags": [
+ "-fsanitize=address"
+ ]
+ },
+ "clang10": {
+ "global_cppflags": [
+ "-g0 -UNDEBUG"
+ ],
+ "global_cflags": [
+ "-fsanitize=address"
+ ],
+ "global_cxxflags": [
+ "-fsanitize=address -stdlib=libc++"
+ ],
+ "global_ldflags": [
+ "-fsanitize=address -stdlib=libc++"
+ ]
+ },
+ "gcc12": {
+ "global_cppflags": [
+ "-g0 -UNDEBUG"
+ ],
+ "global_cflags": [
+ "-fsanitize=address"
+ ],
+ "global_cxxflags": [
+ "-fsanitize=address"
+ ],
+ "global_ldflags": [
+ "-fsanitize=address"
+ ]
+ },
+ "clang14": {
+ "global_cppflags": [
+ "-g0 -UNDEBUG"
+ ],
+ "global_cflags": [
+ "-fsanitize=address"
+ ],
+ "global_cxxflags": [
+ "-fsanitize=address -stdlib=libc++"
+ ],
+ "global_ldflags": [
+ "-fsanitize=address -stdlib=libc++"
+ ]
+ }
+}
diff --git a/php/ext/google/protobuf/wkt.inc b/php/ext/google/protobuf/wkt.inc
index 4579c7e30..929602208 100644
--- a/php/ext/google/protobuf/wkt.inc
Expand Down Expand Up @@ -4856,7 +4773,7 @@ index dea2aecab..c7839ce3a 100644
inline std::string* ArenaStringPtr::UnsafeMutablePointer() {
diff --git a/src/google/protobuf/arenastring_impl.cc b/src/google/protobuf/arenastring_impl.cc
new file mode 100644
index 000000000..0227648c8
index 000000000..c128b2ba0
--- /dev/null
+++ b/src/google/protobuf/arenastring_impl.cc
@@ -0,0 +1,155 @@
Expand Down Expand Up @@ -5550,6 +5467,19 @@ index 000000000..7928c4bf0
+} // namespace google
+
+#include "google/protobuf/port_undef.inc"
diff --git a/src/google/protobuf/compiler/cpp/field.cc b/src/google/protobuf/compiler/cpp/field.cc
index e9ccf46bb..dfa6a5ae9 100644
--- a/src/google/protobuf/compiler/cpp/field.cc
+++ b/src/google/protobuf/compiler/cpp/field.cc
@@ -306,7 +306,7 @@ void InlinedStringVars(const FieldDescriptor* field, const Options& opts,
: "_impl_._inlined_string_donated_";

vars.emplace_back("inlined_string_donated",
- absl::StrFormat("(%s[%d] & %s) != 0;", array, index, mask));
+ absl::StrFormat("(%s[%d] & %s) != 0", array, index, mask));
vars.emplace_back("donating_states_word",
absl::StrFormat("%s[%d]", array, index));
vars.emplace_back("mask_for_undonate", absl::StrFormat("~%s", mask));
diff --git a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc
index 748a8d688..118e29ffe 100644
--- a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc
Expand Down Expand Up @@ -11045,10 +10975,10 @@ index e26fc80ed..e2ba2ae7b 100644
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
diff --git a/test/test_arena_string.cpp b/test/test_arena_string.cpp
new file mode 100644
index 000000000..9ad1e2b32
index 000000000..f620bd28c
--- /dev/null
+++ b/test/test_arena_string.cpp
@@ -0,0 +1,1444 @@
@@ -0,0 +1,1464 @@
+#include <google/protobuf/arena.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/arenastring_impl.h>
Expand Down Expand Up @@ -11259,6 +11189,26 @@ index 000000000..9ad1e2b32
+}
+#endif // __GLIBCXX__ && !_GLIBCXX_USE_CXX11_ABI
+
+TEST_F(ArenaStringTest, support_resize) {
+ auto accessor = MaybeArenaStringAccessor::create(arena, "10086");
+ accessor.resize(4);
+ auto data = &accessor[0];
+ ASSERT_EQ(4, accessor.size());
+ ASSERT_EQ("1008", accessor);
+ ASSERT_EQ(data, accessor.data());
+ accessor.resize(2);
+ data = &accessor[0];
+ ASSERT_EQ(2, accessor.size());
+ ASSERT_EQ("10", accessor);
+ ASSERT_EQ(data, accessor.data());
+ accessor.resize(4);
+ data = &accessor[0];
+ ASSERT_EQ(4, accessor.size());
+ ASSERT_EQ(::absl::string_view("10\0\0", 4), accessor);
+ ASSERT_EQ(data, accessor.data());
+ accessor.destroy();
+}
+
+TEST_F(ArenaStringTest, support_resize_uninitialized) {
+ auto accessor = MaybeArenaStringAccessor::create(arena, "10086");
+ ::absl::strings_internal::STLStringResizeUninitialized(&accessor, 4);
Expand Down
1 change: 0 additions & 1 deletion proto/arena_example.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package babylon;

//option cc_mutable_donated_string = true;
option cc_enable_arenas = true;

message ArenaExample {
Expand Down
Loading