Skip to content

Commit 9d09bb9

Browse files
committed
Fix muduo Linux support and C++23 compatibility
1 parent 49bfb7a commit 9d09bb9

7 files changed

Lines changed: 53 additions & 24 deletions

File tree

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# muduo compat and Boost dependencies
22

33
- muduo upstream: `chenshuo/muduo`, release `v2.0.3`, BSD-3-Clause.
4-
- muduo is packaged as Form B from the GitHub release archive; direct source compilation includes muduo base/network/poller units and excludes optional examples, protobuf/RPC, and contrib targets. The upstream empty `boilerplate.cc` is excluded because its referenced `BoilerPlate.h` is absent from the archive.
4+
- muduo is packaged as Form B **Linux-only** from the GitHub release archive: upstream poller uses `sys/epoll.h` and timer queue uses `sys/timerfd.h`. The only `xpm` section is `linux`; consumers gate it with `cfg(linux)`. Direct source compilation includes muduo base/network/poller units and excludes optional examples, protobuf/RPC, and contrib targets. The upstream empty `boilerplate.cc` is excluded because its referenced `BoilerPlate.h` is absent from the archive.
55
- muduo archive SHA-256: `5e90c2f07074ed5ab9347959edc8d387e40a57fbffb92e4a99cfb9a230851371` (two matching calculations).
66
- Dependency research from the actual compiler errors and upstream include tree found `boost/operators.hpp`, `boost/any.hpp`, and `boost/circular_buffer.hpp`. `boost/operators.hpp` is provided by Boost.Utility; that descriptor already existed. Added `compat.boost-any` and `compat.boost-circular-buffer`; the latter's transitive include closure also required adding `compat.boost-concept-check`.
77
- Added Boost component versions all follow the index's 1.92.0 train:
@@ -11,5 +11,6 @@
1111
- SHA-256 values above were computed twice per archive. CN mirrors are not configured; descriptors use plain upstream URL strings until matching GitCode assets are available.
1212
- muduo depends on `compat.boost-any`, `compat.boost-circular-buffer`, and existing `compat.boost-utility`.
1313
- Workspace tests: `boost-any` checks value storage/cast/clear; `boost-circular-buffer` checks bounded overwrite; `boost-concept-check` compiles concept assertions; `muduo` checks Buffer behavior.
14-
- Verification: `mcpp test -p boost-any`, `mcpp test -p boost-circular-buffer`, `mcpp test -p boost-concept-check`, and `mcpp test -p muduo` passed on the local Linux toolchain. The environment emitted its existing default-SubOS-description warning; it did not fail these runs.
15-
- Platform caveat: all source descriptors declare the three xpm platforms, but muduo behavior is intended for Linux/macOS; macOS/Windows CI still needs to establish actual support.
14+
- CI exposed three unsupported assumptions: macOS lacks Linux `epoll`/`timerfd`, Windows lacks POSIX `pthread.h`/`netinet/in.h`, and LLVM/libc++ at C++23 does not provide `shared_ptr::unique()` (removed in C++20). The first two are fixed by publishing muduo only on Linux and gating its member dependency; the last by an install hook replacing the single upstream `connection_.unique()` call with `connection_.use_count() == 1`, preserving its meaning. LLVM's Linux sysroot also requires an explicit `<time.h>` in `Timestamp.cc` for `struct tm`; the same hook inserts that include. Each edit checks an exact-one match and retains the upstream archive SHA.
15+
- Verification: `mcpp xpkg parse --all-os pkgs/c/compat.muduo.lua` reports Linux only; after a cold local install, `mcpp test -p muduo` passed under GCC 16.1.0 and `mcpp test -p muduo --toolchain llvm@22.1.8` passed under LLVM 22.1.8. The three Boost component members passed the original macOS and Windows CI checks. The local environment emitted a default-SubOS-description warning; it did not fail the runs.
16+
- With the CI-pinned mcpp 2026.10.1.2 and LLVM 22.1.8, a fresh muduo install plus `mcpp test -p muduo --toolchain llvm@22.1.8 --cache off` passed (`buffer ... ok; test result ok. 1 passed; 0 failed`). macOS and Windows gates need confirmation from the next CI run.

