LATX: Add experimental stateless GLib leaf passthrough - #408
Draft
LaurenIsACoder wants to merge 3 commits into
Draft
LATX: Add experimental stateless GLib leaf passthrough#408LaurenIsACoder wants to merge 3 commits into
LaurenIsACoder wants to merge 3 commits into
Conversation
Add the signed-byte, pointer-sized, floating-point, and mixed-register dispatch shapes required by the selected GLib leaf ABI. The signatures are derived from public GLib 2.80 and 2.88 headers and preserve independent x86_64 integer and XMM argument positions. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Wrap a version-stable subset of GLib functions that consumes only scalar values, caller-owned strings, or caller-owned buffers. Keep allocators, containers, GType, GObject, GClosure, GIO, and callback-owning APIs on the guest path so native objects and registries cannot enter guest internals. Preflight only the selected leaf surface and reject native activation when a guest leaf export has no matching host symbol. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Register libglib-2.0.so.0 in a dedicated experimental glib group with the core KZT dependency. The group activates only the stateless leaf wrapper surface; GObject and GIO remain unregistered and execute entirely as guest libraries. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
LaurenIsACoder
force-pushed
the
lauren/kzt-glib-gobject
branch
from
August 20, 2026 02:44
74e7283 to
42c34eb
Compare
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.
概要 / Overview
本 PR 为 KZT 增加 experimental
glib库族,并对 54 个无状态 GLib 叶子函数启用 LoongArch host 原生直通。所选函数只处理 scalar、caller-owned 字符串、caller-owned buffer 或 raw pointer,不创建或返回需要 GLib 管理的对象。This PR adds an experimental KZT
glibfamily and enables native LoongArch passthrough for 54 stateless GLib leaf functions. The selected functions only consume scalars, caller-owned strings, caller-owned buffers, or raw pointers; they do not create or return objects with GLib-managed ownership.设计边界 / Design boundary
GLib 与 GObject 不能按常用函数逐步混合直通。GHashTable、GSource、GMainContext、GVariant、GType、GObject、GClosure、GValue 和 GIO 对象都包含长期状态;如果对象由 host 创建而后续函数回到 guest,guest 库会解引用 host 私有对象。GType、GQuark、signal ID 还依赖各自的 registry,不能混用 host 与 guest 值。
GLib and GObject cannot safely use opportunistic per-function passthrough for object APIs. GHashTable, GSource, GMainContext, GVariant, GType, GObject, GClosure, GValue, and GIO objects carry persistent state. If host code creates an object and an uncovered operation later returns to the guest library, guest code would dereference a host-private object. GType, GQuark, and signal IDs also belong to separate registries and cannot be mixed between host and guest.
因此,本 PR 明确保留以下范围在 guest:
The following areas therefore remain fully on the guest path:
This keeps every GLib/GObject object, registry, callback owner, and destroy path inside the guest implementation while allowing stateless leaf calls to enter host GLib.
主要修改 / Main changes
新增 experimental
glibgroup,依赖 stablecore,默认不启用。为 ASCII、字符串、hash/equal、UTF-8 结构和 pointer-sized bit 操作增加 54 个
GOwrapper。增加对应的 signed-byte、pointer-sized、floating-point 和 mixed-register dispatch 形态。
wrapper 激活前仅 preflight 选定的叶子函数;guest 实际导出的叶子符号缺少 host 对应符号时关闭整个
glibgroup。KZT 日志明确说明 allocator、container、GObject、GIO 和 callback-owning API 仍为 guest。
--kzt-libs显示glib status=experimental requires=core。Adds an experimental
glibgroup depending on stablecore; it is disabled by default.Adds 54
GOwrappers covering ASCII, strings, hash/equal helpers, UTF-8 structure handling, and pointer-sized bit operations.Adds the required signed-byte, pointer-sized, floating-point, and mixed-register dispatch shapes.
Preflights only the selected leaf surface. If a leaf symbol exported by the guest has no matching host symbol, the complete
glibgroup is disabled.Logs the explicit boundary that allocators, containers, GObject, GIO, and callback-owning APIs remain guest-side.
Exposes
glib status=experimental requires=corethrough--kzt-libs.验证 / Validation
当前验证在 AOSC OS LoongArch ABI 2.0 主机完成:
latx-x86_64产品构建通过;二进制 SHA-256:3c0b429d31df039b1dcec26e59db5503379b9bc1276e2328b0e232cb7ec4e70a。defd1c68d48c8314。g_ascii_digit_value、g_ascii_strtod、g_ascii_dtostr、g_ascii_formatd、g_bit_nth_lsf、g_strlcat、g_strcanon、g_unichar_to_utf8和g_utf8_validate_len。g_hash_table_new_full、g_object_new和g_idle_add_full仍位于 guest0x550...地址并由 LAT 翻译。g_str_hash,但 GHashTable 对象仍完全属于 guest。glib、跳过 wrapper,probe 在完整 guest 路径退出 0。g_strv_equal和g_utf8_validate_len不参与绑定。ABI 1.0 的 54-call differential、对象边界和四线程 probe 在 KZT=0/1 下各 20/20,结果 hash 均为3b1b4b6ac4be492d,GDB endpoint 与安全回退通过。g_int64_hash和g_double_hash在 GLib 2.58 与新 host 间返回不同的可观察数值,因此明确保留 guest,不在 54 个 allowlist 中。Validation currently covers an AOSC OS LoongArch ABI 2.0 host:
latx-x86_64product build passes; binary SHA-256:3c0b429d31df039b1dcec26e59db5503379b9bc1276e2328b0e232cb7ec4e70a.defd1c68d48c8314.g_hash_table_new_full,g_object_new, andg_idle_add_fullremain at guest0x550...addresses and are translated by LAT.g_str_hashthrough a KZT bridge while the GHashTable object remains entirely guest-owned.glib, skip the wrapper, and complete the probe through the full guest path.g_strv_equalandg_utf8_validate_lensymbols do not participate in binding. The 54-call differential, object-boundary, and four-thread probes each pass 20/20 under KZT=0 and KZT=1 with identical hash3b1b4b6ac4be492d; GDB endpoint and safe-fallback checks also pass.g_int64_hashandg_double_hashproduce observably different values between GLib 2.58 and the newer host implementation, so they explicitly remain guest-side and are not part of the 54-function allowlist.当前边界 / Current limits
本 PR 保持 Draft,
glib保持 experimental。本 PR 不宣称完整 GLib 或 GObject 原生直通,也不为 Pango/GTK 提供 host GObject object chain。
本 PR 自身的 ABI 1.0 leaf、对象边界、线程、endpoint 和 fallback 已验证;所有新增库族合并后的最终 ABI 1.0 桌面矩阵仍由 WI-2119 统一补充。
临时 probe、GDB 脚本和运行日志未加入产品提交。
This PR remains a draft and the
glibgroup remains experimental.It does not claim complete GLib or GObject passthrough and does not provide a host GObject object chain for Pango/GTK.
This PR's ABI 1.0 leaf, object-boundary, thread, endpoint, and fallback paths are validated; WI-2119 still tracks the final integrated ABI 1.0 desktop matrix across all new library families.
Temporary probes, GDB scripts, and runtime logs are not part of the product commits.