Skip to content

Emulate NaCl with box64 for unsupported platforms#1946

Merged
illwieckz merged 1 commit intoDaemonEngine:masterfrom
runlevel5:poc-box64-nacl
Mar 30, 2026
Merged

Emulate NaCl with box64 for unsupported platforms#1946
illwieckz merged 1 commit intoDaemonEngine:masterfrom
runlevel5:poc-box64-nacl

Conversation

@runlevel5
Copy link
Copy Markdown
Contributor

@runlevel5 runlevel5 commented Mar 27, 2026

For platform that does not support NaCl, it is feasible to use emulator like box64 to run the x86_64 NaCl version. There might be some edge cases that I am not aware of, however for most common paths I could verify the game load and join online game successfully.

NOTE: this works with architecture that supports LE, that is Little Endian because it will share the same structs. To be honest I would not care about BE because box64 does NOT support BE at all. Plus BE platform like PPC64 BE is dying as IBM has been pushing hard on LE solely.

Demo video: https://youtu.be/kwo_nOYiiTI

@illwieckz
Copy link
Copy Markdown
Member

Awesome! That is very good! I will probably try this on RISC-V at some point. 😎️

@illwieckz
Copy link
Copy Markdown
Member

illwieckz commented Mar 27, 2026

NOTE: this PoC only works with PPC64 LE, that is Little Endian because it will share the same structs. To be honest I would not care about BE because box64 does NOT support PPC64 BE at all. Plus BE is dying as IBM has been pushing hard on LE solely.

Yes, BE is dying. If you can make BE ppc64 running a native server that's more than enough for BE.

If you can get LE ppc64 running with a compat layer for the nacl loader, that seems acceptable to me.

It wouldn't be that different than a FreeBSD engine running the Linux NaCl loader, or the arm64 engine running the armhf NaCl loader…

@runlevel5 runlevel5 force-pushed the poc-box64-nacl branch 2 times, most recently from 5e531e5 to 27fa290 Compare March 28, 2026 01:34
@illwieckz
Copy link
Copy Markdown
Member

illwieckz commented Mar 28, 2026

That's excellent! I modified a bit your patch on my side to make it work as well on riscv64, and I could load the client. Performance on riscv64 was so atrocious I couldn't join a server because it timed out, but the nexe code runs!

@runlevel5
Copy link
Copy Markdown
Contributor Author

Performance on riscv64 was so atrocious I couldn't join a server because it timed out, but the nexe code runs!

I bet there are unoptimized codes on RV64 backend of box64, some opcodes might have fallen back to interpreter which is slow. What hardware are you using?

@runlevel5
Copy link
Copy Markdown
Contributor Author

@illwieckz I've just amended the PR to make it more generic

@runlevel5 runlevel5 marked this pull request as ready for review March 28, 2026 09:34
Copy link
Copy Markdown
Member

@illwieckz illwieckz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good to me for now.

We can improve over it later.

@illwieckz
Copy link
Copy Markdown
Member

@runlevel5 please rename properly your commits (like removing the PoC: prefix), and squash if some commits need it.

We don't request peoples to squash commits (we don't enforce 1 PR = 1 commit) and we in fact do appreciate detailed git history, but given this branch was an iterative work with some trials, you may have things you want to squash. 🙂️

Once you've tidied the history just tell me I'll merge the branch.

Thank you very much for making the Dæmon engine and the Unvanquished game better ! ☺️

@runlevel5 runlevel5 changed the title [PoC] Emulate NaCl with box64 for unsupported platforms Emulate NaCl with box64 for unsupported platforms Mar 29, 2026
Run x86_64 NaCl loader and amd64 .nexe game modules under Box64
emulation on platforms without native NaCl support. The native engine
communicates with the emulated NaCl sandbox processes via
architecture-independent Unix domain socket IPC, requiring no changes
to game modules.

- Add opt-in DAEMON_NACL_BOX64_EMULATION CMake option (OFF by default,
  Linux only) that remaps NACL_ARCH to amd64
- Replace architecture-specific NaCl dummy defines with a generic
  fallback for any unsupported architecture
- Prepend box64 to NaCl loader args with PATH resolution
- Skip bootstrap helper (incompatible with Box64 double-exec)
- Disable platform qualification for emulated loader
- Add cvars: vm.box64.path, workaround.box64.disableBootstrap,
  workaround.box64.disableQualification
@illwieckz illwieckz merged commit 2e5b685 into DaemonEngine:master Mar 30, 2026
9 checks passed
@runlevel5 runlevel5 deleted the poc-box64-nacl branch March 30, 2026 22:08
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.

3 participants