‎CHANGELOG.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
### Added
1111

12-
- **`compat.muduo` 2.0.3 与 Boost 头组件。** muduo 的依赖闭包由 `compat.boost-any`、
13-
`compat.boost-circular-buffer`、`compat.boost-concept-check` 和既有 `compat.boost-utility`
14-
满足;新增三个 Boost compat 描述符及各自 workspace 行为/编译测试。归档 URL 使用 GLOBAL 上游源,
15-
CN 镜像待补。Linux 上 `mcpp test -p muduo` 与三个 Boost 成员均通过。
12+
- **`compat.muduo` 2.0.3 与 Boost 头组件。** muduo 仅支持 Linux;内联构建
13+
`muduo_base`/`muduo_net` 源码,按上游 2.0.3 的依赖补充 `compat.boost-any`、
14+
`compat.boost-circular-buffer`、`compat.boost-concept-check` 并复用既有 `compat.boost-utility`。
15+
三个新增 Boost 包各有 workspace 成员;muduo 的成员按 Linux 门控。上游归档使用 GLOBAL 地址,
16+
CN 镜像待补。安装钩子仅修补 C++20 移除的 `shared_ptr::unique()` 与缺失的 `<time.h>`。
1617

1718
- **`compat.yaml-cpp` 0.8.0 与 0.9.0。** YAML 1.2 解析与生成,按上游 CMake 目标原样编译
1819
(`src/*.cpp` + `src/contrib/*.cpp`),GLOBAL + GitCode CN 镜像字节一致。上游把

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ One descriptor per common shape:
4040
| C++ sources, several versions | [`compat.yaml-cpp`](pkgs/c/compat.yaml-cpp.lua) |
4141
| Boost header-only components | [`compat.boost-any`](pkgs/c/compat.boost-any.lua) · [`compat.boost-circular-buffer`](pkgs/c/compat.boost-circular-buffer.lua) · [`compat.boost-concept-check`](pkgs/c/compat.boost-concept-check.lua) · [`compat.boost-utility`](pkgs/c/compat.boost-utility.lua) |
4242
| Header-only | [`compat.gtl`](pkgs/c/compat.gtl.lua) |
43-
| C++ network library | [`compat.muduo`](pkgs/c/compat.muduo.lua) |
43+
| Linux-only C++ network library | [`compat.muduo`](pkgs/c/compat.muduo.lua) |
4444
| Generated config header | [`compat.c-ares`](pkgs/c/compat.c-ares.lua) |
4545
| C++23 module wrapper | [`nlohmann.json`](pkgs/n/nlohmann.json.lua) |
4646
| C++23 module shipped by upstream | [`khronos.vulkan-hpp`](pkgs/k/khronos.vulkan-hpp.lua) |

‎README.zh-CN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mcpp self config --mirror CN # 切换至国内镜像,默认使用 GLOBAL 上
3838
| C 源码 + `features` | [`compat.cjson`](pkgs/c/compat.cjson.lua) |
3939
| C++ 源码,多版本 | [`compat.yaml-cpp`](pkgs/c/compat.yaml-cpp.lua) |
4040
| Boost 头文件组件 | [`compat.boost-any`](pkgs/c/compat.boost-any.lua) · [`compat.boost-circular-buffer`](pkgs/c/compat.boost-circular-buffer.lua) · [`compat.boost-concept-check`](pkgs/c/compat.boost-concept-check.lua) · [`compat.boost-utility`](pkgs/c/compat.boost-utility.lua) |
41-
| C++ 网络库 | [`compat.muduo`](pkgs/c/compat.muduo.lua) |
41+
| 仅 Linux 的 C++ 网络库 | [`compat.muduo`](pkgs/c/compat.muduo.lua) |
4242
| header-only | [`compat.gtl`](pkgs/c/compat.gtl.lua) |
4343
| 生成 config 头 | [`compat.c-ares`](pkgs/c/compat.c-ares.lua) |
4444
| C++23 module wrapper | [`nlohmann.json`](pkgs/n/nlohmann.json.lua) |

