LATX: Add an embedded liblat runtime and native callback support - #481
Draft
LaurenIsACoder wants to merge 9 commits into
Draft
LATX: Add an embedded liblat runtime and native callback support#481LaurenIsACoder wants to merge 9 commits into
LaurenIsACoder wants to merge 9 commits into
Conversation
Extract CPU clone initialization without changing existing callers or thread policy. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Preserve the existing callback ABI, including float results and Host floating-point register preservation. Add explicit helper-call entry points for subsequent TLS initialization. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Keep common runtime options available in release builds and propagate an explicit -L selection through LAT_LD_PREFIX. A re-executed Guest must use the same loader and libc as its parent. Add test-runtime-prefix-exec to check the exported selection and mapped Guest libc before and after exec. Reverting the runtime-root fix makes the fixture fail; the fixed build passes on LoongArch ABI1. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Keep Guest TLS management disabled unless LATX_KZT_GUEST_TLS=1 and KZT is effective. Attach native-created threads from an immutable template, initialize Guest TLS from live loader state, and coordinate generation refresh, callback execution, fork and thread exit. Keep existing library registration and disabled-mode loader behavior. Add policy, loader and native-thread callback tests. Initialize the attached TCB thread ID and robust-list fields before calling the Guest loader allocation helper. The debugger regression reaches that helper with TID 0 before the fix and with the real thread ID after it. Opt-in off/on, robust owner death and 64-cycle dynamic loading regressions pass on LoongArch ABI1. Supply the new runtime-gate variables in the standalone TB-flush test fixture so the complete KZT-enabled lat-pr-fast suite links and runs. Co-authored-by: sunguoyun <sunguoyun@loongson.cn> Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
…ries Provide an initially inactive libc boundary broker for errno, h_errno and locale names. Keep Guest thread destruction in the TLS runtime. Consumers explicitly initialize and activate the broker; enabling Guest TLS alone does not enable semantic propagation. Keep private libc pointers within their owning domain. Own locale projections per Guest context, document borrowed handles, and release each projection in its owning libc during context teardown. The two-thread regression fails with the old shared cache and passes with separate contexts, including mutation and release of an owned duplicate. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
The AOT cache reader and publication tests use g_remove and g_rmdir. Include their declaring header so the tests build with older GLib headers and warnings treated as errors.
Provide common native-to-Guest callback entry points and per-thread attach support for embedded clients. Grow nested libc boundary records dynamically so deep callbacks preserve errno and locale state without a fixed limit. Keep the bridge independent of JVM registration and signal adapters.
Add the shared-library build and NBL loader ABI. Validate bootstrap inputs, keep bootstrap completion local to its CPU, and reject repeated runtime initialization. Drain Guest cleanup callbacks once in reverse registration order, including reentrant registrations and null DSO handles. Reserve only owned Guest mappings in the shared process and reject fixed operations against Native mappings. Preserve partial SysV attachments. Scope PIC and shared-only libc registrations to the shared build so ordinary translator executables retain their existing code generation and bindings. Based on the liblat implementation by sunguoyun, zhaixiang and panxuefeng, with integration, lifecycle, mapping and build corrections. Co-authored-by: zhaixiang <zhaixiang@loongson.cn> Co-authored-by: panxuefeng <panxuefeng@loongson.cn> Co-authored-by: Hanlu Li <heuleehanlu@gmail.com>
Exercise calls, Host thread TLS, deep callbacks, reentrant cleanup, invalid initialization, bootstrap collisions and Native mapping preservation on LoongArch. Include SysV full and partial unmap lifetimes and mixed page sizes. Document the single process-lifetime runtime, bootstrap and error contract.
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.
Depends on #470. This branch rebases its five prerequisite commits onto master at
2c2a169b16a1, followed by four additional commits. Once #470 merges, the prerequisite commits can be dropped from this PR.This adds an embedded x86-64 liblat runtime for LoongArch applications. Native threads can call Guest functions and receive callbacks with independent Guest thread state and dynamically sized libc boundary records.
The four additional commits cover:
The runtime has one process lifetime: finalization drains callbacks but does not destroy or reset it. Loader or Guest fatal errors may terminate the embedding process. The API and build contract are documented in
docs/devel/liblat.md.Validation on LoongArch64 with 16 KiB pages, GCC 8.3 and glibc 2.28:
meson test -C build64 --suite lat-pr-fast --print-errorlogs— 26 passed.meson test -C build-executable --suite lat-pr-fast --print-errorlogs— 27 passed.meson test -C build64 --suite latx-integration --print-errorlogs— 12 passed, using matching x86-64 fixtures.python3 tests/ci/test_lat_ci_workflows.py— 10 passed.Draft: the four additional commits await author-confirmed DCO sign-offs.