Skip to content

Commit 49203a9

Browse files
committed
grpc: Add targets necessary to cross build grpc and the qps benchmark.
This introduces the following targets for both morello and riscv64: - abseil - c-ares - googlebenchmakr - googletest - grpc - protobuf - re2
1 parent f755db0 commit 49203a9

File tree

6 files changed

+396
-0
lines changed

6 files changed

+396
-0
lines changed

pycheribuild/projects/cross/abseil.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# SPDX-License-Identifier: BSD-2-Clause
3+
#
4+
# Copyright (c) 2025 Alfredo Mazzinghi
5+
#
6+
# This software was developed by SRI International, the University of
7+
# Cambridge Computer Laboratory (Department of Computer Science and
8+
# Technology), and Capabilities Limited under Defense Advanced Research
9+
# Projects Agency (DARPA) Contract No. FA8750-24-C-B047 ("DEC").
10+
#
11+
# Redistribution and use in source and binary forms, with or without
12+
# modification, are permitted provided that the following conditions
13+
# are met:
14+
# 1. Redistributions of source code must retain the above copyright
15+
# notice, this list of conditions and the following disclaimer.
16+
# 2. Redistributions in binary form must reproduce the above copyright
17+
# notice, this list of conditions and the following disclaimer in the
18+
# documentation and/or other materials provided with the distribution.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30+
# SUCH DAMAGE.
31+
#
32+
from .crosscompileproject import BuildType, CrossCompileCMakeProject, GitRepository
33+
from ...config.compilation_targets import CompilationTargets
34+
from ...config.target_info import DefaultInstallDir
35+
36+
37+
class BuildAbseil(CrossCompileCMakeProject):
38+
target = "abseil"
39+
repository = GitRepository("https://github.com/CTSRD-CHERI/abseil-cpp.git",
40+
default_branch="cheri-20220623.0")
41+
is_large_source_repository = True
42+
default_build_type = BuildType.DEBUG
43+
native_install_dir = DefaultInstallDir.CHERI_SDK
44+
supported_architectures = (
45+
*CompilationTargets.ALL_SUPPORTED_CHERIBSD_TARGETS,
46+
*CompilationTargets.ALL_NATIVE
47+
)
48+
49+
def setup(self):
50+
super().setup()
51+
self.add_cmake_options(
52+
CMAKE_CXX_STANDARD=17,
53+
BUILD_SHARED_LIBS="ON",
54+
)
55+
self.cross_warning_flags.append("-Wno-error=cheri-capability-misuse")

pycheribuild/projects/cross/c_ares.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# SPDX-License-Identifier: BSD-2-Clause
3+
#
4+
# Copyright (c) 2025 Alfredo Mazzinghi
5+
#
6+
# This software was developed by SRI International, the University of
7+
# Cambridge Computer Laboratory (Department of Computer Science and
8+
# Technology), and Capabilities Limited under Defense Advanced Research
9+
# Projects Agency (DARPA) Contract No. FA8750-24-C-B047 ("DEC").
10+
#
11+
# Redistribution and use in source and binary forms, with or without
12+
# modification, are permitted provided that the following conditions
13+
# are met:
14+
# 1. Redistributions of source code must retain the above copyright
15+
# notice, this list of conditions and the following disclaimer.
16+
# 2. Redistributions in binary form must reproduce the above copyright
17+
# notice, this list of conditions and the following disclaimer in the
18+
# documentation and/or other materials provided with the distribution.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30+
# SUCH DAMAGE.
31+
#
32+
from .crosscompileproject import BuildType, CrossCompileCMakeProject, GitRepository
33+
from ...config.compilation_targets import CompilationTargets
34+
from ...config.target_info import DefaultInstallDir
35+
36+
37+
class BuildCAres(CrossCompileCMakeProject):
38+
target = "c-ares"
39+
repository = GitRepository("https://github.com/c-ares/c-ares.git",
40+
default_branch="cares-1_19_1")
41+
is_large_source_repository = True
42+
default_build_type = BuildType.DEBUG
43+
native_install_dir = DefaultInstallDir.CHERI_SDK
44+
supported_architectures = (
45+
*CompilationTargets.ALL_SUPPORTED_CHERIBSD_TARGETS,
46+
*CompilationTargets.ALL_NATIVE
47+
)
48+
49+
def setup(self):
50+
super().setup()
51+
self.add_cmake_options(
52+
CARES_BUILD_TESTS="OFF"
53+
)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#
2+
# SPDX-License-Identifier: BSD-2-Clause
3+
#
4+
# Copyright (c) 2025 Alfredo Mazzinghi
5+
#
6+
# This software was developed by SRI International, the University of
7+
# Cambridge Computer Laboratory (Department of Computer Science and
8+
# Technology), and Capabilities Limited under Defense Advanced Research
9+
# Projects Agency (DARPA) Contract No. FA8750-24-C-B047 ("DEC").
10+
#
11+
# Redistribution and use in source and binary forms, with or without
12+
# modification, are permitted provided that the following conditions
13+
# are met:
14+
# 1. Redistributions of source code must retain the above copyright
15+
# notice, this list of conditions and the following disclaimer.
16+
# 2. Redistributions in binary form must reproduce the above copyright
17+
# notice, this list of conditions and the following disclaimer in the
18+
# documentation and/or other materials provided with the distribution.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30+
# SUCH DAMAGE.
31+
#
32+
from .crosscompileproject import BuildType, CrossCompileCMakeProject, GitRepository
33+
from ...config.compilation_targets import CompilationTargets
34+
from ...config.target_info import DefaultInstallDir
35+
36+
37+
class BuildGoogleBenchmark(CrossCompileCMakeProject):
38+
target = "googlebenchmark"
39+
repository = GitRepository("https://github.com/google/benchmark",
40+
default_branch="v1.8.2")
41+
dependencies = ("googletest",)
42+
default_build_type = BuildType.RELWITHDEBINFO
43+
native_install_dir = DefaultInstallDir.CHERI_SDK
44+
supported_architectures = (
45+
*CompilationTargets.ALL_SUPPORTED_CHERIBSD_TARGETS,
46+
*CompilationTargets.ALL_NATIVE
47+
)
48+
49+
def setup(self):
50+
super().setup()
51+
self.add_cmake_options(BENCHMARK_ENABLE_TESTING="OFF")
52+
53+
54+
class BuildGoogleTest(CrossCompileCMakeProject):
55+
target = "googletest"
56+
repository = GitRepository("https://github.com/google/googletest",
57+
default_branch="v1.13.0")
58+
default_build_type = BuildType.RELWITHDEBINFO
59+
native_install_dir = DefaultInstallDir.CHERI_SDK
60+
supported_architectures = (
61+
*CompilationTargets.ALL_SUPPORTED_CHERIBSD_TARGETS,
62+
*CompilationTargets.ALL_NATIVE
63+
)

