From: Kaz K. <kky...@gm...> - 2009-01-10 23:24:56
|
Hi all, I'm cross-compiling CLISP 2.45 on an Intel Linux box, targetting a MIPS Linux system with the n32 ABI. I had to patch a few things to get as far as making a lisp.run executable, linked with all the goodies: sigsegv, ffcall. (After making lisp.run, the Makefile then bails: it wants to update the interpreted.mem target, and of course makemake doesn't generate such a rule, since running lisp.run to make interpreted.mem is impossible under cross-compiling. It's probably trying that target only because I invoked make wrong; I gave it no specific target). It's obvious from the Makefile that that there are some cross-compiling rules which require a clisp that is compiled to run on the build machine. This clisp is to be used as a cross compiler. The rules require the presence of a special memory image: "clisp -M cross.mem", and in this image there is supposed to be a function named CROSS:COMPILE-FILE which is invoked using a -x argument. Problem is, there isn't any rule to make cross.mem, nor do there appear to be any materials from which it would be made! Do share the secret! Patches: This is needed because the my 2.6.26 asm-mips/sigcontext.h kernel header tries to define struct sigcontext, which clashes with what has already been pulled in from a glibc header. Index: libsigsegv-2.5/src/fault-linux-mips.h =================================================================== --- libsigsegv-2.5.orig/src/fault-linux-mips.h 2005-05-20 12:47:21.000000000 -0700 +++ libsigsegv-2.5/src/fault-linux-mips.h 2009-01-15 07:47:10.850946160 -0800 @@ -15,8 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include <asm/sigcontext.h> - #define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp #define SIGSEGV_FAULT_CONTEXT scp #define SIGSEGV_FAULT_STACKPOINTER scp->sc_regs[29] Next are CLISP patches. Firstly, if the architecture happens to be mips64-*, that doesn't necessarily mean that the 64 bit ABI is being used. I have a compiler called mips64-linux-gcc, but I'm using it with the n32 ABI, which is default. So I hacked an ABI check into makemake. It's not a perfect solution, because it relies on inspecting the compiler's default ABI, which could be overridden by CFLAGS, or maybe the contents of COMPILER itself. It would be better to have a configure parameter for selecting the ABI. All of this has to do with the arithmetic module, arimips.d and arimips64.d. In the next hunk, we deal with the bug with comment5. It's being linked against a gllib/malloc.o, which is a MIPS object file. We need comment5 to be a build machine tool. Rather than compile malloc.c again to a build machine .o, I just patched things so that the .c file is passed to the compiler when building comment5. It's a trivial small thing; no harm in compiling it a few times over again. The next hunk addresses the problem that I got unresolved symbols, because the final link didn't include the ffcall libraries. In makemake, a FFCALL_LIBS variable is defined, but not used! The last change is a hack to get around the problem that the arithmetic assembly file arimips.s was being compiled with /bin/as. This is because TSYSOS is not simply "linux", but "mips-gnu-linux-none" or something like that. This comes in as a parameter when configure runs makemake. I just blew away that logic so it unconditionally uses the cross GCC. =================================================================== --- clisp-2.45.orig/src/makemake.in 2008-05-08 18:22:01.000000000 -0700 +++ clisp-2.45/src/makemake.in 2009-01-15 17:39:58.309870528 -0800 @@ -1048,7 +1048,22 @@ cpu=mips fi if [ "$host_cpu" = mips64 ] ; then + # cpu value depends on ABI, which we get from the compiler if it's GCC cpu=mips64 + case "$COMPILER" in + *gcc*) + for config in `$COMPILER -v 2>&1` ; do + case "$config" in + --with-abi=*32 ) + cpu=mips + ;; + --with-abi=*64 ) + cpu=mips64 + ;; + esac + done + ;; + esac fi if [ "$host_cpu" = i386 -o "$host_cpu" = i486 -o "$host_cpu" = i586 -o "$host_cpu" = i686 -o "$host_cpu" = i786 -o $TSYS = i386 -o $TSYS = i486 -o $TSYS = i586 -o $TSYS = i686 -o $TSYS = i786 -o $TOS = win32 ] ; then cpu=i386 @@ -1501,7 +1516,8 @@ if [ ${HAVE_MALLOC_POSIX} = 0 -o ${CROSS} = true ]; then # gnulib/stdlib.h will define malloc to rpl_malloc, so we need this GLLIB_O=gllib/malloc${TOBJ}; GLLIB=gllib/malloc - EXTRAOBJ=" gllib/malloc${TOBJ}" + EXTRAOBJ=" ${SRCDIR}/gllib/malloc.c" + CPPFLAGS="${CPPFLAGS} -I." else GLLIB_O=""; GLLIB=""; EXTRAOBJ=""; fi for f in localcharset uniname/uniname uniwidth/width; do @@ -1915,7 +1931,7 @@ echol "XCFLAGS = ${XCFLAGS}" echol "XCPP = ${XCPP}" echol "XCLFLAGS = ${XCLFLAGS}" - echol "XLIBS = ${LIBS}" + echol "XLIBS = ${LIBS} ${FFCALL_LIBS}" XCC="\$(XCC)" XCPPFLAGS="\$(XCPPFLAGS)" XCFLAGS="\$(XCFLAGS)" @@ -2746,16 +2762,11 @@ # Only the native as groks the .SHORTDATA statements in arihppa.d echotab "${XCC} ${XCPPFLAGS} ${XCFLAGS} -c ${f}.s || /usr/ccs/bin/as ${f}.s -o ${f}${TOBJ} || /bin/as ${f}.s -o ${f}${TOBJ}" else - if [ $f = arimips -a "$TSYSOS" != linux ] ; then - # Avoid problem during incremental linking of lisp.o. - echotab "/bin/as -KPIC ${f}.s -o ${f}${TOBJ} || /usr/ccs/bin/as -KPIC ${f}.s -o ${f}${TOBJ}" - else if [ $XCC_GCC = true ] ; then echotab "${XCC} ${XCPPFLAGS} ${XCFLAGS} -x assembler -c ${f}.s" else echotab "${XCC} ${XCPPFLAGS} ${XCFLAGS} -c ${f}.s" fi - fi fi echol fi |