Skip to content

Commit

Permalink
add ci.yml (#3)
Browse files Browse the repository at this point in the history
* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml

* add ci.yml
  • Loading branch information
oathdruid committed Apr 28, 2024
1 parent 09c47ec commit fa429b8
Show file tree
Hide file tree
Showing 12 changed files with 324 additions and 94 deletions.
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

0 comments on commit fa429b8

Please sign in to comment.