Skip to content

Commit b37b430

Browse files
committed
Support ARM64 build
Makes it possible to run benchmarks on embedded hardware. Also-by: Jorge C. Santos <jorge.santos2@etas.com>
1 parent 2791366 commit b37b430

File tree

16 files changed

+1645
-156
lines changed

16 files changed

+1645
-156
lines changed

.bazelrc

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,56 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 ETAS GmbH
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
# Java Language Configuration
115
build --java_language_version=17
216
build --tool_java_language_version=17
317
build --java_runtime_version=remotejdk_17
418
build --tool_java_runtime_version=remotejdk_17
519

20+
# ============================================================================
21+
# Multi-Architecture Build Configuration
22+
# ============================================================================
23+
# These configs enable building for different target architectures.
24+
#
25+
# Usage:
26+
# bazel build //... --config=x86_64-linux # Build for x86_64 (native on x86_64 host)
27+
# bazel build //... --config=arm64-linux # Build for ARM64/aarch64 (cross-compile)
28+
#
29+
# Platform Definitions:
30+
# @score_bazel_platforms//:x86_64-linux - x86_64 architecture (GNU/Linux)
31+
# @score_bazel_platforms//:arm64-linux - ARM64/aarch64 architecture (GNU/Linux)
32+
build:x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux
33+
build:x86_64-linux --define=config=x86_64-linux
34+
build:x86_64-linux --repo_env=TARGET_ARCH=x86_64
35+
36+
build:arm64-linux --platforms=@score_bazel_platforms//:arm64-linux
37+
build:arm64-linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-aarch64-linux
38+
build:arm64-linux --incompatible_enable_cc_toolchain_resolution
39+
build:arm64-linux --define=config=arm64-linux
40+
build:arm64-linux --repo_env=TARGET_ARCH=aarch64
41+
642
test --test_output=errors
743

844
common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/
945
common --registry=https://bcr.bazel.build
1046

11-
# Feature flags
47+
# ============================================================================
48+
# Feature Flags & S-CORE Configuration
49+
# ============================================================================
1250
common --features=-treat_warnings_as_errors
1351
common --features=external_include_paths
52+
53+
# S-CORE Base Libraries and Communication Configuration
1454
common --@score-baselibs//score/mw/log/detail/flags:KUse_Stub_Implementation_Only=False
1555
common --@score-baselibs//score/mw/log/flags:KRemote_Logging=False
1656
common --@score-baselibs//score/json:base_library=nlohmann

MODULE.bazel

Lines changed: 153 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
# *******************************************************************************
1414

1515
"S-CORE SOME/IP Gateway"
16-
1716
module(name = "score_someip_gateway")
1817

18+
# ============================================================================
19+
# Python Configuration
20+
# ============================================================================
1921
bazel_dep(name = "rules_python", version = "1.4.1")
2022

23+
# Python 3.12: Required for testing infrastructure and code generation tools
2124
PYTHON_VERSION = "3.12"
2225

2326
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
@@ -43,119 +46,196 @@ pip.parse(
4346
)
4447
use_repo(pip, "someip_pip")
4548

46-
# Add GoogleTest dependency
49+
# ============================================================================
50+
# Testing & Performance Measurement
51+
# ============================================================================
4752
bazel_dep(name = "googletest", version = "1.17.0")
48-
49-
# Add Google Benchmark dependency for performance testing
5053
bazel_dep(name = "google_benchmark", version = "1.9.1")
5154

