feat(libaio): 收录 compat.libaio 0.3.113,并把描述符目录从 README 挪进 docs/ - #277
Merged
Conversation
…log out of the README libaio is the userspace wrapper over Linux's native AIO syscalls. Shape A (C-source compat): upstream's own `libaio_srcs` list from src/Makefile, twelve TUs, no configure step. Linux-only in the strong sense — `struct iocb` IS the kernel's, so there is no other platform section to write and consumers gate it with `[target.'cfg(linux)'.dependencies]`. Three things the descriptor had to answer: * Upstream installs exactly one header, `libaio.h`, but the tarball keeps it in `src/` next to the private ones — one of which is `syscall.h` and would shadow glibc's for every consumer TU. So `include_dirs` names a `generated_files` forwarder and nothing else; the package's own sources reach the real header through it while their quote-form includes still resolve next to the including `.c`, so no `-I` into `src/` is needed. * `-std=c11` sets __STRICT_ANSI__, which hides `syscall()` and `sigset_t` and makes even the public header fail to parse. `c_standard = "gnu11"` looks like the fix and is a trap: mcpp 2026.8.27.2 accepts the string and still emits `-std=c11`. `-D_GNU_SOURCE` in `cflags` is what works. * `io_getevents`/`io_cancel` have no ordinary definitions upstream — the short names come from `.symver … @@LIBAIO_0.4`. Verified to resolve for an executable under both ld.bfd and lld; building a `.so` straight out of these objects still needs upstream's libaio.map, exactly as with upstream's own libaio.a. No features: the only sources not compiled are a build-time assertion TU (restated as static_asserts in the test) and the harness, which carries a main() and so cannot be a feature at all. CN mirror published at gitcode mcpp-res/libaio, byte-identical to GLOBAL. Verified with the CI-pinned mcpp: `mcpp test -p libaio` green from cold, 12 objects actually compiled, and the assertions confirmed failable. Also, in the same pass: the "Reference examples" table had grown to ~22 KB of the 28 KB README and buried everything around it. The full catalog now lives in docs/descriptor-examples.md (+ zh), with libaio's own entry; the README keeps a six-row table of one starting point per shape and links out. README 28693 -> 6151 bytes. Fixes a stale pkgs/o/opencv.lua link along the way.
Sunrisepeak
pushed a commit
that referenced
this pull request
Aug 29, 2026
moodycamel::ConcurrentQueue — the lock-free MPMC queue, plus its blocking
sibling and a flat C API over both. Shape B (header-only): the three public
headers sit at the tarball root, so `include_dirs = {"*"}` plus an anchor TU
is the package; consumers write `#include <concurrentqueue.h>` exactly as
upstream's README shows.
The one compilable optional component — `c_api/`'s two extern "C" wrapper
TUs — sits behind a default-off `c-api` feature (the compat.cjson `utils`
precedent). Windows needs `MOODYCAMEL_STATIC` on BOTH sides: the header
defaults to `__declspec(dllimport)`, which is wrong for the package's own
TUs (they define the functions, and `cflags` never reaches a .cpp — hence
`cxxflags`) and for a static-archive consumer (hence the feature's
interface `defines`). The macro is only read under `#ifdef _WIN32`, so
defining it everywhere is inert on linux/macos. Verified in the emitted
compile_commands.json that all four TUs carry it.
Tests: tests/examples/concurrentqueue asserts FIFO order, bulk round-trips,
move-only elements, a blocking consumer that REALLY waits (empty-queue
wait_dequeue_timed must burn its 50ms timeout), and a 4x4 MPMC race checked
for exact-once delivery. tests/examples/concurrentqueue-c-api consumes the
feature and round-trips integers through the void* C API. Both members
register in the workspace manifest.
Verified locally with mcpp 2026.8.27.1 (CI pins 2026.8.27.2; the release
CDN times out from this host): both members green from cold; the gate is
real — a TU referencing moodycamel_cq_create against the default build
fails to LINK (undefined reference), and the default build's object dir
holds the anchor alone. No CN mirror: no GITCODE_TOKEN on this host, so the
descriptor uses the plain-string upstream url fallback and the descriptor
catalog entry lands in docs/descriptor-examples.md (+ zh), per the post-#277
README layout.
Co-authored-by: gong <gzj17607270093@163.com>
Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1.
compat.libaio0.3.113libaio 是 Linux 原生异步 I/O 系统调用的用户态封装(
io_setup/io_submit/io_getevents/io_cancel/io_destroy,外加io_prep_*与io_queue_*便利层)。形态 A(C 源码 compat):直接取上游
src/Makefile的libaio_srcs,12 个 TU,无 configure、无生成步骤、无 submodule。Linux only,而且是强意义上的:
struct iocb就是内核的结构体,每个 TU 都是syscall(__NR_io_*, …),不存在别的平台段可写。xpm只有linux,消费者用[target.'cfg(linux)'.dependencies]门控,与compat.wil互为镜像。libaio-0.3.113(最新 release)https://releases.pagure.org/libaio/libaio-0.3.113.tar.gzhttps://gitcode.com/mcpp-res/libaio/releases/download/0.3.113/libaio-0.3.113.tar.gz2c44d1c5fd0d43752287c9ae1eb9c023f04ef848ea8d4aafa46e9aedb678200b(连算两次一致;CN 回拉逐字节相同)GLOBAL 用 releases.pagure.org 的发布文件而非
pagure.io/…/archive/…:后者直接 404,且 pagure 与 GitLab 同类,归档即时生成、sha 会漂移。三个需要交代的决策
① 只暴露一个公开头。 上游
make install只装libaio.h,但 tarball 把它放在src/里与私有头并列 —— 其中一个叫syscall.h,上了 include 路径就会遮蔽 glibc 的同名头。所以include_dirs只指向一个generated_files转发头(compat.gmp 的先例),包自身的源码经它拿到真头文件,而它们引号形式的#include "syscall.h"按「包含者所在目录优先」解析 —— 整包不需要任何指向src/的-I。已实测消费者侧#include <syscall.h>拿到的确实是 glibc 的。②
c_standard = "gnu11"是个陷阱。-std=c11会定义__STRICT_ANSI__,glibc 随之藏掉syscall()与sigset_t,连公开头都会在io_pgetevents处解析失败。写gnu11看起来是解法,mcpp xpkg parse也通过,但查产出的compile_commands.json:mcpp 2026.8.27.2 收下这个字符串后仍然发-std=c11,静默降级无提示。生效的写法是cflags里的-D_GNU_SOURCE。③ 符号版本。
io_getevents/io_cancel在上游没有普通定义 —— 真名是io_getevents_0_4之类,短名经.symver … @@LIBAIO_0.4发布。链可执行文件时 ld.bfd 与 lld 都能解析(两者都实测过),kind = "lib"走的正是这条路;直接拿这些对象建.so则需要上游的src/libaio.map,与上游自己的libaio.a完全同理。也试过删compat-0_1.c以消除@LIBAIO_0.1—— 没用,三个@@LIBAIO_0.4一样会挡住,故保留以与上游对象集一致。feature 评估:无
判据是「有没有额外的、可门控的可编译源码」。没有:
src/struct_offsets.c是构建期断言(其注释明说不进目标文件),harness/是自带main()的测试套件 —— 而 mcpp 的 lib 目标对象全量入链,包里带main()必与消费者冲突,连做 feature 的资格都没有。测试成员
tests/examples/libaio断言全是真实内核 AIO 行为,不 mock:上游
struct_offsets.c的三条static_assert(本包不编那个 TU,把检查搬进测试)、io_prep_pwrite填出的 iocb 字段、写路径提交→收事件→pread确认落盘、offset 512 处的读回比对、双请求批量提交用datacookie 区分、错误契约(对已关闭 fd 提交返回-EBADF且errno不被改动)、io_cancel、以及io_queue_init/io_set_callback/io_queue_run的回调层。验证(mcpp
2026.8.27.2,与 CI 同版本)obj/compat_libaio/libaio-0.3.113/src/下 12 个.o,最终二进制里nm可见io_setup/io_submit/io_getevents@@LIBAIO_0.4。memcmp断言反过来 →FAIL (exit 134);改回冷跑仍绿。2. README「参考示例」段落重构
这张表长到了约 22 KB,占 28 KB 英文 README 的绝大部分,把它周围的所有内容都埋掉了。
docs/descriptor-examples.md与docs/zh/descriptor-examples.md(内容原样搬运,libaio 自己的条目写在这里),并登记进docs/README.md/docs/zh/README.md;docs/package-types.md(中英)里指向旧锚点的反向引用;pkgs/o/opencv.lua→pkgs/o/opencv.opencv.lua。README:28693 → 6151 字节(中文 25591 → 5330)。全部相对链接已逐个检查可达。
设计文档:
.agents/docs/2026-08-29-add-libaio-plan.md。