Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Native Client definitions #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

illwieckz
Copy link

Hi, this updates the Native Client definitions.

To understand it better, here is some generic knowledge about the Native Client ecosystem.

The various toolchains produced different kind of binaries:

  • nexe: architecture-dependent executable.
  • pexe: architecture-independent executable, meant to be translated to nexe before execution using a special tool.

A PNaCl compiler produces pexe executable, while an NaCl compiler produces nexe executable.

While the pexe format can be seen as a kind of platform, in practice there is no runner for it: a pexe should be translated to nexe to be executed by the NaCl loader.

There has been at least 5 Native Client compilers:

The PNaCl Clang compiler and the NaCl Clang compiler share the same repository and are both part of the PNaCl Clang project, I listed them separately because the different binaries produce different defines.

Here is some knowledge I gathered:

Among all the compilers I tested (all but PNaCl GCC), only PNaCl Clang sets the __pnacl__ definition.

All the compilers I tested (all but PNaCl GCC) set the __native_client__ definition, so this is a better one to detect Native Client than __pnacl__.

I have found some __native_client__ and some __pnacl__ usage in some header files in the PNaCl GCC source directory. So maybe the __pnacl__ is usable to detect a pexe compiler.

According to this comment, 10 years ago PNaCl Clang was built on Ubuntu 12.04 and developed on Ubuntu 14.04, so I guess the 13 years old PNaCl GCC requires an environment as old as that to be built, if not older. It's very unlikely the PNaCl GCC can be faced in the wild.

In real life, finding the __pnacl__ definition means the PNaCl Clang compiler is used.

The Saigo compilers sets the __saigo__ definition.

Among the users of Native Client today we can list:

  • Google (assumed to still be using it if they funded the development of a new toolchain and are still funding the maintenance of it, but I don't know what they do with it, maybe some chrome apps…).
  • The Dæmon game engine powering the Unvanquished game, using Native Client as the sandbox to run downloaded custom mods. We are migrating from PNaCl to Saigo, and I thought I could share some knowledge. 😉️

Summary:

  • NaCl GCC
    • __native_client__
  • PNaCl GCC
    • supposedly __native_client__ (unverified)
    • supposedly __pnacl__ (unverified)
  • PNaCl Clang
    • __native_client__
    • __pnacl__
  • NaCl Clang
    • __native_client__
  • Saigo
    • __native_client__
    • __saigo__

While it is true facing a __pnacl__ definition means this a Native Client architecture being targeted, not all NaCl compilers set it, it is better to use __native_client__ instead.

So…

  • I've kept the “PNaCl” architecture even if it doesn't sound that useful.
  • I've added the “Native Client” architecture which is much more useful.
  • I've added the “Saigo” compiler.
  • I haven't made a difference between the PNaCl Clang and the NaCl Clang in the description, as they're just different binaries from the same source. It is still true that binaries from the PNaCl Clang project producing nexe are defining __native_client__.

@a1batross
Copy link
Member

Maybe move PNaCl definition to the Native Client and add it's identification macro as something specific to PNaCl? While it's technically different binaries, they seem to be part of the same tech. Or make them interlinked instead, because somebody interested in Native Client might be interested in PNaCl as well and vice versa.

Also, it might make sense to add a note to the Saigo that it's Clang-based and therefore also defines everything Clang/LLVM does?

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.

2 participants