pycheribuild/projects/cross/grpc.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#
2+
# SPDX-License-Identifier: BSD-2-Clause
3+
#
4+
# Copyright (c) 2025 Alfredo Mazzinghi
5+
#
6+
# This software was developed by SRI International, the University of
7+
# Cambridge Computer Laboratory (Department of Computer Science and
8+
# Technology), and Capabilities Limited under Defense Advanced Research
9+
# Projects Agency (DARPA) Contract No. FA8750-24-C-B047 ("DEC").
10+
#
11+
# Redistribution and use in source and binary forms, with or without
12+
# modification, are permitted provided that the following conditions
13+
# are met:
14+
# 1. Redistributions of source code must retain the above copyright
15+
# notice, this list of conditions and the following disclaimer.
16+
# 2. Redistributions in binary form must reproduce the above copyright
17+
# notice, this list of conditions and the following disclaimer in the
18+
# documentation and/or other materials provided with the distribution.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30+
# SUCH DAMAGE.
31+
#
32+
33+
from .crosscompileproject import BuildType, CrossCompileCMakeProject, GitRepository
34+
from ...config.compilation_targets import CompilationTargets
35+
from ...config.target_info import DefaultInstallDir
36+
37+
38+
class BuildGrpc(CrossCompileCMakeProject):
39+
target = "grpc"
40+
repository = GitRepository("https://github.com/CTSRD-CHERI/grpc.git",
41+
default_branch="grpc-1.54.2-cheri")
42+
dependencies = ("abseil", "c-ares", "protobuf", "re2", "googlebenchmark")
43+
is_large_source_repository = True
44+
default_build_type = BuildType.RELWITHDEBINFO
45+
native_install_dir = DefaultInstallDir.CHERI_SDK
46+
supported_architectures = (
47+
*CompilationTargets.ALL_SUPPORTED_CHERIBSD_TARGETS,
48+
*CompilationTargets.ALL_NATIVE
49+
)
50+
51+
@property
52+
def cmake_prefix_paths(self):
53+
# Force CMAKE_PREFIX_PATH to be empty
54+
# This should be fine, because we are still setting the
55+
# CMAKE_SYSROOT correctly and setting
56+
# CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
57+
# So the find_package() calls should pick up sysroot packages
58+
# while find_program() will find thigs in $PATH or CMAKE_PROGRAM_PATH.
59+
if self.compiling_for_host():
60+
return super().cmake_prefix_paths
61+
else:
62+
return []
63+
64+
def setup(self):
65+
super().setup()
66+
self.add_cmake_options(
67+
CMAKE_CXX_STANDARD=17,
68+
gRPC_ABSL_PROVIDER="package",
69+
gRPC_BENCHMARK_PROVIDER="package",
70+
gRPC_CARES_PROVIDER="package",
71+
gRPC_PROTOBUF_PROVIDER="package",
72+
gRPC_RE2_PROVIDER="package",
73+
gRPC_SSL_PROVIDER="package",
74+
gRPC_ZLIB_PROVIDER="package",
75+
gRPC_BACKWARDS_COMPATIBILITY_MODE="OFF",
76+
gRPC_BUILD_CODEGEN="ON",
77+
gRPC_BUILD_GRPC_CPP_PLUGIN="ON",
78+
BUILD_SHARED_LIBS="ON",
79+
CMAKE_PROGRAM_PATH=self.config.cheri_sdk_bindir,
80+
)
81+
82+
if not self.compiling_for_host():
83+
self.add_cmake_options(gRPC_BUILD_TESTS="ON")
84+
self.cross_warning_flags.append("-Wno-error=cheri-capability-misuse")
85+
self.cross_warning_flags.append("-Wno-error=format")
86+
87+
def install(self, **kwargs):
88+
super().install(**kwargs)
89+
90+
if self.target_info.is_native():
91+
return
92+
93+
scenario_dir = self.install_dir / "qps_scenarios"
94+
self.makedirs(scenario_dir)
95+
self.run_cmd("python", f"{self.source_dir}/tools/run_tests/performance/scenario_config_exporter.py",
96+
"--export_scenarios", "-l", "c++", "--category=all", cwd=scenario_dir)
97+
98+
# Install the QPS benchmark components
99+
self.install_file(self.build_dir / "qps_worker", self.install_dir / "grpc_qps_worker")
100+
self.install_file(self.build_dir / "qps_json_driver", self.install_dir / "grpc_qps_json_driver")
101+
102+
qps_utils_dir = self.install_dir / "qps_utils"
103+
self.makedirs(qps_utils_dir)
104+
self.makedirs(qps_utils_dir / "python_utils")
105+
self.install_file(self.source_dir / "tools" / "run_tests" / "start_port_server.py",
106+
qps_utils_dir / "start_port_server.py")
107+
self.install_file(self.source_dir / "tools" / "run_tests" / "python_utils" / "port_server.py",
108+
qps_utils_dir / "python_utils" / "port_server.py")
109+
self.install_file(self.source_dir / "tools" / "run_tests" / "python_utils" / "start_port_server.py",
110+
qps_utils_dir / "python_utils" / "start_port_server.py")
111+
self.install_file(self.source_dir / "tools" / "run_tests" / "python_utils" / "jobset.py",
112+
qps_utils_dir / "python_utils" / "jobset.py")
113+
114+
for sofile in self.build_dir.glob("libgrpc++_test_config.so*"):
115+
self.install_file(self.build_dir / sofile, self.install_dir / "lib" / sofile.name)
116+
for sofile in self.build_dir.glob("libgrpc++_test_util.so*"):
117+
self.install_file(self.build_dir / sofile, self.install_dir / "lib" / sofile.name)
118+
for sofile in self.build_dir.glob("libgrpc_test_util.so*"):
119+
self.install_file(self.build_dir / sofile, self.install_dir / "lib" / sofile.name)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# SPDX-License-Identifier: BSD-2-Clause
3+
#
4+
# Copyright (c) 2025 Alfredo Mazzinghi
5+
#
6+
# This software was developed by SRI International, the University of
7+
# Cambridge Computer Laboratory (Department of Computer Science and
8+
# Technology), and Capabilities Limited under Defense Advanced Research
9+
# Projects Agency (DARPA) Contract No. FA8750-24-C-B047 ("DEC").
10+
#
11+
# Redistribution and use in source and binary forms, with or without
12+
# modification, are permitted provided that the following conditions
13+
# are met:
14+
# 1. Redistributions of source code must retain the above copyright
15+
# notice, this list of conditions and the following disclaimer.
16+
# 2. Redistributions in binary form must reproduce the above copyright
17+
# notice, this list of conditions and the following disclaimer in the
18+
# documentation and/or other materials provided with the distribution.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30+
# SUCH DAMAGE.
31+
#
32+
from .crosscompileproject import BuildType, CrossCompileCMakeProject, GitRepository
33+
from ...config.compilation_targets import CompilationTargets
34+
from ...config.target_info import DefaultInstallDir
35+
36+
37+
class BuildProtobuf(CrossCompileCMakeProject):
38+
target = "protobuf"
39+
repository = GitRepository("https://github.com/CTSRD-CHERI/protobuf.git",
40+
default_branch="v3.21.12-cheri")
41+
is_large_source_repository = True
42+
default_build_type = BuildType.RELWITHDEBINFO
43+
native_install_dir = DefaultInstallDir.CHERI_SDK
44+
supported_architectures = (
45+
*CompilationTargets.ALL_SUPPORTED_CHERIBSD_TARGETS,
46+
*CompilationTargets.ALL_NATIVE
47+
)
48+
49+
def setup(self):
50+
super().setup()
51+
self.add_cmake_options(
52+
CMAKE_CXX_STANDARD=11,
53+
protobuf_BUILD_TESTS="OFF",
54+
BUILD_SHARED_LIBS="ON",
55+
)

0 commit comments

Comments
 (0)