changelog shortlog tags changeset files revisions annotate raw

bin/Qemu pseudo-crosscompiler

changeset 754: d39e613e8266
parent:c42c0b86a604
author: Gregor (codu.org)
date: Mon Jan 03 22:11:26 2011 +0000 (16 months ago)
permissions: -rwxr-xr-x
description: medit/bin/N-in-a-row game chebang=#!/usr/bin/env .wiki cont=This is an idea for a game which:

* Is entirely non-random
* Has no hidden information
* Involves strategy
* Is playable by normal humans
* Has an infinite state-space
* Is hopefully fun
* Is generally unsolvable
** Although it may be solvable when restricted to "reasonable" board sizes

The basic idea is:

* The gameboard is an infinite grid
* One player starts by placing a single X anywhere
* The second player must get two Os in a row within f(1) turns (f to be defined)
* Generally, if you get N in a row, then the opponent has f(N) turns to get N+1 in a row or you win. Then it repeats when they have N+1
* You can also get N+1 in a row yourself, in which case the counter resets with you still in the winning position.

Open questions:

* What is f?
* Can you place your symbol anywhere, or only next to the existing game?

Of course, the most vital part is the definition of f, and we're not yet sure what to do with that.
1#!/usr/bin/env .wiki
2Qemu has user binary emulation for numerous platforms. As a result, you can use debootstrap to create a chroot for a host platform, then actually chroot into it! If you're really sneaky, you can set up certain binaries (e.g. the compiler) to be compiled for the host, so that you can compile fast, but also compile software that's not cross-compiler-aware. And here's how!
3
4(Note: I've tested this with arm/armel and ppc/powerpc. The instructions below are for powerpc, since I wrote them after I'd already gotten arm working, and as I was getting PPC working)
5
6# You must have Qemu installed to some path other than /usr, such as /opt/qemu. I will use /opt/qemu throughout this text.
7# You must have set up qemu-binfmt-conf.sh to use the Qemu installed to /opt/qemu, and run it. Note: With MIPS in particular it was also necessary to create a symlink in /opt/qemu/bin from qemu-mipsn32 to qemu-mips. I have no idea why qemu-binfmt-conf.sh thinks that qemu-mipsn32 exists, or why a different ABI would require a different emulator. Anyway, it works this way.
8# Make a static version of the relevant Qemu user emulation binary: {{{cd .../qemu; CFLAGS="-O2 -g -static" LDFLAGS=-static ./configure --prefix=/opt/qemu --target-list=ppc-linux-user; make}}}
9# Now we start preparing the target directory. I used /usr/gnemul/debian-ppc to keep it near /usr/gnemul/qemu-ppc. Note that you CAN NOT use /usr/gnemul/qemu-ppc as your debootstrap chroot, but it doesn't have to be in /usr/gnemul. Copy in the qemu binary: {{{mkdir -p /usr/gnemul/debian-ppc/opt/qemu/bin; cp -a .../qemu/ppc-linux-user/qemu-ppc /usr/gnemul/debian-ppc/opt/qemu/bin}}}
10# Now, debootstrap into the target directory. {{{debootstrap --arch powerpc lenny /usr/gnemul/debian-ppc}}} Barring weird failures, you will now have a working, chroot-able Debian. With ARM I had to copy in a static version of /bin/rm compiled for the host architecture due to missing syscalls in qemu. With PPC I needed both a static version of /bin/rm AND a static version of dpkg! In short, you may or may not have to copy stuff in to make it all work, but it's assumed that what's failing will be fairly obvious, and so the solution will be clear (just build the proper thing as static for the host). For dpkg in particular, after running configure, edit config.h such that it thinks it's the target platform.
11(To be continued)