Skip to content

Stop shipping NaCl IRT and build it alongside gamelogic instead? #1993

Description

@slipher

So the irt_core nexe is untrusted code in the Native Client sandbox implementing mostly the equivalent of libc syscall wrappers for the NaCl VM, plus some other libc stuff like pthreads and malloc. I believe it is treated the same as any other untrusted code by the sandbox. (There are some examples in the NaCl repo's tests/barebones/ showing how VM syscalls can be done without the library.) So we might consider ditching the IRT nexe shipped with the engine, and instead build it into each gamelogic binary. This would let us reach the goal of building a Daemon engine without binary blobs much more simply than if we had to build irt_core. To build everything we need from native_client the normal way you need to set up 3 toolchains:

  • Target platform native code toolchain for sel_ldr
  • NaCl toolchain(s) to build irt_core_raw
  • Host-mode toolchain to build the tls_edit tool which transforms irt_core_raw into irt_core (only actually needed for 32-bit targets)

If we build the IRT files as normal gamelogic files, the latter two toolchains would no longer needed to produce a built-from-scratch Daemon release. I'm assuming that tls_edit is only needed for the case where the code is loaded like a shared library, and not if it's built into the main binary.

If my assumptions are correct the steps to do this would be:

  • Add Native Client as a submodule
  • Add the IRT source files there into any gamelogic build
  • Remove the -B <irt_core path> flag from the nacl_loader invocation

Obviously the reason to have the IRT in the first place is to save compile time and disk space for those distributing nexe binaries. The irt_core-amd64.nexe we currently ship is 623K. But Bloaty says 46% of that is debug info. Strip that as our build process normally does, perhaps remove some unused parts while linking, and it's maybe a couple hundred KB. Plus Breakpad debug info for the IRT would be generated in the normal build process.

Building an irt_core_raw with Saigo single-threadedly took 0.94 s for me excluding build system overhead. (I got Total command execution time: 0.938376 seconds using the Scons --debug=time option.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions