Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
89d74ff
fix(bazel): strip upstream src/urma/BUILD.bazel so umdk headers glob …
cw20050111-prog Aug 14, 2026
4e76075
fix(urma): require explicit opt-in for the URMA link-time mock
cw20050111-prog Aug 17, 2026
1d7d634
Link liburma for all examples
cw20050111-prog Aug 18, 2026
2ab86d5
Drop duplicate liburma lookup in urma_performance
cw20050111-prog Aug 18, 2026
7e4fad6
Add comment about linking liburma in BrpcExample.cmake
cw20050111-prog Aug 18, 2026
27630a1
Revert liburma linking for diagnosis
cw20050111-prog Aug 18, 2026
a75a5ed
Check for URMA library and update build configuration
cw20050111-prog Aug 18, 2026
948072f
Add URMA library search to CMake configuration
cw20050111-prog Aug 18, 2026
89552b1
Update CMake to link with URMA library conditionally
cw20050111-prog Aug 18, 2026
96b3e6b
Remove URMA library check from CMakeLists.txt
cw20050111-prog Aug 18, 2026
b92c5bc
Refactor URMA library linking logic in CMake
cw20050111-prog Aug 18, 2026
1d4be29
fix(urma): address code review findings
cw20050111-prog Aug 21, 2026
4694785
Support local UMDK headers in Bazel
cw20050111-prog Aug 21, 2026
4883b3e
Fix typo in comment of BUILD.bazel file
cw20050111-prog Aug 22, 2026
ad103c0
Update .gitignore to include new files and directories
cw20050111-prog Aug 22, 2026
87fe59e
Refactor bond_include handling in repositories.bzl
cw20050111-prog Aug 22, 2026
e34f9d3
Fix indentation for bond_include check
cw20050111-prog Aug 22, 2026
4a01879
Delete bazel/third_party/umdk/umdk.BUILD
cw20050111-prog Aug 22, 2026
7c4fda2
Match CMake URMA_ROOT lookup semantics in Bazel
cw20050111-prog Aug 22, 2026
8fa1ccd
Install gperftools for the CMake-based URMA mock unittest job
cw20050111-prog Aug 22, 2026
d6ff554
Add 'urma_transport_dev' branch to CI workflow
cw20050111-prog Aug 22, 2026
9b540ac
Add urma_user_ctl to the URMA link-time mock
cw20050111-prog Aug 22, 2026
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
33 changes: 32 additions & 1 deletion .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Test on Linux

on:
push:
branches: [ master ]
branches: [ master, urma_transport_dev ]
paths-ignore:
- '**.md'
pull_request:
Expand Down Expand Up @@ -85,6 +85,37 @@ jobs:
-DWITH_ASAN=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ..
make -j ${{env.proc_num}} && make clean

cmake-unittest-urma-mock:
# No URMA hardware is available in CI, so this builds against brpc's
# URMA link-time mock (WITH_URMA_MOCK=ON) instead of a real liburma, and
# actually runs UrmaTransport's unit tests against it.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/install-all-dependencies
- name: install gperftools
# test/CMakeLists.txt links ${GPERFTOOLS_LIBRARIES} into every
# brpc_*_unittest target unconditionally, and FindGperftools.cmake
# leaves it as "...-NOTFOUND" when the library is absent, which then
# reaches the linker verbatim. The existing unittest jobs build via
# test/Makefile and get gperftools from init-ut-make-config; this is
# the first CMake-based unittest job, so install it explicitly.
run: sudo apt-get install -y libgoogle-perftools-dev
- name: configure
run: |
mkdir build && cd build
cmake -DBUILD_UNIT_TESTS=ON -DDOWNLOAD_GTEST=ON \
-DWITH_URMA=ON -DWITH_URMA_MOCK=ON \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 ..
- name: build
run: |
cd build
make -j ${{env.proc_num}} brpc_urma_unittest
- name: run tests
run: |
cd build
ctest -R brpc_urma_unittest --output-on-failure