‎pkgs/c/compat.muduo.lua‎

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package = {
22
spec = "1",
33
namespace = "compat",
44
name = "muduo",
5-
description = "A C++ network library for Linux and macOS",
5+
description = "A reactor-based C++ network library for Linux",
66
licenses = {"BSD-3-Clause"},
77
repo = "https://github.com/chenshuo/muduo",
88
type = "package",
@@ -14,18 +14,6 @@ package = {
1414
sha256 = "5e90c2f07074ed5ab9347959edc8d387e40a57fbffb92e4a99cfb9a230851371",
1515
},
1616
},
17-
macosx = {
18-
["2.0.3"] = {
19-
url = "https://github.com/chenshuo/muduo/archive/refs/tags/v2.0.3.tar.gz",
20-
sha256 = "5e90c2f07074ed5ab9347959edc8d387e40a57fbffb92e4a99cfb9a230851371",
21-
},
22-
},
23-
windows = {
24-
["2.0.3"] = {
25-
url = "https://github.com/chenshuo/muduo/archive/refs/tags/v2.0.3.tar.gz",
26-
sha256 = "5e90c2f07074ed5ab9347959edc8d387e40a57fbffb92e4a99cfb9a230851371",
27-
},
28-
},
2917
},
3018

3119
mcpp = {
@@ -64,3 +52,42 @@ package = {
6452
},
6553
},
6654
}
55+
56+
import("xim.libxpkg.pkginfo")
57+
import("xim.libxpkg.log")
58+
59+
function install()
60+
local wrap = "muduo-" .. pkginfo.version()
61+
if not os.isfile(path.join(wrap, "muduo/net/TcpClient.cc")) then
62+
log.error("compat.muduo: expected %s/muduo/net/TcpClient.cc", wrap)
63+
return false
64+
end
65+
66+
local prefix = pkginfo.install_dir()
67+
os.tryrm(prefix)
68+
os.mkdir(prefix)
69+
local srcroot = path.join(prefix, wrap)
70+
os.mv(wrap, srcroot)
71+
72+
-- shared_ptr::unique() was removed in C++20; the upstream C++17 code
73+
-- uses it before copying connection_. Preserve its exact meaning.
74+
local source = path.join(srcroot, "muduo/net/TcpClient.cc")
75+
local content = io.readfile(source)
76+
local patched, count = content:gsub("connection_%.unique%(%);", "connection_.use_count() == 1;")
77+
if count ~= 1 then
78+
log.error("compat.muduo: expected exactly one shared_ptr::unique() call, got %d", count)
79+
return false
80+
end
81+
io.writefile(source, patched)
82+
-- sys/time.h does not promise the definition of struct tm. Clang's
83+
-- Linux sysroot needs the explicit time.h include for gmtime_r().
84+
source = path.join(srcroot, "muduo/base/Timestamp.cc")
85+
content = io.readfile(source)
86+
patched, count = content:gsub("#include <sys/time%.h>\n", "#include <sys/time.h>\n#include <time.h>\n")
87+
if count ~= 1 then
88+
log.error("compat.muduo: expected exactly one sys/time.h include, got %d", count)
89+
return false
90+
end
91+
io.writefile(source, patched)
92+
return true
93+
end

‎tests/examples/muduo/mcpp.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name = "muduo-tests"
44
version = "0.1.0"
55

6-
[dependencies.compat]
6+
[target.'cfg(linux)'.dependencies.compat]
77
muduo = "2.0.3"

‎tests/examples/muduo/tests/buffer.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if defined(__linux__) || defined(__APPLE__)
1+
#ifdef __linux__
22
#include <muduo/net/Buffer.h>
33

44
#include <cstring>

0 commit comments

Comments
 (0)