Skip to content

Commit 838731c

Browse files
committed
Update bazel_deps and bazel-toolchain
This switches to boost 1.91.0 and allows building on Ubuntu 26.04 A few local changes are necessary to build in those environments
1 parent dd04040 commit 838731c

9 files changed

Lines changed: 66 additions & 9 deletions

File tree

.bazelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ test --test_output=errors
1313

1414
build:host --platforms=@local_config_platform//:host
1515
build:host --linkopt=-lrt
16+
# bazel_deps select()s on this to pick compiler-specific copts (e.g.
17+
# libxcb's -Wno-* warnings). The host build uses the bundled
18+
# llvm_toolchain, so declare CLANG. Target builds use a different
19+
# toolchain and don't go through these select()s.
20+
build:host --define CLANG=true
21+
test:host --define CLANG=true
1622
build:host --copt=-Werror
1723
build:host --copt=-Wno-parentheses-equality
1824
# Catch the `return X(); if (...) ...` family at compile time. clang

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bazel_toolchain_dependencies()
2828
load("@com_github_mjbots_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
2929
llvm_toolchain(
3030
name = "llvm_toolchain",
31-
llvm_version = "10.0.0",
31+
llvm_version = "20.1.8",
3232
urls = {
3333
"windows" : ["https://github.com/mjbots/bazel-toolchain/releases/download/0.5.6-mj20201011/LLVM-10.0.0-win64.tar.xz"],
3434
},

mjlib/base/BUILD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ cc_library(
8383
name = "error_code",
8484
hdrs = ["error_code.h"],
8585
srcs = ["error_code.cc"],
86+
# Boost.System (>= 1.84) uses std::mutex internally to guard error
87+
# category init. Embedded toolchains (no OS) don't ship <mutex>; tell
88+
# Boost to use a no-op mutex instead. This is propagated to all
89+
# consumers via cc_library.defines so any downstream firmware build
90+
# picks it up automatically.
91+
defines = select({
92+
"@platforms//os:none": ["BOOST_SYSTEM_DISABLE_THREADS"],
93+
"//conditions:default": [],
94+
}),
8695
deps = [
8796
":stringify",
8897
"@boost//:system",

mjlib/base/error_code.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,38 @@ inline std::ostream& operator<<(std::ostream& ostr, const error_code& ec) {
9999

100100
}
101101
}
102+
103+
// Boost.Asio (>= 1.81) introduced a "disposition" concept used by awaitable
104+
// completion machinery to convert error-style completion arguments into
105+
// exceptions. Asio ships a specialisation for boost::system::error_code; for
106+
// mjlib::base::error_code (a wrapper that adds context messages) we need our
107+
// own. The trait inherently throws, so it's only available when exceptions
108+
// are enabled -- e.g. host builds, not embedded firmware.
109+
#ifdef __cpp_exceptions
110+
#include <boost/asio/disposition.hpp>
111+
112+
namespace boost {
113+
namespace asio {
114+
115+
template <>
116+
struct disposition_traits<mjlib::base::error_code> {
117+
static bool not_an_error(const mjlib::base::error_code& ec) noexcept {
118+
return !ec;
119+
}
120+
121+
static void throw_exception(const mjlib::base::error_code& ec) {
122+
throw boost::system::system_error(ec.boost_error_code(), ec.message());
123+
}
124+
125+
static std::exception_ptr to_exception_ptr(
126+
const mjlib::base::error_code& ec) noexcept {
127+
return ec
128+
? std::make_exception_ptr(
129+
boost::system::system_error(ec.boost_error_code(), ec.message()))
130+
: nullptr;
131+
}
132+
};
133+
134+
}
135+
}
136+
#endif // __cpp_exceptions

mjlib/base/json5_write_archive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class Json5WriteArchive : public VisitArchive<Json5WriteArchive> {
184184
} else if (!std::isfinite(value)) {
185185
stream_ << (options_.standard ? "null" : "NaN");
186186
} else {
187-
stream_ << fmt::format(format_string, value);
187+
stream_ << fmt::format(fmt::runtime(format_string), value);
188188
}
189189
}
190190

mjlib/io/realtime_executor.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <boost/asio/any_io_executor.hpp>
1818
#include <boost/asio/defer.hpp>
1919
#include <boost/asio/dispatch.hpp>
20-
#include <boost/asio/execution/execute.hpp>
2120
#include <boost/asio/execution_context.hpp>
2221
#include <boost/asio/post.hpp>
2322

@@ -79,8 +78,8 @@ class RealtimeExecutor {
7978
void execute(Callback&& callback) const {
8079
Service& s = const_cast<Service&>(service());
8180
s.StartWork();
82-
boost::asio::execution::execute(
83-
base_, Wrap<typename std::decay<Callback>::type>(&s, std::move(callback)));
81+
base_.execute(
82+
Wrap<typename std::decay<Callback>::type>(&s, std::move(callback)));
8483
}
8584

8685
template <typename Callback, typename Allocator>

tools/workspace/bazel_deps/repository.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ def bazel_deps_repository(name):
2020
github_archive(
2121
name = name,
2222
repo = "mjbots/bazel_deps",
23-
commit = "18eeb7e59ab3535ef93c45716313b9a037c972a1",
24-
sha256 = "7b5891127d884743d23779f42a2d80dfcea93fe97efb16372495497e19ff8468",
23+
commit = "3d32bc0ff10c15bd4b435be8851a3042b6c8911b",
24+
sha256 = "e8dadbedebe026834c1a7fd23e1ad5267011e6041813b45d1d63911d58e27438",
2525
)

tools/workspace/bazel_toolchain/repository.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ def bazel_toolchain_repository():
2020
github_archive(
2121
name = "com_github_mjbots_bazel_toolchain",
2222
repo = "mjbots/bazel-toolchain",
23-
commit = "47efd434976067fec4689a3e5cca9859b82b08ec",
24-
sha256 = "86428e992ad64e74bca6e388e4dc2846dee8fd8060b1b5cd8dfdc33631ef9103",
23+
commit = "9cc9535ef65a9361ba144be54d3f72c19346abf2",
24+
sha256 = "54ce65745967b8447c095385d23aca8e56c2ae889d51b61bd2239e450ccb43fd",
2525
)

tools/workspace/imgui/package.BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ cc_library(
4141
],
4242
}),
4343
includes = ["."],
44+
copts = select({
45+
"@com_github_mjbots_bazel_deps//conditions:clang" : [
46+
# imgui zero-initializes its own structs with memset/memcpy;
47+
# newer clang flags this on non-trivially-copyable types.
48+
"-Wno-nontrivial-memcall",
49+
],
50+
"//conditions:default" : [],
51+
}),
4452
deps = select({
4553
"@bazel_tools//src/conditions:windows" : [
4654
],

0 commit comments

Comments
 (0)