Skip to content

feat(pkg): add LibSerial 1.0.0 compat package - #511

Merged
Sunrisepeak merged 5 commits into
mcpplibs:mainfrom
tz12323:feat/add-libserial
Oct 10, 2026
Merged

Sunrisepeak merged 5 commits into
mcpplibs:mainfrom
tz12323:feat/add-libserial

Conversation

@tz12323

@tz12323 tz12323 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Add compat.libserial, a Linux-only C++-source compat package for LibSerial 1.0.0 (SerialPort / SerialStream), built from upstream's LIBSERIAL_SOURCES three translation units and exposing the public headers under libserial/ the way upstream's install does.

The headers open with <termios.h> and every TU reaches <linux/serial.h>, so the descriptor declares only the linux platform and consumers gate it with [target.'cfg(linux)'.dependencies] (same shape as compat.libaio).

Upstream's SerialPortConstants.h uses uint8_t without including ; a generated_files shim supplies it and #include_next's the real header. The test opens on the libserial header first of all, so the shim is compile-time asserted, and asserts the rest over a real openpty() pair.

No CN mirror (no mcpp-res write access): plain-string upstream url per docs/cn-mirror.md.

mcpp-index agent and others added 5 commits October 3, 2026 03:15
Add compat.libserial, a Linux-only C++-source compat package for LibSerial
1.0.0 (SerialPort / SerialStream), built from upstream's LIBSERIAL_SOURCES
three translation units and exposing the public headers under libserial/ the
way upstream's install does.

The headers open with <termios.h> and every TU reaches <linux/serial.h>, so
the descriptor declares only the linux platform and consumers gate it with
[target.'cfg(linux)'.dependencies] (same shape as compat.libaio).

Upstream's SerialPortConstants.h uses uint8_t without including <cstdint>;
a generated_files shim supplies it and #include_next's the real header. The
test opens on the libserial header first of all, so the shim is compile-time
asserted, and asserts the rest over a real openpty() pair.

No CN mirror (no mcpp-res write access): plain-string upstream url per
docs/cn-mirror.md.
合并 main 时 openkal-llvm-runtime 0.15.4 与 openkal-linux 0.16.1 /
openkal-musl 0.20.1 两条被 libserial 条目覆盖;按 main 恢复,libserial
条目另起一条(并补充 libc++ 修复与 CN 镜像)。
…esult_t;加 CN 镜像

SerialPort.h 的公开模板 call_with_retry 用了 C++20 移除的 std::result_of。
libstdc++ 仍保留,libc++ 没有,linux llvm 腿三个 TU 全部编译失败,且消费者
TU 同样会坏。shim 改不了头内模板,_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
又必须先于每个 TU 的第一个 libc++ 头,故由 install() 把两处改写为等价的
std::invoke_result_t<Fn, Args...> 并补 <type_traits>,匹配次数不符即安装失败。

- url 改为 { GLOBAL, CN },CN 为 mcpp-res/libserial(逐字节一致)
- 本地 gcc 16.1.0 / llvm 22.1.8 / llvm 23.1.3 均 1 passed
@Sunrisepeak

Copy link
Copy Markdown
Member

Maintainer follow-up, appended as commits on top of your branch (history unchanged):

  1. b825851 merge main: the branch was behind main.
  2. 6600af0 CHANGELOG: the earlier merge had dropped two existing entries (openkal-llvm-runtime 0.15.4 and openkal-linux 0.16.1 / openkal-musl 0.20.1). They are restored, and libserial now has its own entry.
  3. e144221 libc++ fix + CN mirror
    • Why workspace (linux llvm) was red: SerialPort.h's public template call_with_retry uses std::result_of, which C++20 removed. libstdc++ still ships it, libc++ does not, so all three TUs failed on clang, and any consumer TU including the header would fail the same way. Upstream master still has it.
    • Why patch the header in install(): a shim cannot reach a template inside the header, and _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS would have to precede the first libc++ header of every consumer TU.
    • The fix: install() rewrites both spellings to the equivalent std::invoke_result_t<Fn, Args...>, adds <type_traits>, and asserts the match counts (2 / 1), so an upstream change fails the install instead of silently skipping the fix.
    • CN mirror: mcpp-res/libserial is created, byte-identical to the GitHub tarball. url is now { GLOBAL, CN }.

Verified locally on gcc 16.1.0, llvm 22.1.8 and llvm 23.1.3, and CI is all green. Details are appended to .agents/docs/2026-10-03-add-libserial-plan.md §10.

@Sunrisepeak
Sunrisepeak merged commit 6a3153a into mcpplibs:main Oct 10, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants