Skip to content

Add libXt-1.3.1 build#5

Merged
jserv merged 1 commit into
mainfrom
libxt
Jun 3, 2026
Merged

Add libXt-1.3.1 build#5
jserv merged 1 commit into
mainfrom
libxt

Conversation

@jserv
Copy link
Copy Markdown
Contributor

@jserv jserv commented Jun 2, 2026

This build libXt-compat.so from pinned upstream libXt-1.3.1 against the SDL2-backed Xlib shim. Output exports 299 Xt symbols; depends only on libX11-compat.so and libSystem.

Fill the Xlib symbols libXt actually calls.
XAddConnectionWatch, XRemoveConnectionWatch, XInternalConnectionNumbers, XProcessInternalConnection: stubs, since the SDL backend has no internal connections to fold into the event loop.
XConvertCase: carved verbatim from libX11 KeyBind.c with attribution, since the surrounding KeyBind.c overlaps with src/input.c's SDL-backed keysym handling.
XrmQGetResource, XrmQGetSearchList, XrmQGetSearchResource: bridge the quark API onto the existing string-based database by encoding the database pointer plus the widget prefix arrays into the search list, then reassembling the full quark path on lookup.
The previous always-False stubs sent libXt's _XtDisplayInitialize into an alloca-doubling loop until the stack smashed.

mk/libxt.mk compiles util/makestrs.c as a host tool, runs it to generate StringDefs.c, StringDefs.h, and Shell.h, then compiles the 53 libXt translation units with -DHAVE_CONFIG_H -DLIBXT_COMPILATION -DXT_NO_SM. include/libxt-build/config.h is the synthesized autoconf output. include/X11/Xmu/Editres.h, include/X11/SM/SMlib.h, include/X11/ICE/ICElib.h satisfy unconditional libXt header includes without dragging libXmu, libSM, or libICE into the link closure.

scripts/sync-upstream-headers.py gains per-source src_take_all and util_files knobs, plus a SRC_PATCHES entry that works around a real upstream bug in libXt-1.3.1's SessionSetValues, where a misplaced XT_NO_SM #endif leaves widget casts referenced outside their declaration scope.


Summary by cubic

Builds libXt-compat.so from pinned libXt-1.3.1 and wires it into the build, enabling Xt apps to run on our SDL2-backed Xlib without new system deps. Implements missing Xlib hooks and a robust Xrm quark bridge so initialization and resource lookups work correctly, including deep prefixes.

  • New Features

    • Build libXt-compat.so exporting 299 Xt symbols; links only to libX11-compat.so and libSystem.
    • Bridge Xrm quark APIs (XrmQGetResource, XrmQGetSearchList, XrmQGetSearchResource) with prefix encoding and correct buffer-size semantics to unblock _XtDisplayInitialize and support deep resource paths.
    • Add XConvertCase (from upstream libX11) for correct keysym case folding.
    • Stub internal-connection hooks (XAddConnectionWatch, XRemoveConnectionWatch, XInternalConnectionNumbers, XProcessInternalConnection) for the SDL backend.
    • Fix XrmParseCommand to only NULL-terminate argv when compression frees a slot, avoiding an overrun; matches upstream behavior.
    • Add libXt smoke and micro tests (test-libxt-link, test-libxt-micro) covering init, events, callbacks, GC, and fallback resources; integrated into make check.
  • Dependencies

    • Add mk/libxt.mk; compile 53 upstream sources, build host makestrs to generate StringDefs.{c,h} and Shell.h, and link with -DXT_NO_SM.
    • Stage generated StringDefs.h/Shell.h under the staged X11 include tree so <X11/Shell.h> resolves for downstream consumers.
    • Add stub headers X11/Xmu/Editres.h, X11/SM/SMlib.h, X11/ICE/ICElib.h to avoid pulling libXmu, libSM, or libICE.
    • Add include/libxt-build/config.h (enables USE_POLL, XTHREADS; disables SM).
    • Extend scripts/sync-upstream-headers.py with per-source src_take_all/util_files, stage libXt src/util into separate dirs, and patch libXt-1.3.1 Shell.c SessionSetValues for XT_NO_SM.
    • Include mk/libxt.mk from the top-level Makefile; add test rules linking libXt-compat.so and libX11-compat.so. On Linux, add -Wl,-rpath,'$ORIGIN' for runtime and -Wl,-rpath-link,$OUT on tests.

Written for commit 8ba599c. Summary will update on new commits.

Review in cubic

@jserv jserv force-pushed the libxt branch 2 times, most recently from 9ae74d5 to b9b90ed Compare June 2, 2026 19:52
cubic-dev-ai[bot]

This comment was marked as resolved.

This build libXt-compat.so from pinned upstream libXt-1.3.1 against the
SDL2-backed Xlib shim. Output exports 299 Xt symbols; depends only on
libX11-compat.so and libSystem.

Fill the Xlib symbols libXt actually calls.
XAddConnectionWatch, XRemoveConnectionWatch, XInternalConnectionNumbers,
XProcessInternalConnection: stubs, since the SDL backend has no internal
connections to fold into the event loop.
XConvertCase: carved verbatim from libX11 KeyBind.c with attribution, since
the surrounding KeyBind.c overlaps with src/input.c's SDL-backed keysym
handling.
XrmQGetResource, XrmQGetSearchList, XrmQGetSearchResource: bridge the quark
API onto the existing string-based database by encoding the database pointer
plus the widget prefix arrays into the search list, then reassembling the
full quark path on lookup.
The previous always-False stubs sent libXt's _XtDisplayInitialize into an
alloca-doubling loop until the stack smashed.

mk/libxt.mk compiles util/makestrs.c as a host tool, runs it to generate
StringDefs.c, StringDefs.h, and Shell.h, then compiles the 53 libXt
translation units with -DHAVE_CONFIG_H -DLIBXT_COMPILATION -DXT_NO_SM.
include/libxt-build/config.h is the synthesized autoconf output.
include/X11/Xmu/Editres.h, include/X11/SM/SMlib.h, include/X11/ICE/ICElib.h
satisfy unconditional libXt header includes without dragging libXmu, libSM,
or libICE into the link closure.

scripts/sync-upstream-headers.py gains per-source src_take_all and
util_files knobs, plus a SRC_PATCHES entry that works around a real upstream
bug in libXt-1.3.1's SessionSetValues, where a misplaced XT_NO_SM #endif
leaves widget casts referenced outside their declaration scope.

On Linux, bake -Wl,-rpath,$ORIGIN into libXt-compat.so so its DT_NEEDED
reference to libX11-compat.so (recorded by basename from -lX11-compat)
resolves from the sibling build directory at runtime. macOS encodes a
relative install_name and already worked from a repo-root cwd.
@jserv jserv merged commit 4358bd4 into main Jun 3, 2026
3 checks passed
@jserv jserv deleted the libxt branch June 3, 2026 03:48
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.

1 participant