[pypy-svn] r58586 - in pypy/dist/pypy: doc rlib
hpk at codespeak.net
hpk at codespeak.net
Fri Oct 3 13:11:31 CEST 2008
Author: hpk
Date: Fri Oct 3 13:11:29 2008
New Revision: 58586
Modified:
pypy/dist/pypy/doc/maemo.txt
pypy/dist/pypy/rlib/pyplatform.py
Log:
a write up of how i got a clean, controlable working cross-compilation environment.
There might be better ways (i still hope we can reuse the Maemo-provided install
scripts which i mentioned further down in the doc) but for now this provides
a sane enough way to get a cross-compilation environment, i guess.
Modified: pypy/dist/pypy/doc/maemo.txt
==============================================================================
--- pypy/dist/pypy/doc/maemo.txt (original)
+++ pypy/dist/pypy/doc/maemo.txt Fri Oct 3 13:11:29 2008
@@ -8,6 +8,122 @@
cross-compile pypy to maemo platform emulator under qemu. Note that this
is work-in-progress.
+
+Variant 0: cross-compiling pypy-c
+------------------------------------------
+
+The basic idea is to install a scratchbox environment that emulates
+a real ARM-based N810 device. One can then login to this virtual
+environment and execute ARM binaries. Scratchbox also provides
+compiler toolchains that allow to drive a compiler from the outside.
+This is what we want for building pypy-c because most work happens
+independently from the platform and we want this work to execute natively.
+For all platform relevant details we need to consult the target environment
+and use the cross-compiler. So now let's move on to install such an environment
+and compiler.
+
+Note: the
+
+ http://repository.maemo.org/stable/diablo/maemo-scratchbox-install_4.1.1.sh
+
+script is provided by the maemo team and would automate installation.
+Unfortuantely it does not provide a working cross-compiler (XXX
+mail to maintainers and see if there is an easy fix).
+
+creating a /scratchbox environment
++++++++++++++++++++++++++++++++++++++++++
+
+The basic idea is to follow
+
+ http://www.scratchbox.org/documentation/user/scratchbox-1.0/html/tutorial.htm#
+
+with tarballs that work for the N810/Maemo target.
+
+make yourself an empty ``work`` directory and get a
+working set of tarballs, e.g. like this::
+
+ export GET='wget -c'
+ export URL='http://www.scratchbox.org/download/files/sbox-releases/apophis/tarball'
+ $GET $URL/scratchbox-core-1.0.11-i386.tar.gz
+ $GET $URL/scratchbox-libs-1.0.11-i386.tar.gz
+ $GET $URL/scratchbox-toolchain-cs2007q3-glibc2.5-arm7-1.0.8-6-i386.tar.gz
+ $GET $URL/scratchbox-devkit-cputransp-1.0.7-i386.tar.gz
+ $GET $URL/scratchbox-devkit-perl-1.0.4-i386.tar.gz # for autoconf
+ $GET $URL/scratchbox-devkit-svn-1.0-i386.tar.gz # for being able to checkout
+ #$GET $URL/scratchbox-devkit-debian-1.0.10-i386.tar.gz # to eventually get debian working
+
+unpack all those tarballs, e.g. like this::
+
+ for x in *.tar.gz ; do sudo tar zxvf $x; done
+
+now you should have a ``work/scratchbox`` directory containing your basic uninitialized
+scratchbox environment.
+
+make a symlink to have scratchbox at the canonical location::
+
+ ln -s /path/to/work/sandbox /sandbox
+
+initilaize the scratchbox install (you should be fine with using default answers to any questions)::
+
+ /scratchbox/run_me_first.sh
+
+NOTE, that this will implicitely start some services that generally are controlled via::
+
+ /scratchbox/sbin/sbox_ctrl stop|start
+
+So if you later want to play with multiple different scratchbox installations you should stop the services before moving them away. You can also try to link this script into your ``/etc/init.d/`` so that it automatically runs after a reboot.
+
+Now create a user::
+
+ /scratchbox/sbin/sbox_adduser USER yes
+
+the 'yes' means that the USER gets added to the sbox unix group, neccessary to login into the virtual environment.
+
+
+Creating an target emulating N810/Maemo environment
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+Now we instruct scratchbox to define a target suitable for emulating the N810/Maemo device::
+
+Login to the virtual environment and invoke :
+
+ /scratchbox/login
+ sb-menu
+
+this brings up an interactive menu, you need to *setup* a new target,
+you may name it "ARMEL" and then you need to select
+
+ compiler: cs2007q3-glibc2.5-arm7
+ devkits: cputransp, perl, svn
+ cputransp: (select 'qemu-arm-0.8.2-sb2' when it asks later on)
+
+In theory, you should also be able to execute the following cmdline::
+
+ sb-conf setup armel --compiler=cs2007q3-glibc2.5-arm7 \
+ --devkit=cputransp:perl:svn \
+ --cputransp=qemu-arm-0.8.2-sb2
+
+but this did not provide a complete environment for me (XXX try to fix).
+
+Congrats! If all worked well you should now be able to cross-compile C programs via:
+
+ /scratchbox/compilers/cs2007q3-glibc2.5-arm7/bin/arm-none-linux-gnueabi-gcc
+
+and copy the binary result to the N810/Maemo device. You can also login to
+the virtual environment and execute the ARM binary there.
+
+PyPy's translation tool chain tries to use this cross-compiler when
+you specify ``--platform=maemo`` to the translate.py script.
+
+So you can now get yourself a copy of pypy (in the hosting, not the
+virtual environment of course!) and do:
+
+ python translate.py --batch --platform=maemo --opt=mem \
+ targetpypystandalone.py --no-allworkingmodules
+
+copy the result to the device and run it.
+
+
variant 1: Installing `scratchbox`_
-------------------------------------------
Modified: pypy/dist/pypy/rlib/pyplatform.py
==============================================================================
--- pypy/dist/pypy/rlib/pyplatform.py (original)
+++ pypy/dist/pypy/rlib/pyplatform.py Fri Oct 3 13:11:29 2008
@@ -27,7 +27,13 @@
class Maemo(Platform):
def get_compiler(self):
# XXX how to make this reliable???
- return '/scratchbox/compilers/cs2005q3.2-glibc-arm/bin/sbox-arm-linux-gcc'
+ for x in (
+ '/scratchbox/compilers/cs2007q3-glibc2.5-arm7/bin/arm-none-linux-gnueabi-gcc',
+ '/scratchbox/compilers/cs2005q3.2-glibc-arm/bin/sbox-arm-linux-gcc',
+ ):
+ if py.path.local(x).check():
+ return x
+ raise ValueError("could not find scratchbox cross-compiler")
def execute(self, cmd):
return py.process.cmdexec('/scratchbox/login ' + cmd)
More information about the Pypy-commit
mailing list