52-
# Rust rules for Bazel
55+
# ============================================================================
56+
# Build System Rules
57+
# ============================================================================
58+
bazel_dep(name = "rules_cc", version = "0.2.14")
5359
bazel_dep(name = "rules_rust", version = "0.63.0")
60+
bazel_dep(name = "rules_pkg", version = "1.1.0")
61+
62+
# Platforms: Standard constraint values and platform definitions
63+
# Required for select() expressions that use @platforms//cpu:* and @platforms//os:*
64+
bazel_dep(name = "platforms", version = "1.0.0")
65+
66+
# ============================================================================
67+
# Toolchains & Platform Configuration
68+
# ============================================================================
69+
# S-CORE Platform Definitions: Provides constraint values and platform definitions
70+
bazel_dep(name = "score_bazel_platforms", version = "0.0.2")
71+
72+
# LLVM Toolchain: C/C++ cross-compilation support for x86_64 and aarch64
73+
# Integrates with LLVM 19.1.0 and Debian Bullseye sysroots
74+
bazel_dep(name = "toolchains_llvm", version = "1.5.0")
75+
76+
# Rust Toolchain Extension: Manages sysroot download and toolchain registration
77+
bazel_dep(name = "score_toolchains_rust", version = "0.1")
78+
git_override(
79+
module_name = "score_toolchains_rust",
80+
remote = "https://github.com/eclipse-score/toolchains_rust.git",
81+
commit = "5614e4b273f2f5302d47a05d7e58dae86f97a3c3", # Last verified: 23.08.2025
82+
)
83+
84+
# ============================================================================
85+
# Optional Toolchain Dependencies
86+
# ============================================================================
87+
# We provide a local stub to satisfy module resolution without adding QNX support.
88+
bazel_dep(name = "rust_qnx8_toolchain", version = "1.0.0")
89+
local_path_override(
90+
module_name = "rust_qnx8_toolchain",
91+
path = "bazel_stubs/rust_qnx8_toolchain",
92+
)
5493

55-
# C/C++ rules for Bazel
56-
bazel_dep(name = "rules_cc", version = "0.2.1")
94+
# ============================================================================
95+
# Sysroot Management for Multi-Architecture Support
96+
# ============================================================================
97+
# Downloads and registers Debian Bullseye sysroots for both x86_64 and aarch64.
98+
# These sysroots are used by both LLVM (C++) and Rust toolchains for cross-compilation.
99+
rust_ext = use_extension("@score_toolchains_rust//extensions:rust_toolchain_ext.bzl", "rust_toolchain_ext")
100+
rust_ext.sysroot(
101+
name = "sysroot_linux_x64",
102+
url = "https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/4f611ec025be98214164d4bf9fbe8843f58533f7/debian_bullseye_amd64_sysroot.tar.xz",
103+
sha256 = "5df5be9357b425cdd70d92d4697d07e7d55d7a923f037c22dc80a78e85842d2c",
104+
strip_prefix = "",
105+
build_file = "@score_toolchains_rust//sysroot:BUILD.bazel",
106+
)
107+
rust_ext.sysroot(
108+
name = "sysroot_linux_aarch64",
109+
url = "https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/906cc7c6bf47d4bd969a3221fc0602c6b3153caa/debian_bullseye_arm64_sysroot.tar.xz",
110+
sha256 = "d303cf3faf7804c9dd24c9b6b167d0345d41d7fe4bfb7d34add3ab342f6a236c",
111+
strip_prefix = "",
112+
build_file = "@score_toolchains_rust//sysroot:BUILD.bazel",
113+
)
57114

58-
# LLVM Toolchains Rules - host configuration
59-
bazel_dep(name = "toolchains_llvm", version = "1.4.0")
115+
use_repo(rust_ext, "sysroot_linux_x64")
116+
use_repo(rust_ext, "sysroot_linux_aarch64")
60117

118+
# ============================================================================
119+
# LLVM C/C++ Toolchain Configuration
120+
# ============================================================================
121+
# Configures LLVM 19.1.0 for C/C++ compilation with cross-architecture support.
61122
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
62123
llvm.toolchain(
124+
name = "llvm_toolchain",
63125
cxx_standard = {"": "c++17"},
64126
llvm_version = "19.1.0",
65127
)
66-
use_repo(llvm, "llvm_toolchain")
67-
use_repo(llvm, "llvm_toolchain_llvm")
128+
llvm.sysroot(
129+
name = "llvm_toolchain",
130+
label = "@sysroot_linux_x64//:sysroot",
131+
targets = ["linux-x86_64"],
132+
)
133+
llvm.sysroot(
134+
name = "llvm_toolchain",
135+
label = "@sysroot_linux_aarch64//:sysroot",
136+
targets = ["linux-aarch64"],
137+
)
68138

139+
use_repo(llvm, "llvm_toolchain")
69140
register_toolchains("@llvm_toolchain//:all")
70141

