comp.lang.ada
 help / color / mirror / Atom feed
From: vladimir@Intrepid.COM (Vladimir Vukicevic)
Subject: Re: Error compiling GNAT 2.00 on Linux
Date: Sun, 4 Dec 1994 22:06:37 GMT
Date: 1994-12-04T22:06:37+00:00	[thread overview]
Message-ID: <D0B432.AHr@Intrepid.COM> (raw)
In-Reply-To: 3br0dh$rme@lastactionhero.rs.itd.umich.edu

Daniel Reish (dreish@umich.edu) wrote:
> While attempting to compile GNAT 2.00 on my Linux machine, I ran into
> the following error:
>
> a-misc.o(.text+0x296): undefined reference to `setjmp'
>
> This was after entering the ada/ subdirectory in the main gcc-2.6.2
> directory.  The line it stops at is the one in which it links those 30
> or 40 object files together into ./gnat1.  Does anyone know what might
> be going wrong?  I new to Ada, so I don't really know where to start
> looking, myself.  Since I would imagine this is of fairly general
> interest, since there isn't a precompiled GNAT 2.00 for Linux yet,
> please respond by followup.  Thanks.

(I apologize if anyone receives this twice, my news server has been flaky
lately.)

I just compiled gnat 2.0 (gcc 2.6.2) yesterday on my Linux box. Because
of Linux's libc's (brain-dead?) handling of setjmp, sigsetjmp, longjmp,
and siglongjmp, some patches to the gnat source are required. (The reason
is that all these are macros, some as simple as #define setjmp(x) __setjmp(x),
others not so simple.)

Note that sigsetjmp doesn't work in the Ada RTL under Linux, since sigsetjmp
is #define'd as { __sigjmp_save(env, savemask); __setjmp(env[0].__jmpbuf); },
and I'm too lazy to write the equivelent Ada code. It shouldn't be too hard,
tho, if you really need sigsetjmp.

Other than this, gnat 2.0/gcc 2.6.2 compiled cleanly for me using
gnat 1.83/gcc 2.6.0. Also, I think I ran into some problems with installation,
where the 'auxiliary' gnat programs, i.e. gnatbl, gnatbuild, gnatch[o]p, gnatf,
etc. weren't installed correctly. Make sure that these got installed before
you do a make [dist]clean.

	- Vladimir

The following patches should be applied in the directory under gcc-2.6.2,
after the 'ada' dir from gnat-2.0-src/src/ has been moved into gcc-2.6.2/.

diff -u gnat-2.00-src/src/ada/a-misc.c gcc-2.6.2/ada/a-misc.c
--- gnat-2.00-src/src/ada/a-misc.c	Wed Nov 30 10:38:51 1994
+++ gcc-2.6.2/ada/a-misc.c	Sat Dec  3 23:38:05 1994
@@ -44,6 +44,7 @@
 #include "a-misc.h"
 #include "a-rtree.h"
 #include "flags.h"
+#include <setjmp.h>
 
 extern char *xmalloc ();
 extern char *main_input_filename;
diff -u gnat-2.00-src/src/ada/a-trans3.c gcc-2.6.2/ada/a-trans3.c
--- gnat-2.00-src/src/ada/a-trans3.c	Wed Nov 30 10:38:53 1994
+++ gcc-2.6.2/ada/a-trans3.c	Sat Dec  3 23:37:42 1994
@@ -42,6 +42,7 @@
 #include "a-misc.h"
 #include "a-rtree.h"
 #include "convert.h"
+#include <setjmp.h>
 
 #undef  NULL
 #define NULL 0
@@ -590,10 +591,14 @@
      a jmpbuf.  */
   setjmp_decl
     = create_subprog_decl
+#ifdef linux
+      ("__setjmp", NULL_PTR,
+#else
 #ifdef WINNT
       ("_setjmp", NULL_PTR,
 #else
       ("setjmp", NULL_PTR,
+#endif
 #endif
        build_function_type (integer_type_node,
 			    tree_cons (NULL_TREE,  jmpbuf_ptr_type, endlink)),
diff -u gnat-2.00-src/src/ada/i-cporte.adb gcc-2.6.2/ada/i-cporte.adb
--- gnat-2.00-src/src/ada/i-cporte.adb	Wed Nov 30 10:40:20 1994
+++ gcc-2.6.2/ada/i-cporte.adb	Sat Dec  3 23:40:53 1994
@@ -239,7 +239,7 @@
 
    procedure longjmp (env : jmp_buf; val : int) is
       procedure longjmp_base (env : jmp_buf_ptr; val : int);
-      pragma Import (C, longjmp_base, "longjmp");
+      pragma Import (C, longjmp_base, "__longjmp");
 
    begin
       longjmp_base (Address_to_Pointer (env'Address), val);
@@ -267,7 +267,7 @@
 
    procedure setjmp (env : jmp_buf; Result : out Return_Code) is
       function setjmp_base (env : jmp_buf_ptr) return Return_Code;
-      pragma Import (C, setjmp_base, "setjmp");
+      pragma Import (C, setjmp_base, "__setjmp");
 
    begin
       Result := setjmp_base (Address_to_Pointer (env'Address));
@@ -289,6 +289,8 @@
          savemask : int)
          return     Return_Code;
       pragma Import (C, sigsetjmp_base, "sigsetjmp");
+   --  Linux note: sigsetjmp isn't really sigsetjmp. If this is called,
+   --  an undefined symbol error will occur when linking.
 
    begin
       Result := sigsetjmp_base (Address_to_Pointer (env'Address), savemask);





      parent reply	other threads:[~1994-12-04 22:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-12-03 23:53 Error compiling GNAT 2.00 on Linux Daniel Reish
1994-12-04 21:51 ` Rolf Ebert
1994-12-04 22:06 ` Vladimir Vukicevic [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox