This is an automated email from the ASF dual-hosted git repository. wwbmmm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push: new 71184b03 Support bthread tracer with bazel (#2905) 71184b03 is described below commit 71184b03f14f60f00dda6b22b67eacebc35c96b2 Author: Bright Chen <chenguangmin...@foxmail.com> AuthorDate: Tue Mar 4 21:49:40 2025 +0800 Support bthread tracer with bazel (#2905) --- .github/workflows/ci-linux.yml | 6 +++--- BUILD.bazel | 12 +++++++++--- MODULE.bazel | 3 ++- src/bthread/task_tracer.h | 4 ++-- test/bthread_fd_unittest.cpp | 2 +- test/endpoint_unittest.cpp | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index e4db5c0e..da5c1b53 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -46,13 +46,13 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - - run: bazel test --verbose_failures -- //... -//example/... + - run: bazel build --verbose_failures -- //... -//example/... gcc-compile-with-boringssl: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - - run: bazel test --verbose_failures --define with_mesalink=false --define with_glog=true --define with_thrift=true --define BRPC_WITH_BORINGSSL=true -- //... -//example/... + - run: bazel build --verbose_failures --define with_mesalink=false --define with_glog=true --define with_thrift=true --define BRPC_WITH_BORINGSSL=true -- //... -//example/... gcc-compile-with-make-all-options: runs-on: ubuntu-20.04 @@ -86,7 +86,7 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - - run: bazel test --verbose_failures --define with_mesalink=false --define with_glog=true --define with_thrift=true --define with_debug_bthread_sche_safety=true --define with_debug_lock=true -- //... -//example/... + - run: bazel build --verbose_failures --define with_mesalink=false --define with_glog=true --define with_thrift=true --define with_debug_bthread_sche_safety=true --define with_debug_lock=true -- //... -//example/... clang-compile-with-make: runs-on: ubuntu-20.04 diff --git a/BUILD.bazel b/BUILD.bazel index 3237e6c4..e383be4b 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -48,8 +48,11 @@ COPTS = [ "//bazel/config:brpc_with_debug_bthread_sche_safety": ["-DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=1"], "//conditions:default": ["-DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=0"], }) + select({ - "//bazel/config:brpc_with_debug_lock": ["-DBRPC_DEBUG_LOCK=1"], - "//conditions:default": ["-DBRPC_DEBUG_LOCK=0"], + "//bazel/config:brpc_with_debug_lock": ["-DBRPC_DEBUG_LOCK=1"], + "//conditions:default": ["-DBRPC_DEBUG_LOCK=0"], +}) + select({ + "@platforms//cpu:x86_64": ["-DBRPC_BTHREAD_TRACER"], + "//conditions:default": [], }) LINKOPTS = [ @@ -402,7 +405,10 @@ cc_library( deps = [ ":butil", ":bvar", - ], + ] + select({ + "@platforms//cpu:x86_64": ["@com_github_libunwind_libunwind//:libunwind"], + "//conditions:default": [], + }), ) cc_library( diff --git a/MODULE.bazel b/MODULE.bazel index e18e5c47..818b6e0d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -15,7 +15,8 @@ bazel_dep(name = 'platforms', version = '0.0.4') bazel_dep(name = "apple_support", version = "1.17.1") bazel_dep(name = 'rules_cc', version = '0.0.1') bazel_dep(name = 'rules_proto', version = '4.0.0') -bazel_dep(name = 'zlib', version = '1.2.13', repo_name = 'com_github_madler_zlib') +bazel_dep(name = 'zlib', version = '1.3.1.bcr.5', repo_name = 'com_github_madler_zlib') +bazel_dep(name = "libunwind", version = "1.8.1", repo_name = 'com_github_libunwind_libunwind') # --registry=https://baidu.github.io/babylon/registry bazel_dep(name = 'leveldb', version = '1.23', repo_name = 'com_github_google_leveldb') diff --git a/src/bthread/task_tracer.h b/src/bthread/task_tracer.h index 8c84f7b9..f154c3ee 100644 --- a/src/bthread/task_tracer.h +++ b/src/bthread/task_tracer.h @@ -80,8 +80,8 @@ private: bool OK() const { return err_count == 0; } - static const size_t MAX_TRACE_NUM = 64; - static const size_t MAX_ERROR_NUM = 2; + static constexpr size_t MAX_TRACE_NUM = 64; + static constexpr size_t MAX_ERROR_NUM = 2; unw_word_t ips[MAX_TRACE_NUM]; char mangled[MAX_TRACE_NUM][256]{}; diff --git a/test/bthread_fd_unittest.cpp b/test/bthread_fd_unittest.cpp index ec5df536..e799bb39 100644 --- a/test/bthread_fd_unittest.cpp +++ b/test/bthread_fd_unittest.cpp @@ -560,7 +560,7 @@ TEST(FDTest, double_close) { ASSERT_EQ(ec, errno); } -const char* g_hostname = "baidu.com"; +const char* g_hostname = "github.com"; TEST(FDTest, bthread_connect) { butil::EndPoint ep; ASSERT_EQ(0, butil::hostname2endpoint(g_hostname, 80, &ep)); diff --git a/test/endpoint_unittest.cpp b/test/endpoint_unittest.cpp index 69d17919..4c6efb35 100644 --- a/test/endpoint_unittest.cpp +++ b/test/endpoint_unittest.cpp @@ -483,7 +483,7 @@ TEST(EndPointTest, endpoint_concurrency) { } } -const char* g_hostname = "baidu.com"; +const char* g_hostname = "github.com"; TEST(EndPointTest, tcp_connect) { butil::EndPoint ep; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org