71-
# tooling
142+
# ============================================================================
143+
# Rust Toolchain Configuration for Multi-Architecture Support
144+
# ============================================================================
145+
# Configures rules_rust to compile for both x86_64 and aarch64 targets.
146+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
147+
rust.toolchain(
148+
edition = "2021",
149+
extra_target_triples = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"],
150+
versions = ["1.83.0"],
151+
)
152+
use_repo(rust, "rust_toolchains")
153+
register_toolchains("@rust_toolchains//:all")
154+
155+
# ============================================================================
156+
# Tooling & Development
157+
# ============================================================================
72158
bazel_dep(name = "score_tooling", version = "1.0.2")
73159
bazel_dep(name = "aspect_rules_lint", version = "1.5.3")
74160
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
75161

76-
# docs-as-code
162+
# ============================================================================
163+
# Documentation
164+
# ============================================================================
77165
bazel_dep(name = "score_docs_as_code", version = "1.4.0")
78166

79-
# communication
80-
bazel_dep(name = "communication", version = "0.0.0")
81-
git_override(
82-
module_name = "communication",
83-
commit = "86c66f345fdd35dcc3f380905e799f559dfd5001",
84-
remote = "https://github.com/eclipse-score/communication.git",
85-
)
86-
87-
# TODO: These should fetched via registry and we shouldn't have to care about updating them
167+
# ============================================================================
168+
# Dependency Chain Compatibility
169+
# ============================================================================
170+
# TODO: Migrate rules_boost to Bazel Central Registry once compatible versions available.
171+
# Currently using archive_override to pin master branch for compatibility with other deps.
88172
archive_override(
89173
module_name = "rules_boost",
90174
integrity = "sha256-iKHWUIBrUN/fFOCltkTmHfDcKw0h4ZVmP7NVSoc8zBs=",
91175
strip_prefix = "rules_boost-master",
92176
urls = ["https://github.com/nelhage/rules_boost/archive/refs/heads/master.tar.gz"],
93177
)
94178

95-
bazel_dep(name = "score-baselibs", version = "0.0.0")
179+
# ============================================================================
180+
# Communication Framework
181+
# ============================================================================
182+
bazel_dep(name = "communication", version = "0.0.0")
96183
git_override(
184+
module_name = "communication",
185+
commit = "86c66f345fdd35dcc3f380905e799f559dfd5001",
186+
remote = "https://github.com/eclipse-score/communication.git",
187+
)
188+
189+
# ============================================================================
190+
# Base Libraries
191+
# ============================================================================
192+
# ============================================================================
193+
# Base Libraries
194+
# ============================================================================
195+
# Patch note: baselibs-multiarch.patch adds multi-arch support for .deb downloads.
196+
# score-baselibs hardcodes amd64 URLs; patch replaces them with architecture-aware
197+
# selection (x86_64 or aarch64) based on TARGET_ARCH environment variable.
198+
bazel_dep(name = "score-baselibs", version = "0.0.0")
199+
archive_override(
97200
module_name = "score-baselibs",
98-
commit = "f02d7f427df1968df8d5f9f9aa85bf68baeb839e",
99-
remote = "https://github.com/eclipse-score/baselibs.git",
201+
urls = ["https://github.com/eclipse-score/baselibs/archive/f02d7f427df1968df8d5f9f9aa85bf68baeb839e.tar.gz"],
202+
strip_prefix = "baselibs-f02d7f427df1968df8d5f9f9aa85bf68baeb839e",
203+
patches = ["//patches:baselibs-multiarch.patch"],
204+
patch_strip = 1,
100205
)
101206

207+
# ============================================================================
208+
# Code Generation - FlatBuffers
209+
# ============================================================================
210+
bazel_dep(name = "flatbuffers", version = "25.2.10")
211+
212+
# TRLC: Traceability Language Compiler for requirements management
102213
git_override(
103214
module_name = "trlc",
104215
commit = "650b51a47264a4f232b3341f473527710fc32669", # trlc-2.0.2 release
105216
remote = "https://github.com/bmw-software-engineering/trlc.git",
106217
)
107218

