Subject: [clisp-list] avcall on sparc

From: Will Newton <[email-masked]>
Date: Wed Mar 20 19:46:03 2002

I am seeing a problem building on sparc with gcc (Solaris and Linux). avcall 
fails it's structure tests, but I believe I have found a solution.

When compiling with -O2 or better, the configure test for pcc non-reentrant 
struct return convention is optimized away and always returns true. This 
causes avcall to believe it can use PCC but it cannot - and so bad things 
happen.

I have attached a patch I believe fixes the issue, by clearing CFLAGS before 
running the test:

--- aclocal.m4.old      Thu Mar 21 03:10:02 2002
+++ aclocal.m4  Thu Mar 21 03:11:43 2002
@@ -838,6 +838,8 @@
 dnl
 AC_DEFUN(CL_PCC_STRUCT_RETURN,
 [AC_CACHE_CHECK([for pcc non-reentrant struct return convention], 
cl_cv_c_struct_return_static, [
+save_CFLAGS="$CFLAGS"
+CFLAGS=""
 AC_TRY_RUN([typedef struct { int a; int b; int c; int d; int e; } foo;
 foo foofun () { static foo foopi = {3141,5926,5358,9793,2385}; return foopi; 
}
 foo* (*fun) () = (foo* (*) ()) foofun;
@@ -854,6 +856,7 @@
 dnl When cross-compiling, don't assume anything.
 dnl There are even weirder return value passing conventions than pcc.
 cl_cv_c_struct_return_static="guessing no")
+CFLAGS="$save_CFLAGS"
 ])
 case "$cl_cv_c_struct_return_static" in
   *yes) AC_DEFINE(__PCC_STRUCT_RETURN__) ;;

---

From: Sam Steingold <[email-masked]>
Date: Thu Mar 21 07:46:07 2002

> * In message <[email-masked]>
> * On the subject of "[clisp-list] avcall on sparc"
> * Sent on Thu, 21 Mar 2002 03:46:18 +0000
> * Honorable Will Newton <[email-masked]> writes:
>
> I am seeing a problem building on sparc with gcc (Solaris and Linux).

I think the problem is only on Solaris with gcc3.
I do not observe it on rh7.2 with either gcc 2.96 or gcc 3.0.4.

> avcall  fails it's structure tests, but I believe I have found a solution.
thanks!

> When compiling with -O2 or better, the configure test for pcc
> non-reentrant struct return convention is optimized away and always
> returns true. This causes avcall to believe it can use PCC but it
> cannot - and so bad things happen.
interesting.

> I have attached a patch I believe fixes the issue, by clearing CFLAGS
> before running the test:

did you test it?
does it work?
I do not have a solaris with gcc3 - Ray, could you please check that
this indeed fixes your problem?

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
Those who don't know lisp are destined to reinvent it, poorly.

---

From: Will Newton <[email-masked]>
Date: Thu Mar 21 08:08:13 2002

> I do not observe it on rh7.2 with either gcc 2.96 or gcc 3.0.4.

The original report I got was on Debian (not sure of the compiler). I tested 
it on Solaris and gcc 2.95.2 and it showed up also.

> does it work?

Yeah. I just got confirmation that it fixes the problem.

---

From: Raymond Toy <[email-masked]>
Date: Thu Mar 21 08:21:04 2002

>>>>> "Sam" == Sam Steingold <[email-masked]> writes:

    >> I am seeing a problem building on sparc with gcc (Solaris and Linux).

    Sam> I think the problem is only on Solaris with gcc3.
    Sam> I do not observe it on rh7.2 with either gcc 2.96 or gcc 3.0.4.

    >> avcall  fails it's structure tests, but I believe I have found a solution.
    Sam> thanks!

    >> cannot - and so bad things happen.
    Sam> interesting.

    >> I have attached a patch I believe fixes the issue, by clearing CFLAGS

    Sam> did you test it?
    Sam> does it work?
    Sam> I do not have a solaris with gcc3 - Ray, could you please check that
    Sam> this indeed fixes your problem?

Yes indeed!  I'll try it out asap.

Ray

---

From: Raymond Toy <[email-masked]>
Date: Thu Mar 21 09:41:09 2002

>>>>> "Will" == Will Newton <[email-masked]> writes:

    >> I do not observe it on rh7.2 with either gcc 2.96 or gcc 3.0.4.

    Will> The original report I got was on Debian (not sure of the compiler). I tested 
    Will> it on Solaris and gcc 2.95.2 and it showed up also.

    >> does it work?

    Will> Yeah. I just got confirmation that it fixes the problem.

Sorry, not for me.  I had to hand-apply the patch.  I assume it was
for ffcall/autoconf/aclocal.m4.  The result is:

AC_DEFUN(CL_PCC_STRUCT_RETURN,
[AC_CACHE_CHECK([for pcc non-reentrant struct return convention], cl_cv_c_struct_return_static, [
save_CFLAGS="$CFLAGS"
CFLAGS=""
AC_TRY_RUN([typedef struct { int a; int b; int c; int d; int e; } foo;
foo foofun () { static foo foopi = {3141,5926,5358,9793,2385}; return foopi; }
foo* (*fun) () = (foo* (*) ()) foofun;
int main()
{ foo foo1;
  foo* fooptr1;
  foo foo2;
  foo* fooptr2;
  foo1 = foofun(); fooptr1 = (*fun)(&foo1);
  foo2 = foofun(); fooptr2 = (*fun)(&foo2);
  exit(!(fooptr1 == fooptr2 && fooptr1->c == 5358));
}], cl_cv_c_struct_return_static=yes, rm -f core
cl_cv_c_struct_return_static=no,
dnl When cross-compiling, don't assume anything.
dnl There are even weirder return value passing conventions than pcc.
cl_cv_c_struct_return_static="guessing no")
CFLAGS="$ave_CFLAGS"
])
case "$cl_cv_c_struct_return_static" in
  *yes) AC_DEFINE(__PCC_STRUCT_RETURN__) ;;
  *no) ;;
esac

When I run configure, I see that it says:

checking for pcc non-reentrant struct return convention... (cached) yes

which is the desired answer, I guess.

I still get the minitests error in avcall:

Int f(Int,Int,Int):({1},{2},{3})->{6}
Int f(Int,Int,Int):({1},{2},{3})->{902231815}
J f(J,int,J):({47,11},2,{73,55})->{120,68}
J f(J,int,J):({47,11},2,{73,55})->{902231815,-4267884}

Ray

---

From: Sam Steingold <[email-masked]>
Date: Thu Mar 21 10:02:08 2002

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] avcall on sparc"
> * Sent on 21 Mar 2002 12:40:37 -0500
> * Honorable Raymond Toy <[email-masked]> writes:
>

actually, believe it or not, ffcall/autoconf/aclocal.m4 is a generated
file.  :-)