gcc-compile-with-make-protobuf:
runs-on: ubuntu-22.04
steps:
Expand Down
13 changes: 13 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ DEFINES = [
}) + select({
"//bazel/config:brpc_with_urma": ["BRPC_WITH_URMA=1"],
"//conditions:default": [],
}) + select({
"//bazel/config:brpc_with_urma_mock": ["BRPC_WITH_URMA_MOCK=1"],
"//conditions:default": [],
}) + select({
"//bazel/config:brpc_with_debug_bthread_sche_safety": ["BRPC_DEBUG_BTHREAD_SCHE_SAFETY=1"],
"//conditions:default": ["BRPC_DEBUG_BTHREAD_SCHE_SAFETY=0"],
Expand Down Expand Up @@ -100,6 +103,16 @@ LINKOPTS = [
"-libverbs",
],
"//conditions:default": [],
}) + select({
# brpc_with_urma_mock is a specialization of brpc_with_urma (see
# bazel/config/BUILD.bazel), so it wins this select whenever both defines
# are set: mock builds compile against brpc's link-time mock instead and
# must not also link the real liburma, or urma_* symbols would clash.
"//bazel/config:brpc_with_urma_mock": [],
"//bazel/config:brpc_with_urma": [
"-lurma",
],
"//conditions:default": [],
}) + select({
"//bazel/config:brpc_with_asan": ["-fsanitize=address"],
"//conditions:default": [],
Expand Down
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ option(WITH_URMA "With URMA (openEuler Unified Remote Memory Access)" OFF)
option(DOWNLOAD_URMA_HEADERS
"Download UMDK headers when WITH_URMA is enabled and headers are absent"
ON)
option(WITH_URMA_MOCK
"Explicitly allow linking brpc's URMA link-time mock when liburma is not found (WITH_URMA only). The mock cannot talk to real URMA hardware, so this must be opted into rather than silently substituted."
OFF)
option(WITH_UBRING "With UB" OFF)
option(WITH_DEBUG_BTHREAD_SCHE_SAFETY "With debugging bthread sche safety" OFF)
option(WITH_DEBUG_LOCK "With debugging lock" OFF)
Expand Down Expand Up @@ -371,11 +374,19 @@ if(WITH_URMA)
if(URMA_LIB)
message(STATUS "Found URMA library: ${URMA_LIB}")
set(URMA_USE_MOCK 0)
else()
elseif(WITH_URMA_MOCK)
message(STATUS
"liburma not found; building with the URMA link-time mock")
"liburma not found; WITH_URMA_MOCK=ON, building with the URMA "
"link-time mock")
set(URMA_USE_MOCK 1)
else()
message(FATAL_ERROR
"Fail to find liburma. Install liburma, set URMA_ROOT, or "
"explicitly opt into brpc's link-time mock with "
"-DWITH_URMA_MOCK=ON (the mock cannot talk to real URMA "
"hardware; only enable it for CI/tests without URMA hardware).")
endif()
list(APPEND BRPC_COMMON_DEFINITIONS BRPC_WITH_URMA_MOCK=${URMA_USE_MOCK})
endif()

find_library(PROTOC_LIB NAMES protoc)
Expand Down
11 changes: 4 additions & 7 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@ git_override(
commit = '1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93', # Jun 28, 2024
)

git_repository = use_repo_rule(
'@bazel_tools//tools/build_defs/repo:git.bzl',
'git_repository',
umdk_repository = use_repo_rule(
'//bazel/third_party/umdk:repositories.bzl',
'umdk_repository',
)
git_repository(
umdk_repository(
name = 'umdk',
build_file = '//bazel/third_party/umdk:umdk.BUILD',
remote = 'https://atomgit.com/openeuler/umdk.git',
commit = '564ee727a55523d4351a8fb3c94292b388ebb924', # v26.06.0_CAM
)
6 changes: 2 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ workspace(name = "com_github_brpc_brpc")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("//bazel/third_party/umdk:repositories.bzl", "umdk_repository")

#
# Constants
Expand Down Expand Up @@ -279,11 +280,8 @@ http_archive(
urls = ["https://archive.apache.org/dist/thrift/0.15.0/thrift-0.15.0.tar.gz"],
)

git_repository(
umdk_repository(
name = "umdk",
build_file = "//bazel/third_party/umdk:umdk.BUILD",
remote = "https://atomgit.com/openeuler/umdk.git",
commit = "564ee727a55523d4351a8fb3c94292b388ebb924", # v26.06.0_CAM
)

# Header-only JSON library used by iobuf_unittest's IOBuf<->std::iostream
Expand Down
15 changes: 15 additions & 0 deletions bazel/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ config_setting(
visibility = ["//visibility:public"],
)

# A specialization of :brpc_with_urma (its define_values is a superset), so
# Bazel resolves select()s using both to this setting whenever it matches.
# Passing --define BRPC_WITH_URMA=true alone builds against a real liburma;
# adding --define BRPC_WITH_URMA_MOCK=true switches to brpc's URMA link-time
# mock instead. The mock cannot talk to real URMA hardware, so it must be
# opted into rather than silently substituted.
config_setting(
name = "brpc_with_urma_mock",
define_values = {
"BRPC_WITH_URMA": "true",
"BRPC_WITH_URMA_MOCK": "true",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "brpc_with_boringssl",
define_values = {"BRPC_WITH_BORINGSSL": "true"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(default_visibility = ["//visibility:public"])

cc_library(
name = "urma_headers",
hdrs = glob([
"src/urma/lib/urma/bond/include/*.h",
"src/urma/lib/urma/core/include/*.h",
]),
includes = [
"src/urma/lib/urma/bond/include",
"src/urma/lib/urma/core/include",
],
)
#
# This empty BUILD.bazel file is required to make Bazel treat
# this directory as a package.
141 changes: 141 additions & 0 deletions bazel/third_party/umdk/repositories.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

_UMDK_REMOTE = "https://atomgit.com/openeuler/umdk.git"
_UMDK_COMMIT = "564ee727a55523d4351a8fb3c94292b388ebb924" # v26.06.0_CAM

_BUILD_FILE = """
package(default_visibility = ["//visibility:public"])

cc_library(
name = "urma_headers",
hdrs = glob([
"src/urma/lib/urma/bond/include/*.h",
"src/urma/lib/urma/core/include/*.h",
]),
includes = [
"src/urma/lib/urma/bond/include",
"src/urma/lib/urma/core/include",
],
)
"""

def _is_false(value):
return value.lower() in ["0", "false", "no", "off"]

def _first_existing_file(ctx, root, relpaths):
for relpath in relpaths:
# get_child() joins one segment at a time; passing a relative path
# containing separators is not portable across Bazel versions.
path = ctx.path(root)
for segment in relpath.split("/"):
path = path.get_child(segment)
if path.exists:
return relpath
return None

def _write_build_file(ctx):
ctx.file("BUILD.bazel", _BUILD_FILE)

def _use_local_umdk(ctx, urma_root):
core_include = _first_existing_file(ctx, urma_root, [
"urma_api.h",
"ub/umdk/urma/urma_api.h",
"umdk/urma/urma_api.h",
"urma/urma_api.h",
# CMake's find_path() implicitly also searches an include/ prefix
# under HINTS, so URMA_ROOT=/usr resolves there. Probe the same
# layouts here to keep URMA_ROOT meaning the same in both builds.
"include/ub/umdk/urma/urma_api.h",
"include/umdk/urma/urma_api.h",
"include/urma/urma_api.h",
"include/urma_api.h",
"src/urma/lib/urma/core/include/urma_api.h",
])
if not core_include:
fail("URMA_ROOT is set to '%s', but no urma_api.h was found under it" %
urma_root)

core_include = core_include[:-len("/urma_api.h")] if "/" in core_include else "."
bond_include = _first_existing_file(ctx, urma_root, [
"urma_ubagg.h",
"ub/umdk/urma/urma_ubagg.h",
"umdk/urma/urma_ubagg.h",
"urma/urma_ubagg.h",
"include/ub/umdk/urma/urma_ubagg.h",
"include/umdk/urma/urma_ubagg.h",
"include/urma/urma_ubagg.h",
"include/urma_ubagg.h",
"src/urma/lib/urma/bond/include/urma_ubagg.h",
])
if not bond_include:
fail(("URMA_ROOT is set to '%s' and urma_api.h was found under it, " +
"but no urma_ubagg.h was. brpc needs both the core and the bond " +
"UMDK headers; a partial tree would only fail later with a " +
"missing-include error far from its cause.") % urma_root)
bond_include = bond_include[:-len("/urma_ubagg.h")] if "/" in bond_include else "."

ctx.symlink(
ctx.path(urma_root).get_child(core_include),
"src/urma/lib/urma/core/include",
)
ctx.symlink(
ctx.path(urma_root).get_child(bond_include),
"src/urma/lib/urma/bond/include",
)
_write_build_file(ctx)

def _run(ctx, args):
result = ctx.execute(args, quiet = False)
if result.return_code != 0:
fail("Failed to run '%s'\nstdout:\n%s\nstderr:\n%s" %
(" ".join(args), result.stdout, result.stderr))

def _download_umdk(ctx):
checkout = "umdk_checkout"
_run(ctx, ["git", "init", checkout])
_run(ctx, ["git", "-C", checkout, "remote", "add", "origin", _UMDK_REMOTE])
_run(ctx, ["git", "-C", checkout, "fetch", "--depth", "1", "origin", _UMDK_COMMIT])
_run(ctx, ["git", "-C", checkout, "checkout", "--detach", "FETCH_HEAD"])
ctx.symlink(
ctx.path(checkout).get_child("src/urma/lib/urma/core/include"),
"src/urma/lib/urma/core/include",
)
ctx.symlink(
ctx.path(checkout).get_child("src/urma/lib/urma/bond/include"),
"src/urma/lib/urma/bond/include",
)
_write_build_file(ctx)

def _umdk_repository_impl(ctx):
urma_root = ctx.os.environ.get("URMA_ROOT", "")
if urma_root:
_use_local_umdk(ctx, urma_root)
return

download = ctx.os.environ.get("BRPC_DOWNLOAD_URMA_HEADERS", "true")
if _is_false(download):
fail("Failed to find urma_api.h. Set URMA_ROOT to an installed UMDK " +
"tree or allow downloading with --repo_env=BRPC_DOWNLOAD_URMA_HEADERS=true.")

_download_umdk(ctx)

umdk_repository = repository_rule(
implementation = _umdk_repository_impl,
environ = [
"BRPC_DOWNLOAD_URMA_HEADERS",
"URMA_ROOT",
],
)
13 changes: 10 additions & 3 deletions config_brpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ else
LDD=ldd
fi

TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-urma,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,with-asan,with-riscv-zvbc,with-riscv-zbc,with-cpu-frequency,nodebugsymbols,werror -n 'config_brpc' -- "$@"`
TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-urma,with-urma-mock,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,with-asan,with-riscv-zvbc,with-riscv-zbc,with-cpu-frequency,nodebugsymbols,werror -n 'config_brpc' -- "$@"`
WITH_GLOG=0
WITH_THRIFT=0
WITH_RDMA=0
WITH_URMA=0
WITH_URMA_MOCK=0
WITH_MESALINK=0
WITH_BTHREAD_TRACER=0
WITH_ASAN=0
Expand Down Expand Up @@ -92,6 +93,7 @@ while true; do
--with-thrift) WITH_THRIFT=1; shift 1 ;;
--with-rdma) WITH_RDMA=1; shift 1 ;;
--with-urma) WITH_URMA=1; shift 1 ;;
--with-urma-mock) WITH_URMA_MOCK=1; shift 1 ;;
--with-mesalink) WITH_MESALINK=1; shift 1 ;;
--with-bthread-tracer) WITH_BTHREAD_TRACER=1; shift 1 ;;
--with-debug-bthread-sche-safety ) BRPC_DEBUG_BTHREAD_SCHE_SAFETY=1; shift 1 ;;
Expand Down Expand Up @@ -554,9 +556,14 @@ if [ $WITH_URMA != 0 ]; then
append_to_output_libs "$URMA_LIB"
append_to_output "DYNAMIC_LINKINGS+=-lurma"
append_to_output "URMA_USE_MOCK=0"
else
CPPFLAGS="${CPPFLAGS} -DBRPC_WITH_URMA_MOCK=0"
elif [ $WITH_URMA_MOCK != 0 ]; then
append_to_output "URMA_USE_MOCK=1"
print_info "liburma not found; using URMA link-time mock"
CPPFLAGS="${CPPFLAGS} -DBRPC_WITH_URMA_MOCK=1"
print_info "liburma not found; --with-urma-mock given, using URMA link-time mock"
else
>&2 $ECHO "Fail to find liburma. Install liburma, or explicitly opt into brpc's link-time mock with --with-urma-mock (the mock cannot talk to real URMA hardware; only use it for CI/tests without URMA hardware)."
exit 1
fi
fi

Expand Down
Loading
Loading