108-
bazel_dep(name = "flatbuffers", version = "25.2.10")
109-
110-
###################################################################################
111-
# Examples
112-
###################################################################################
113-
114-
#-------------------------------------------------------------
115-
# Crate index for hello world example
116-
#-------------------------------------------------------------
219+
# ============================================================================
220+
# Examples: Car Window Simulator
221+
# ============================================================================
117222
car_window_sim_crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
118-
car_window_sim_crate.spec(
119-
package = "rustyrepl",
120-
version = "0.2.0",
121-
) #//,features = ["async"])
122-
car_window_sim_crate.spec(
123-
package = "anyhow",
124-
version = "1",
125-
)
126-
car_window_sim_crate.spec(
127-
package = "async-trait",
128-
version = "0.1",
129-
)
130-
car_window_sim_crate.spec(
131-
features = ["derive"],
132-
package = "clap",
133-
version = "4",
134-
)
135-
car_window_sim_crate.spec(
136-
features = ["full"],
137-
package = "tokio",
138-
version = "1.10",
139-
)
223+
car_window_sim_crate.spec(package = "rustyrepl", version = "0.2.0")
224+
car_window_sim_crate.spec(package = "anyhow", version = "1")
225+
car_window_sim_crate.spec(package = "async-trait", version = "0.1")
226+
car_window_sim_crate.spec(features = ["derive"], package = "clap", version = "4")
227+
car_window_sim_crate.spec(features = ["full"], package = "tokio", version = "1.10")
140228
car_window_sim_crate.from_specs(name = "car_window_sim_crate")
141229
use_repo(car_window_sim_crate, "car_window_sim_crate")
142230

143-
###################################################################################
144-
# vsomeip integration
145-
###################################################################################
146-
bazel_dep(name = "rules_foreign_cc", version = "0.15.0")
231+
# ============================================================================
232+
# SOME/IP Stack Integration
233+
# ============================================================================
234+
# Rules for Foreign/C/C++/CMake integration
235+
bazel_dep(name = "rules_foreign_cc", version = "0.15.1")
147236

148237
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
149238

150-
_ALL_CONTENT = """
151-
filegroup(
152-
name = "all_srcs",
153-
srcs = glob(["**"]),
154-
visibility = ["//visibility:public"],
155-
)
156-
"""
157-
158-
# Boost
159239
http_archive(
160240
name = "boost",
161241
build_file_content = """
@@ -165,15 +245,14 @@ filegroup(
165245
visibility = ["//visibility:public"],
166246
)
167247
""",
168-
sha256 = "af57be25cb4c4f4b413ed692fe378affb4352ea50fbe294a11ef548f4d527d89",
169-
strip_prefix = "boost_1_87_0",
170-
urls = ["https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.bz2"],
248+
sha256 = "7da75f171837577a52bbf217e17f8ea576c7c246e4594d617bfde7fafd408be5",
249+
strip_prefix = "boost-1.87.0",
250+
urls = ["https://github.com/boostorg/boost/releases/download/boost-1.87.0/boost-1.87.0-cmake.tar.xz"],
171251
)
172252

173-
# pcre source code repository
174253
http_archive(
175254
name = "vsomeip",
176-
build_file_content = _ALL_CONTENT,
255+
build_file = "@//:vsomeip.BUILD.bazel",
177256
sha256 = "659421fa01c0f56e5587c82f476c18a593e1a7ad4b381d95b57821d0545dae53",
178257
strip_prefix = "vsomeip-3.5.7",
179258
urls = [

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
### Build & Dependencies
4343
- [ ] Optimize Bazel build configuration
44-
- [ ] Build vsomeip using native bazel or at least improve the Boost dependency
44+
- [x] Build vsomeip using native bazel or at least improve the Boost dependency
4545
- [ ] Right now the clang++ from the environment is somehow visible in the sandbox when building Boost which also makes it necessary that you have clang installed on your host. We should improve the sandboxing so that clang from the host system is no longer visible to any build.
4646
- [ ] Update dependency versions
4747
- [ ] Try out running on QNX
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Stub module for rust_qnx8_toolchain.
2+
3+
This is a minimal stub to satisfy the dependency declared by score_toolchains_rust.
4+
QNX support is not needed for S-CORE SOME/IP Gateway (Linux targets only).
5+
"""
6+
7+
module(
8+
name = "rust_qnx8_toolchain",
9+
version = "1.0.0",
10+
)
11+
12+
# No dependencies or content - this is a pure stub to satisfy module resolution.

0 commit comments

Comments
 (0)