myxce/DEPS.md
lei.chen 50cf424146 build: remove nix dependency layer -- apt system libs + meson wrap subprojects
The build no longer self-wraps into `nix develop`: src/tools/xce-build.sh now
runs meson+ninja directly on system packages, with a dependency preflight
that fails early naming the missing tool/pkg-config package (DEPS.md).

Dependencies (see DEPS.md for the full tables):
- 11 C libraries from apt (libuv, openssl, libedit, sqlite3, hwloc, libcgroup,
  libtirpc, libcyaml, libyaml, zlib, libsystemd) with version floors in
  meson.build mirroring the Ubuntu 24.04 baseline.
- sd-bus: default libsystemd, -Duse_elogind=true opt-back for nix-era hosts.
- 6 libraries/tools unavailable in apt become committed meson wrap
  subprojects under src/subprojects/ (source closure, ~500 files): the
  upstream trees plus packagefiles/ overlays and diff_files patches
  registering dependency/program overrides the nix .pc files used to
  provide (incl. the '<name>-raw' variable deps the Go CGO path reads).
  Fresh-clone reproducibility verified: wiped trees + `meson subprojects
  download` reproduce the committed state exactly (fixed librtti.wrap's
  dangling patch_directory and c-capnproto's empty packagefiles overlay).
- xceadmin: self-contained venv built from requirements-build.txt (pinned,
  offline-seedable via PIP_FIND_LINKS) instead of --system-site-packages.

Build/packaging:
- Makefile facade over xce-build.sh; scripts/ci-ubuntu.sh drives a bare
  Ubuntu 24.04 container through deps + build + tests.
- src/tools/xce-package.sh: release-tree tarball packager. Collects
  non-base DT_NEEDED libs from the BUILD-tree binaries (staged ldd lies:
  the dangling build RPATH makes ldd drop the very lines the naive filter
  needs), sets $ORIGIN RPATHs, rebases the xceadmin venv at install time
  (kernel does not parse quotes in shebangs), ships systemd unit samples +
  install.sh. Local smoke test: all 8 binaries resolve, xceadmin works from
  both bin/ wrapper and venv script.

Test fixes found on the way (all environmental, not build bugs):
- harness_test.c setUp(): pin XCE_CONTROLLER_PEERS to a bound-then-closed
  loopback port so the CLI-error tests assert the no-controller failure
  path even on a dev box running a live cluster on localhost:9990.
- test_test_cli.c: setpgid(0,0) in the spawned-xce_test child. libedit's
  sig_handler re-raises received signals via kill(0, sig) -- process GROUP
  wide (strace -k evidence) -- and the child previously shared the
  harness's pgrp, so an interrupted SSL handshake killed the whole suite
  (exit 130).

Also fixed while re-baselining on the de-nix toolchain (pre-existing, now
deterministic): raft_init zeroes pre-vote tally state (pre_vote_in_progress/
pre_votes_granted/pre_vote_replies were left at stack garbage);
push_config_to_standbys clears stale config acks before fan-out
(repl_reset_config_acks) -- SHA-256-derived tags are not monotonic, so a
previous push's ack numerically above the new tag fabricated a barrier
quorum; capnpc-c's generated encode_* memsets the destination first
(skipped Data fields fed garbage into capn_setp).

Validation: asan profile 161/161 meson tests green (one known p2_integration
-110 timing flake on first run, green on re-run); debug + release full
builds OK; tarball smoke-tested on the build host. Cluster rollout on
t1/t2/t3 follows.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-20 18:04:22 +00:00

81 lines
5.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# XCE 第三方依赖清单
> 建立:2026-10-20(build/de-nix 分支)。背景与决策见 gaps.md "六、构建/分发系统"。
>
> **原则**:系统库优先(apt/发行版包),发行版没有的用 meson wrap subproject 从源码构建;
> 运行期需要自带的库由打包脚本 bundle(`$ORIGIN` RPATH),不引入 /nix/store 或任何
> 内容寻址二进制闭包。glibc/libm/libpthread/pthread 永不 bundle。
## 构建工具链
| 工具 | 最低版本 | 获取 | 备注 |
|---|---|---|---|
| gcc | 13 | 系统包 | `apt install gcc`(glibc 2.39+ 基线) |
| meson | 1.5 | `pip install meson` / `apt install meson`(≥1.3 时 pip 补) | src/meson.build 要求 >=1.5 |
| ninja | 1.11 | `apt install ninja-build` | meson 默认 backend |
| pkg-config | 0.29 | `apt install pkg-config` | |
| go | 1.22 | 上游 tarball / `apt install golang-go` | apiserver/xcecli 已 vendor 全部模块,构建离线 |
| capnp (capnproto) | 1.0.1 | `apt install capnproto`(含 libcapnp-dev) | schema 编译器 + C++ 运行时(pycapnp 链接用) |
| packcc | 2.2 | wrap subproject(Ubuntu 24.04 无包) | 3 个 .peg 解析器(lib/section, rusage, xce_resreq, xce_select) |
| python3 | 3.10 | 系统自带 | xceadmin 构建/测试;no-fork rule 检查脚本 |
| swag | latest | `go install github.com/swaggo/swag/cmd/swag@latest` | 仅 apiserver 文档再生成时需要,非构建必需 |
## C 库依赖
### apt 可直接安装(11 个)
| 依赖 (meson 名) | apt 包 | 版本下限 | 用途 |
|---|---|---|---|
| libuv | libuv1-dev | >=1.44 | 所有 daemon 事件循环 |
| openssl | libssl-dev | >=3.0 | TLS(controller 互联、apiserver)、SHA256 |
| libedit | libedit-dev | >=3.1 | xce_test REPL(BSD 许可,替代 GPL readline) |
| sqlite3 | libsqlite3-dev | >=3.37 | worker 本地状态 |
| hwloc | libhwloc-dev | >=2.8 | worker 拓扑/槽位 |
| libcgroup | libcgroup-dev | >=2.0 | worker cgroup v2 限额 |
| libtirpc | libtirpc-dev | >=1.3 | rpc 头文件 |
| libcyaml | libcyaml-dev | >=1.2 | YAML 配置读取 |
| yaml-0.1 | libyaml-dev | >=0.2.5 | 同上(libcyaml 依赖) |
| zlib | zlib1g-dev | >=1.2.11 | 压缩 |
| threads/math/rt | (libc) | — | 无需安装 |
### apt 没有 → meson wrap subproject(源码随 repo 拉取构建,6 个)
| 依赖 (meson 名) | 上游 | 版本 | 用途 / 备注 |
|---|---|---|---|
| c-capnproto | github:shen390s/c-capnproto(pin e45ff68) | — | Cap'n Proto C runtime(libCapnC_Runtime)+ capnpc-c 代码生成器;32 个源文件 include capnp_c.h |
| librtti | git+ssh gitea rshen/librtti(pin 2149f778) | 0.0.2 | C 运行时类型信息库;上游本身是零依赖 meson 项目;93 个源文件消费 |
| struct2json | xbuild channel 源码 vendor | 1.0.0 | cJSON + s2j 封装(纯静态库);6 个 meson 消费点 |
| tinylog | xbuild channel 源码 vendor | 1.0.0 | 轻量异步日志(-ltlog + tlog.h);13 个源文件消费 |
| unity | xbuild channel 源码 vendor(上游 ThrowTheSwitch/Unity) | 2.6.1 | 单元测试框架(libunity.a + unity/unity.h);仅测试目标链接 |
| packcc | 上游 arithy/packcc | >=2.2 | PEG 解析器生成器;构建工具而非链接库 |
### 特殊:libelogind → libsystemd
worker 的 systemd transient unit 管理(`sd_bus_*`,263 处调用)目前链 nix 的 elogind 255.5。
Ubuntu 24.04 无 elogind 包,但有 **libsystemd-dev 255.4**——sd-bus API 同源兼容。
构建默认 `dependency('libsystemd')`,保留 `-Duse_elogind=true` 选项供非 systemd 平台。
(Step 2 实施时验证;这是本迁移唯一有 ABI 行为风险的替换点,worker 单测兜底。)
### Python(xceadmin)
`src/xceadmin/pyproject.toml` 已声明全部运行依赖:click>=8.0, pycapnp>=1.3, PyYAML>=6.0,
jsonschema>=4.0。构建用普通 venv(**不要** --system-site-packages——那是 nix 环境的产物):
`python3 -m venv .venv && .venv/bin/pip install .`。pycapnp 的 C 扩展链系统的
capnproto C++ 运行时(apt capnproto/libcapnp-dev 提供版本 1.0.1;pycapnp>=1.3 兼容)。
## 为什么不用 nix store(决策记录)
nix 把依赖闭包做成内容寻址的 /nix/store 路径 + mount namespace,要求闭包出现在**每一台
运行机器**上,且 patchelf 重定位后 ldd/gdb/stack trace 全部变形(t2/t3 master 进程 argv 是
`ld-linux... --library-path /opt/newxce/app/nix/store/...`,人读不懂)。EDA 客户环境没有
/nix/store,这条路在产品定义上不可用。本 repo 依赖只有十来个中小型库,"自包含"的正确形态
是**源码闭包**(wrap subproject)+ 运行期 bundle 清单,不需要二进制 store。此外 nix 的
LD_LIBRARY_PATH 泄漏会导致系统工具崩溃(t2/t3 的 ls/head segfault 实录)。
## 运行期 bundle 规则(打包脚本用)
- **bundle**:libuv、libcapnp/libCapnC_Runtime、librtti、libtlog、libstruct2json、
libcyaml、libyaml、libtirpc、libedit、libcgroup、libhwloc、libssl/libcrypto(若目标基线 <3.0)
- **永不 bundle**:libc/libm/libpthread/libdl/librt(glibc)、libsystemd(按目标发行版)
- 判定方法:对每个产物 `ldd`,凡路径不在 {/lib, /usr/lib, /lib64} 的(即 wrap 构建产物)
一律复制进 `lib/`,二进制设 `$ORIGIN/../lib` RPATH。