please do `cvs up` and recomfigure from scratch.

> which is the desired answer, I guess.
probably not :-)

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
Lisp is a language for doing what you've been told is impossible. - Kent Pitman

---

From: Raymond Toy <[email-masked]>
Date: Thu Mar 21 10:19:07 2002

>>>>> "Sam" == Sam Steingold <[email-masked]> writes:

    Sam> please do `cvs up` and recomfigure from scratch.

Do that.  configure finished without complaint.  Hurray!!!!!!!

    >> which is the desired answer, I guess.
    Sam> probably not :-)

Yep.

It's building as I type.  I'll let you know in a bit how it goes.

Ray

---

From: Will Newton <[email-masked]>
Date: Thu Mar 21 10:28:02 2002

> for ffcall/autoconf/aclocal.m4.  The result is:

It was for src/autoconf/aclocal.m4.
Doing make -f Makefile.devel configures seems to propogate this change.

> checking for pcc non-reentrant struct return convention... (cached) yes

Try removing config.cache.

> which is the desired answer, I guess.

I don't think it is. I don't even know what pcc non-reentrant struct return 
convention is, but I'm pretty sure neither Solaris or Sparc-Linux do it.

---

From: Raymond Toy <[email-masked]>
Date: Thu Mar 21 12:28:57 2002

>>>>> "Raymond" == Raymond Toy <[email-masked]> writes:

    Raymond> Do that.  configure finished without complaint.  Hurray!!!!!!!

    Sam> probably not :-)

    Raymond> Yep.

    Raymond> It's building as I type.  I'll let you know in a bit how it goes.

make check passes.  Hurray!!!!!

Ray