[Reference only][Draft] AI-assisted native Linux experiment#1342
[Reference only][Draft] AI-assisted native Linux experiment#1342tc-imba wants to merge 43 commits into
Conversation
….cpp File moved verbatim (100% rename); CMake now compiles only the current platform's src/Platform/<OS>/ directory. Zero Windows behavior change.
Constructor-based bootstrap (LD_PRELOAD) that spawns the init thread, mirroring EntryWin32's thread_dll_start. Not yet compiled into a target; linking libUE4SS.so on Linux is blocked on: - UEPseudo Linux platform headers (exist in UEPseudo PR UE4SS-RE#79, fetched as pr-79-linux in the submodule) - UE_BUILD_*/UBT_COMPILED_PLATFORM defines from the Linux build modes - -fms-extensions for __declspec in RC_*_API macros
- ASM_MASM only enabled on Windows - UE4SS_PLATFORM_TYPES: Win64 on Windows, Linux elsewhere (CI grep takes first declaration via -m1) - Linux platform defines: PLATFORM_LINUX/PLATFORM_UNIX/LINUX, OVERRIDE_PLATFORM_HEADER_NAME=Linux, UBT_COMPILED_PLATFORM=Linux - UNICODE/_UNICODE defines are Windows-only; Linux uses FORCE_U16 char16_t - clang.cmake: -gdwarf/-fPIC on Linux instead of -gcodeview - Gate on WIN32: raw_pdb, UVTD, cppmods, proxy_generator, Win32 system libs - New UE4SS_GUI option gates ImGui/GLFW/glad (headless Linux M1) - Linux links dl + pthread Native configure (clang+Ninja, Game__Shipping__Linux) passes.
- LuaRaw luauser.c: pthread recursive-mutex Lua lock (POSIX branch); Windows CRITICAL_SECTION branch unchanged - ParserBase/IniParser/LuaMadeSimple: add missing <algorithm>/<memory>/ <stdexcept> includes (transitively provided by MSVC headers) - JSON TokenParser: cast stoll result to int64_t (long long is a distinct type from int64_t on LP64, making the Number ctor ambiguous) - printf_s/wprintf_s mapped to printf/wprintf via Linux platform defines (~110 call sites; approach from PR UE4SS-RE#384) - Input: Win32AsyncInputSource compiled/registered only on Windows; GLFW3InputSource and QueueInputSource remain on all platforms
Full FileInterface implementation over open/write/mmap/fstat/unlink: - fd-based handle (int), identifying properties from fstat (dev/inode/mtime/size) replacing the Windows volume/file-index scheme - UTF-16 <-> UTF-8 conversion at the file boundary; read_all does a proper UTF-8 decode (Helpers' to_u16string widens byte-wise and mangles non-ASCII, so LinuxFile carries its own codecvt decode) - serialization cache logic mirrors WinFile.cpp 1:1 tests/: new UE4SS_BUILD_TESTS option + ctest-wired FileTests covering roundtrip (incl. non-ASCII), append, mmap, missing-file throw, delete, nested directory creation. All pass natively.
Pin Palworld Steam build 24088465. PalServer-Linux-Shipping SHA-256: a05788ead7619db22a1509c43241c16d289ed7040e8bcbb2e36e13e223e822f9 ELF build ID: 217802a00653a9c4
|
Note that this PR was made with AI, and is very large, so extreme attention is required, and I have a low confidence level for the quality of these changes. Also note that the author did not disclose the use of AI (unless I missed it somewhere ?), but they also left obvious traces such as the "superpowers" files, and the formatting of the PR description, so I don't think the intention was to hide the use of AI. The PR also contains changes to the now unsupported xmake buildsystem, anyone looking at this PR should ignore those changes. There are also unrelated formatting changes that muddies up the PR. The changes in the UEPseudo repo contain changes to one of the MemberVariableLayout files without corresponding changes to UVTD, this is not allowed because these file are generated by UVTD and will be overridden from time to time. This PR is obviously impossible to merge due to scope, size, and large-scale AI usage, however, it might be a usable reference for actual implementations, with very careful double checking of everything. |
This PR is completely planned and implemented by codex with gpt-5.6-sol + superpowers, and it is still in progress. Though it seems that it is already working on the Palworld Linux server, it is not intended to be merged into the repo. It should be served as a reference of a working implmentation, so I create a draft here mainly for feedbacks and discussions. Regarding the AI usage, I think in 2026, AI generated fixes and features are generally acceptable after careful review (which I will do later, and I may ask for the maintainer's help). Thanks for your feedbacks on the current changes, I will rewrite these parts based on them, and I may have some further questions later. Before making real PRs, I will appreciate if you could give a guideline or suggestions about what should be done first. |
|
Thanks for the reference. We accept AI-based PRs when the creator understands the subjects themselves and just used AI to assist with the coding and tedium. If the user just prompted AI until it worked without understanding anything, we don't really want to merge, because ofc we have AI tools available as well and could do that ourselves but (hopefully) with a more thorough understanding. Will be interested in seeing where this goes. |
|
@tc-imba heads up on a hole in the Linux StartupPolicy, found running your linux-port on a Palworld dedicated server under box64 (ARM64).
const auto* expected_value = std::getenv(TargetExecutableEnv);
if (!expected_value) return {.kind = DecisionKind::LegacyStart};and EntryLinux only skips on TargetMismatch/InvalidLauncherState, so LegacyStart means "init unconditionally". The argv[0] fallback you added for emulated hosts never gets a chance to run. That bites with Palworld's Sentry crashpad_handler. PalServer spawns it with a scrubbed env, so The game itself is fine, it's just the helper process. I'm working around it by making crashpad_handler non-executable, but that's ugly and it makes PalServer log a (non fatal) posix_spawn failure. Not sure what the right fix is on your side. Making LegacyStart not unconditional would need UE4SS to know what the game is, which is the whole point of the var. Maybe the launcher could pass the target through something box64 propagates, or LegacyStart could bail out if argv[0] is clearly a known helper. Your call, just wanted it documented since it's easy to hit on any Unreal game with a crash reporter. |
|
@Shirowwww Resolved in 421411a and a789c17. I traced the failure to marker-free LegacyStart combined with Box64s separate BOX64_LD_PRELOAD list. The Linux constructor now passes its actual loaded module identity into StartupPolicy; when the target marker is missing and BOX64_LD_PRELOAD positively names that UE4SS module, startup fails closed before creating logs, scan threads, or mods and diagnose mode reports reason=box64_target_missing. Native marker-free LD_PRELOAD behavior and marker-present launcher decisions are unchanged. This is intentionally a narrow safety guard rather than full Box64 support; deliberate marker-free UE4SS injection through BOX64_LD_PRELOAD is rejected. The regression coverage exercises exact, basename, symlink, hard-link, unrelated, and marker-precedence cases, plus a real preload process test that verifies no UE4SS.log is created. Final local CTest result: 32/32 configured tests passed, with PalworldSignatureTests retaining its environment-dependent skip. |
Caution
Reference-only draft: this branch was planned and implemented with Codex/GPT-5.6 and superpowers. It has not received complete human line-by-line validation and is not a merge candidate. The purpose of this PR is to preserve a working experiment, collect technical feedback, and identify small changes that can be independently reimplemented and reviewed.
The original description is preserved below as a historical technical record; its merge plan, cleanup commitments, and scope statements are superseded by this notice.
The xmake changes are out of scope because maintainers no longer support that build path. Any real Linux PRs will be recreated from current upstream branches, use CMake only, disclose AI assistance, and contain no unrelated formatting or Palworld-specific product work.
Description
This PR is completely planned and implemented by codex with gpt-5.6-sol + superpowers, and it is still in progress.
This draft publishes my current native Linux port for maintainer review and integration planning. It is intentionally not presented as a request to merge the entire branch into main in one step.
The branch currently contains 38 commits touching 149 files, with approximately 11,378 additions and 779 deletions. The implementation is based on current main and references ideas and earlier investigation from #384 by @Yangff, while adding a fresh implementation, broader automated coverage, process-scoped preload behavior, and live Palworld dedicated-server validation.
Palworld is the binding validation target for this milestone because it provides a real native Unreal Engine 5.1 dedicated-server environment. It is not intended to become a permanent game-specific dependency of the core project. I will clean up the code later, including removing or relocating Palworld-specific contents, test assets, reports, hard-coded validation details, and the separate building-mod design material before a final merge.
What this branch implements
Native Linux build and platform boundary
Linux loading and startup lifecycle
Portable runtime services
Unreal ABI, hooks, and layouts
The main branch depends on a companion UEPseudo branch containing:
ELF discovery and signature resolution
Lua and C++ mod validation
Tests and diagnostics
The branch adds native tests covering, among other areas:
Dependency branches
The main branch currently points at commits published in these forks:
These dependency commits are not yet present in their upstream default branches. A recursive checkout using only the upstream submodule URLs may therefore fail until the dependency changes are reviewed and published upstream, or until an integration workflow temporarily remaps those submodules to the fork branches.
Suggested merge plan
I do not recommend squash-merging this complete draft directly into main. My preferred approach is:
The existing commit order already follows much of this progression and can be used as a starting point for cherry-picking or rebuilding smaller reviewable PRs.
Cleanup and follow-up I intend to do
Before asking for final merge readiness, I intend to:
Current limitations
Review findings that currently block promotion from draft
An independent review of the published branch identified the following issues that should be resolved before this is treated as a generally mergeable Linux implementation:
These findings reinforce the proposed integration-branch approach: dependency reachability, symbol isolation, shutdown safety, hot reload, and ABI scoping should be explicit gates before the Linux integration branch is promoted toward main.
Type of change
How has this been tested?
Fresh verification on the published branch:
Recorded live Palworld dedicated-server evidence is available here:
Those reports document live server startup, signature resolution, hook activity, Lua and C++ mod probes, object/header/USMAP generation, process isolation, and fail-soft behavior. They also clearly identify the remaining manual acceptance work.
Checklist
Screenshots
Not applicable; the current Linux milestone is headless.
Additional context
This draft is primarily asking maintainers for direction on:
I am happy to reorganize the branch around the maintainers' preferred merge sequence before requesting full review.