LATX, feat: Add experimental Cairo native wrapper - #396
Merged
LaurenIsACoder merged 6 commits intoAug 13, 2026
Merged
Conversation
A guest loader may publish RT_CONSISTENT before it has finished applying a dynamically loaded object's relocations. Marking a successful KZT pass complete at that point lets the loader overwrite native bridges and prevents the existing pre-RELRO retry. For objects with PT_GNU_RELRO, wait for the intercepted writable RELRO boundary. Objects without RELRO still bind at RT_CONSISTENT because they have no later protection transition. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Read and write scalar wrapper values from lane zero of the selected guest XMM register. The old expression indexed lanes within XMM0, which misrouted XMM1 and later arguments and overlapped double values. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
The generic iFii signature was declared but had no callable wrapper, and its unused typedef used 64-bit integers. Cairo format-stride calculation is the first enabled native wrapper that requires this signature. Implement the wrapper with two int32 arguments and an int32 return so the generated Cairo symbol map can link with the public Cairo ABI. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Add the Cairo 1.18 public symbol catalog together with the scalar, pointer, double, and XCB-aligned dispatch signatures it requires. Keep this mechanical ABI preparation separate from library activation, preflight policy, and callback behavior. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Inspect the guest Cairo dynamic symbol table before native activation. Require every exported Cairo function to have a declared safe wrapper and a matching host symbol, and expose rejection reasons through opt-in KZT diagnostics so unsupported backends fail as a whole library. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Register Cairo as an opt-in library family and cover the complete public symbol set exported by the supported guest Cairo 1.18 runtime. Bridge destroy, stream, user-font, observer, MIME, and raster-source callbacks with typed guest argument marshalling, bounded reusable slots, locking, and object-lifetime tracking. Adapt XCB connection objects and reject native activation when whole-library preflight fails. Keep FreeType and Fontconfig interop memory-safe by returning an explicit font-type mismatch until those opaque object families have native wrappers. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Contributor
|
Hi, Loongnix Desktop ABI 1.0 gtkperf-for-gtk3 开启LATX_KZT_LIBS=cairo复现断言失败: Thanks, |
Contributor
|
跑5次能复现2次。 gtkperf-for-gtk3 由于是libgtk-3.so被skip kzt了: 请检查CheckEnableKZT: 类似被option_kzt=0的场景还有:因为matlab R2016b的sys/opengl/lib/glnxa64/下有x86_64的libGL.so.1.6.0 所以CheckEnableKZT发现找到libGL的x86_64的so就return 0关闭了KZT: |
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.
English
Summary
This adds an experimental, opt-in KZT native wrapper for Cairo. Supported x86_64 guest Cairo calls can enter the LoongArch host Cairo library instead of translating the guest Cairo implementation.
The change:
Safety and compatibility
Cairo remains an experimental KZT library family and is enabled explicitly with:
Native activation is rejected for the whole Cairo library when the guest ELF is unsupported, an exported Cairo function has no declared wrapper, or the host library lacks a required symbol. LAT then continues with the translated guest Cairo library.
The validated runtime combination is guest Cairo 1.18.0 and host Cairo 1.18.2. FreeType and Fontconfig opaque-object interoperation is not enabled; those entry points return an explicit Cairo font-type mismatch instead of mixing guest and host objects.
Validation
Validation was performed on a LoongArch system with a real local X11 display:
dlopenprobes passed in KZT-off, stable-KZT, and Cairo-enabled modes;cairo_create,cairo_set_source_rgba,cairo_rectangle,cairo_fill,cairo_show_text,cairo_surface_flush, andcairo_destroy;中文
概述
本 PR 为 Cairo 增加实验性质、需要显式开启的 KZT 原生 wrapper。受支持的 x86_64 guest Cairo 调用可以直接进入 LoongArch host Cairo,而不再翻译执行 guest Cairo 的实现代码。
本次修改:
安全性与兼容性
Cairo 仍属于实验 KZT 库族,需要显式启用:
如果 guest ELF 不受支持、某个导出的 Cairo 函数没有安全 wrapper,或者 host Cairo 缺少必要符号,LAT 会拒绝整个 Cairo 库的原生直通,并继续翻译执行 guest Cairo。
已验证的版本组合为 guest Cairo 1.18.0 和 host Cairo 1.18.2。当前不启用 FreeType 和 Fontconfig 不透明对象的跨库互操作;相关入口会明确返回 Cairo font type mismatch,避免混用 guest 与 host 对象。
验证
以下验证在 LoongArch 机器的真实本地 X11 显示环境完成:
dlopen探针在关闭 KZT、稳定 KZT 和启用 Cairo 三种模式下均通过;cairo_create、cairo_set_source_rgba、cairo_rectangle、cairo_fill、cairo_show_text、cairo_surface_flush和cairo_destroy完成 guest 调用 -> LAT wrapper -> native bridge -> host Cairo -> 返回 guest 的完整路径;