Pseudo Native Compiler

From RockWiki

Jump to: navigation, search

The Pseudo-Native-Compiler is our solution to the lack of sufficiently fast hardware donations - it cross-compiles as much as possible, delegating only the absolute minimum of required executable calls to the target architecture (via network). In this document, the machine doing most of the work (probably an x86 or so) will be called the 'big' machine, and the target native host (probably a m86k or arm or mips or... whatever) will be called the 'slow' machine.

How to Configure

in scripts/Config, configure the build for the slow machine (for example ARM, xscale CPU, armv5te arch). Forget the 'this is a cross-build option', instead enable the following option:

  <*>        This is a pseudo-native cross-build

disregard the warning (this is the documentation ;) and configure the following two options:

  <192.168.0.3 > IP of native host for command forwarding

enter the ip of the slow machine (in this case the ARM box), where you will start pseudonative_daemon later on.

  <192.168.0.2:/home/rock> NFSROOT to be mounted on native host

here you should enter the IP address of the big machine, followed by a colon and the absolute path to the rock tree on the big machine. it's used by the slow machine later on to NFS-mount the rock directory.

Now configure which system to build as usual. I recommend you start with target 'generic' and the 'minimal' Package-Preselection (to be found in the export options) to make sure your setup works. Don't forget to run ./scripts/Download -cfg <yourconfigname> -required.

How does it work?

After you configured your pseudonative build, make sure the binfmt_misc module is loaded on the big machine, because the build tools automagically

  • register a binfmt_misc handler with the elf header of the target architecture
  • set pseudonative_handler as handler for this binfmt_misc (once it is compiled)

you need to start pseudonative_daemon without any arguments (or maybe with -d for debug) on the slow machine (as root) now. It can be found in package/fake/pseudonative_daemon. it's only one .c file, so it shouldn't take long to compile it.

make sure your rock source tree is correctly configured to be r/w accessible via NFS by the slow machine, so it can mount and modify it. best is to simply try and mount it. you need portmap running... for example add the following line to /etc/exports on the big machine

  /home/rock       192.168.0.3(rw,no_root_squash,async)

start the nfsd (rc portmap start ; rc knfsd start), start your build as you would usually, and watch the pseudonative daemon's output. it probably takes some time, but sooner or later - though not before stage 1 - a native program will be called, and you should see some output from the very noisy pesudonative_daemon on the target machine.

the build tools will build and use a big-machine-native version of - for example - perl and gcc instead of the slow-machine-native versions.

note that pseudonative_daemon is not secure. it's far, _far_ from being secure. one could say, it's _the_ anti-security tool. Anyone can run any command anywhere on the target machine, as the user you started pseudonative_daemon with - which should be root, to be able to chroot into the NFS-mounted environemnt. So it's not intended to be used on untrusted networks, let alone over the internet. If you still need to know the port number it uses, as well as the protocol, have a look at misc/tools-source/pseudonative_handler.c and package/fake/pseudonative_daemon, there are defines for the packet types and the port used - and a lot of more information about the internals - all information, really ;o)

Personal tools