I just went through this exercise for my own purposes, thought some of you might be interested. It's certainly easier than trying to find and maintain sparc/ppc/mips hardware/software.
1. Install MIPS compiler and runtime library, and qemu-mips:
1 18:23 sudo apt-get install gcc-multilib-mips-linux-gnu 3 18:26 sudo apt-get install gcc-mips-linux-gnu 5 18:26 sudo apt-get install qemu-user
2. Clone Gambit, build boot/ and gsc-boot:
9 18:28 git clone https://github.com/gambit/gambit.git 10 18:28 cd gambit 11 18:28 ./configure 12 18:29 make -j8 core
3. Reconfigure Gambit to build a cross-compiled MIPS version:
15 18:35 ./configure --host=mips-linux-gnu
4. Build a MIPS gsi/gsi and gsc/gsc:
16 18:35 make clean 18 18:36 make -j8 core
5. Test gsi/gsi with qemu-mips, telling qemu-mips where to find MIPS version of ld.so.1:
49 18:56 qemu-mips -L /usr/mips-linux-gnu/ gsi/gsi
6. Run a unit test:
69 19:14 qemu-mips -L /usr/mips-linux-gnu/ gsi/gsi tests/unit-tests/03-number/_num.scm
7. Check that it really is a MIPS binary:
72 19:22 file gsi/gsi
Output:
gsi/gsi: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld.so.1, BuildID[sha1]=c434b85ac605107cc0a7d45ba0f12e70243113ca, for GNU/Linux 3.2.0, not stripped
8. Get some silly timings:
heine:~/programs/gambit/big-endian/gambit> qemu-mips -L /usr/mips-linux-gnu/ gsi/gsi Gambit v4.9.5-206-g42e51d68
(define a (time (expt 3 1000000)))(define b (time (* a a)))
(time (expt 3 1000000)) 0.879048 secs real time 0.877924 secs cpu time (0.876923 user, 0.001001 system) 3 collections accounting for 0.003398 secs real time (0.003400 user, 0.000001 system) 3257548 bytes allocated 1930 minor faults no major faults
(time (* a a))
0.973768 secs real time 0.972830 secs cpu time (0.972827 user, 0.000003 system) 1 collection accounting for 0.001181 secs real time (0.001180 user, 0.000001 system) 4524200 bytes allocated 2055 minor faults no major faults
The corresponding native binary:
heine:~/programs/gambit/big-endian/gambit> gsi Gambit v4.9.5-204-g79fcaed1
(define a (time (expt 3 1000000)))(define b (time (* a a)))
(time (expt 3 1000000)) 0.018802 secs real time 0.016549 secs cpu time (0.015181 user, 0.001368 system) 2 collections accounting for 0.000659 secs real time (0.000591 user, 0.000070 system) 3295704 bytes allocated 1764 minor faults 1 major fault 67505646 cpu cycles
(time (* a a))
0.016171 secs real time 0.016149 secs cpu time (0.013784 user, 0.002365 system) 1 collection accounting for 0.000319 secs real time (0.000000 user, 0.000319 system) 4524224 bytes allocated 2050 minor faults no major faults 58058052 cpu cycles
And I added -save-temps to the makefile command to compile lib/_num.c to see that yes, this really is a big-endian version of _num.i.
Pretty cool!
Brad