From 3f8a1c7c982d4791440f932103f8335bde947175 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Tue, 1 Sep 2026 00:18:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(wayland):=20=E5=AF=BC=E5=87=BA=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=A4=9F=E4=B8=8D=E7=9D=80=E7=9A=84=E5=85=AB=E4=B8=AA?= =?UTF-8?q?=20static=20inline=20=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `static inline` 是内部链接,C++ 禁止从模块导出。这个 fork 一直知道这个坑 —— 它为 wayland-scanner 生成的包装专门做了 `inline` 副本 —— 但漏掉了两个手写头: wayland-server-core.h wl_signal_init/_add/_get/_emit -> .server wayland-util.h wl_fixed_to/from_double/int -> .client 这不是边角。每一次 wlroots 监听注册都是 wl_signal_add(&x->events.y, &l),所以 **走模块路线写不了合成器**;wl_fixed_t 是协议里每个亚像素坐标的载体(指针移动、 触摸、数位板),所以**处理不了输入事件**。 ⚠️ 一直没发现,因为这个包的测试从没调用过其中任何一个。缺口是从**外面**被问出 来的 —— 一个最小 wlroots 合成器编不过。同一类问题在 freedesktop.cairo(少 cairo_t)和 displayinfo(少 295 个枚举量)上都出现过,发现方式完全一样: **自己的测试问不出来,别的包在真实用途里能。** 索引示例现在真的调用这八个 —— 再塌陷就是编译错误。 资产:wayland-1.26.0-mcpp4.tar.gz,sha256 9bce2cc0…,两个镜像一致。 六个描述符同步。gcc 16.1 / llvm 22.1 双绿。 --- pkgs/f/freedesktop.wayland-cursor.lua | 6 +++--- pkgs/f/freedesktop.wayland-egl.lua | 6 +++--- pkgs/f/freedesktop.wayland-scanner.lua | 6 +++--- pkgs/f/freedesktop.wayland-server.lua | 21 ++++++++++++++++++--- pkgs/f/freedesktop.wayland-util.lua | 6 +++--- pkgs/f/freedesktop.wayland.lua | 18 +++++++++++++++--- tests/examples/wayland/tests/modules.cpp | 20 ++++++++++++++++++++ 7 files changed, 65 insertions(+), 18 deletions(-) diff --git a/pkgs/f/freedesktop.wayland-cursor.lua b/pkgs/f/freedesktop.wayland-cursor.lua index b5ac2e4..4fd8bcb 100644 --- a/pkgs/f/freedesktop.wayland-cursor.lua +++ b/pkgs/f/freedesktop.wayland-cursor.lua @@ -59,10 +59,10 @@ package = { linux = { ["1.26.0"] = { url = { - GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp3.tar.gz", - CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp3.tar.gz", + GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp4.tar.gz", + CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp4.tar.gz", }, - sha256 = "b95537b21b0df2119a84ec8b3b833a564259e52fbbe2b119c5f9dd7cbaad55a0", + sha256 = "9bce2cc00c61399a3c2fb15e730b664073694154860bc5e2b4496bcf09e55e52", }, }, }, diff --git a/pkgs/f/freedesktop.wayland-egl.lua b/pkgs/f/freedesktop.wayland-egl.lua index 372343d..7a28fb3 100644 --- a/pkgs/f/freedesktop.wayland-egl.lua +++ b/pkgs/f/freedesktop.wayland-egl.lua @@ -39,10 +39,10 @@ package = { linux = { ["1.26.0"] = { url = { - GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp3.tar.gz", - CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp3.tar.gz", + GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp4.tar.gz", + CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp4.tar.gz", }, - sha256 = "b95537b21b0df2119a84ec8b3b833a564259e52fbbe2b119c5f9dd7cbaad55a0", + sha256 = "9bce2cc00c61399a3c2fb15e730b664073694154860bc5e2b4496bcf09e55e52", }, }, }, diff --git a/pkgs/f/freedesktop.wayland-scanner.lua b/pkgs/f/freedesktop.wayland-scanner.lua index 214f2e9..17d172a 100644 --- a/pkgs/f/freedesktop.wayland-scanner.lua +++ b/pkgs/f/freedesktop.wayland-scanner.lua @@ -33,10 +33,10 @@ package = { linux = { ["1.26.0"] = { url = { - GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp3.tar.gz", - CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp3.tar.gz", + GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp4.tar.gz", + CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp4.tar.gz", }, - sha256 = "b95537b21b0df2119a84ec8b3b833a564259e52fbbe2b119c5f9dd7cbaad55a0", + sha256 = "9bce2cc00c61399a3c2fb15e730b664073694154860bc5e2b4496bcf09e55e52", }, }, }, diff --git a/pkgs/f/freedesktop.wayland-server.lua b/pkgs/f/freedesktop.wayland-server.lua index a7a9aca..fe615ff 100644 --- a/pkgs/f/freedesktop.wayland-server.lua +++ b/pkgs/f/freedesktop.wayland-server.lua @@ -20,6 +20,21 @@ -- `libwayland-server.so.0` are distinct SONAMEs that Mesa's libEGL_mesa needs -- BOTH of, and mcpp links every library target in a package against all of its -- sources — so one package cannot emit two libraries with disjoint contents. +-- +-- ───────────────────────────────────────────────────────────────────────── +-- ⭐ wl_signal_* 在 mcpp4 之前够不着(已修复) +-- +-- `wayland-server-core.h` 把 wl_signal_init / _add / _get / _emit 定义成 +-- `static inline` —— 内部链接,C++ 禁止从模块导出。于是走**模块路线**的消费者 +-- 一个都拿不到。 +-- +-- 这不是边角:每一次 wlroots 监听注册都是 +-- `wl_signal_add(&thing->events.x, &listener)`,所以**用模块写不了合成器**。 +-- +-- ⚠️ 一直没发现,是因为这个包的测试从没调用过其中任何一个。缺口是从**外面** +-- 被问出来的 —— 一个最小 wlroots 合成器编不过。同一类问题在 +-- `freedesktop.cairo`(少 cairo_t)和 `displayinfo`(少 295 个枚举量)上都出现 +-- 过,发现方式也一样:**自己的测试问不出来,别的包在真实用途里能。** package = { spec = "1", namespace = "freedesktop", @@ -33,10 +48,10 @@ package = { linux = { ["1.26.0"] = { url = { - GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp3.tar.gz", - CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp3.tar.gz", + GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp4.tar.gz", + CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp4.tar.gz", }, - sha256 = "b95537b21b0df2119a84ec8b3b833a564259e52fbbe2b119c5f9dd7cbaad55a0", + sha256 = "9bce2cc00c61399a3c2fb15e730b664073694154860bc5e2b4496bcf09e55e52", }, }, }, diff --git a/pkgs/f/freedesktop.wayland-util.lua b/pkgs/f/freedesktop.wayland-util.lua index 94b94cf..25fb226 100644 --- a/pkgs/f/freedesktop.wayland-util.lua +++ b/pkgs/f/freedesktop.wayland-util.lua @@ -33,10 +33,10 @@ package = { linux = { ["1.26.0"] = { url = { - GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp3.tar.gz", - CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp3.tar.gz", + GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp4.tar.gz", + CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp4.tar.gz", }, - sha256 = "b95537b21b0df2119a84ec8b3b833a564259e52fbbe2b119c5f9dd7cbaad55a0", + sha256 = "9bce2cc00c61399a3c2fb15e730b664073694154860bc5e2b4496bcf09e55e52", }, }, }, diff --git a/pkgs/f/freedesktop.wayland.lua b/pkgs/f/freedesktop.wayland.lua index bb8a7ba..741b6a4 100644 --- a/pkgs/f/freedesktop.wayland.lua +++ b/pkgs/f/freedesktop.wayland.lua @@ -20,6 +20,18 @@ -- `libwayland-server.so.0` are distinct SONAMEs that Mesa's libEGL_mesa needs -- BOTH of, and mcpp links every library target in a package against all of its -- sources — so one package cannot emit two libraries with disjoint contents. +-- +-- ───────────────────────────────────────────────────────────────────────── +-- ⭐ wl_fixed_* 在 mcpp4 之前够不着(已修复) +-- +-- `wayland-util.h` 把四个定点数转换定义成 `static inline`(内部链接),模块 +-- 无法导出。而 `wl_fixed_t` 是协议里**每一个亚像素坐标**的载体 —— wl_pointer +-- 的移动、触摸点、数位板轴 —— 所以走模块路线的客户端**处理不了输入事件**。 +-- +-- ⚠️ 它们放在**这个**模块而不是 `freedesktop.wayland.util`:那个模块是和头文件 +-- **配对**设计的(只出宏和模板,零个 `using ::`),加同名实体会让每次调用在 +-- clang 上 `ambiguous`。也没有同时放进 server —— 两个模块各自的实体,对同时 +-- import 两者的 TU 一样是二义。三个模块同时 import 已在两条工具链上实测。 package = { spec = "1", namespace = "freedesktop", @@ -33,10 +45,10 @@ package = { linux = { ["1.26.0"] = { url = { - GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp3.tar.gz", - CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp3.tar.gz", + GLOBAL = "https://github.com/mcpplibs/wayland/releases/download/v1.26.0/wayland-1.26.0-mcpp4.tar.gz", + CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0-mcpp4.tar.gz", }, - sha256 = "b95537b21b0df2119a84ec8b3b833a564259e52fbbe2b119c5f9dd7cbaad55a0", + sha256 = "9bce2cc00c61399a3c2fb15e730b664073694154860bc5e2b4496bcf09e55e52", }, }, }, diff --git a/tests/examples/wayland/tests/modules.cpp b/tests/examples/wayland/tests/modules.cpp index 54c1462..52e3357 100644 --- a/tests/examples/wayland/tests/modules.cpp +++ b/tests/examples/wayland/tests/modules.cpp @@ -92,6 +92,26 @@ int main() "WL_MARSHAL_FLAG_DESTROY keeps upstream's value"); } + // ⭐ 这八个函数在 mcpp4 之前根本够不着(`static inline` 无法从模块导出), + // 而**没有任何测试调用过它们**,所以谁都没发现。缺口是从外面被一个最小 + // wlroots 合成器问出来的。下面每一行都是"再塌陷就编译不过"的探针。 + { + // wayland-util.h 的定点数 —— 协议里每个亚像素坐标的载体 + check(wl_fixed_from_int(3) == 768, "wl_fixed_from_int"); + check(wl_fixed_to_double(wl_fixed_from_double(1.5)) == 1.5, "wl_fixed double 往返"); + check(wl_fixed_from_double(-1.5) == -384, "负数按上游 round() 舍入"); + + // wayland-server-core.h 的 signal —— 每次 wlroots 挂监听都要它 + wl_signal sig{}; + wl_signal_init(&sig); + check(sig.listener_list.next == &sig.listener_list, "wl_signal_init"); + wl_listener l{}; + l.notify = [](wl_listener *, void *) {}; + wl_signal_add(&sig, &l); + check(wl_signal_get(&sig, l.notify) == &l, "wl_signal_add + wl_signal_get"); + wl_list_remove(&l.link); + } + std::printf("\n%d check(s) failed\n", failures); return failures == 0 ? 0 : 1; }