From: najem@milton.cs.uiuc.edu (Ziad Najem)
Newsgroups: comp.os.linux
Subject: Re: Problems making Common LISP
Date: 27 Sep 92 20:13:45 GMT
Article-I.D.: m.1992Sep27.201345.15010
Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL

rafal@utstat.uucp (Rafal Kustra (summer student)) writes:

>In article <YelJ74W00Uh7M5k0x8@andrew.cmu.edu> you write:
>>Hello all,
>>
>>Well, I'm taking another one of those wonderfull CS courses here at CMU,
>>and just happen to be using Common Lisp (my early oppinnion - I hate it
>>:-)  Anyways, I was happy to hear that there was a version of CL on TSX.
>> So I went a FTP'd it earlier tonight.  I read the little README. and
>>attempted to make the runnable file.  However, GCC (2.2.2d) complained
>>that _setjmp was undefined and being referenced from an external text
>>segment.  Could someone give me the command line arg to GCC to tell it
>>how/where to find the jump table stuffs?
>>
>>Thanks,
>>
>>-Scott
>>
>>Scott Grabowski                +  "I don't pretend to understand women's
>>sg2j@andrew.cmu.edu            +  little quirks, just one thing I know for
>>Physics is Phun!               +  sure, chicks dig jerks."  - Marblehead
>>Johnson!

>setjmp was changed from function (gcc 2.2.2) to
>macro (gcc 2.2.2d). So if you installed your 2.2.2d on
>top of 2.2.2 correctly ( and still got old setjmp.h in 
>.../i-386-linux/2.2.2/include) you should add 
>-V 2.2.2
>when compiling it. Of course, that means that you won't
>be able to use jump tables, so it might be better to
>change the code itself. (look in headers).

>				Rafal

Since clisp was provided as .a file, recompilation is not possible.
The solution would be to provide setjmp externally. Here is what B.
Haible (the author of clisp) emailed few days ago. 

 - Ziad
   najem@cs.uiuc.edu


		  ----- Begin Include Message -----


Date: Fri, 25 Sep 92 00:45:42 +0200
From: haible@ma2s2.mathematik.uni-karlsruhe.de (Bruno Haible)
Subject: Re: linking clisp


Dear CLISP users,

Some of you have had problems when linking lisp.a with the libc
coming with gcc 2.2.2d. In case "setjmp" is missing from that
library, here is the source of setjmp() from some older libc:

============================= setjmp.s =========================
/*
 * setjmp & longjmp for gcc.
 *
 * We need to save all regs except %eax,%ecx,%edx, as these are
 * used by calls.
 *
 * Jump buffer looks like this (same as bruce evans for minix):
 *
 * 00: %ebp
 * 04: %esp
 * 08: %eip
 * 0C: %ebx
 * 10: %esi
 * 14: %edi
 *
 * Total length hex 18 = 24 bytes.
 */

.text
.globl _setjmp,_longjmp
.align	2
_setjmp:
	popl %ecx		# get return address
	movl 0(%esp),%edx	# and jump buffer address
	movl %ebp,0(%edx)
	movl %esp,4(%edx)
	movl %ecx,8(%edx)
	movl %ebx,12(%edx)
	movl %esi,16(%edx)
	movl %edi,20(%edx)
	xorl %eax,%eax		# non-jump return
	jmpl *%ecx

.align	2
_longjmp:
	movl 4(%esp),%edx	# jump buffer address
	movl 8(%esp),%eax	# val
	cmpl $1,%eax		# Value may not be zero (code by bruce?)
	adcb $0,%al		# nice code, somewhat cryptic, no?
	movl 0(%edx),%ebp	# restore %ebp
	movl 4(%edx),%esp
	movl 12(%edx),%ebx
	movl 16(%edx),%esi
	movl 20(%edx),%edi
	jmp 8(%edx)
=========================================================

Assemble it:

        gcc -c setjmp.s

and use setjmp.o for linking:

      gcc lisp.a setjmp.o -L. -lreadline -ltermcap -s -o lisp.run

I hope this solves this problem.

Bruno Haible
haible@ma2s2.mathematik.uni-karlsruhe.de