🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6380

gcc-2.7.2 on SunOS4.1.x does not have atexit - define it

#6380
From: Manfred Hollstein KS/EF4A 60/1F/...
Date: Fri, 08 Dec 1995 00:00
104 lines
4543 bytes
Hi there,

as    I  just  mentioned  in   my   previous   e-mail  concerning  the
m68k-motorola-sysv configuration,   SunOS4.1.x  does not  provide   an
atexit function.

Gcc-2.7.2 was configured as follows:

../gcc-2.7.2/configure --srcdir=../gcc-2.7.2	\
	--prefix=${HOME}/gnu/sparc-sun-sunos4.1.3	\
	--local-prefix=${HOME}/gnu/sparc-sun-sunos4.1.3	\
	--with-gnu-as sparc-sun-sunos4.1.3

You can reproduce this with the following test program:

/* ---- File: t.c ---- */
extern int atexit (void (*) (void));

void last_function ()
{
  printf ("This is last_function\n");
}

main ()
{
  atexit (last_function);
  exit (0);
}
/* -------------------- */

$ gcc -v -V 2.7.2 t.c
Reading specs from /u/b60/manfred/gnu/sparc-sun-sunos4.1.3/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.2/specs
gcc version 2.7.2
 /u/b60/manfred/gnu/sparc-sun-sunos4.1.3/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.2/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=7 -Dsparc -Dsun -Dunix -D__GCC_NEW_VARARGS__ -D__sparc__ -D__sun__ -D__unix__ -D__GCC_NEW_VARARGS__ -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(bsd) -Acpu(sparc) -Amachine(sparc) t.c /tmp/cca03729.i
GNU CPP version 2.7.2 (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /u/b60/manfred/gnu/sparc-sun-sunos4.1.3/include
 /u/b60/manfred/gnu/sparc-sun-sunos4.1.3/sparc-sun-sunos4.1.3/include
 /u/b60/manfred/gnu/sparc-sun-sunos4.1.3/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.2/include
 /usr/include
End of search list.
 /u/b60/manfred/gnu/sparc-sun-sunos4.1.3/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.2/cc1 /tmp/cca03729.i -quiet -dumpbase t.c -version -o /tmp/cca03729.s
GNU C version 2.7.2 (sparc) compiled by GNU C version 2.7.2.
 /u/b60/manfred/gnu/sparc-sun-sunos4.1.3/sparc-sun-sunos4.1.3/bin/as -o /tmp/cca037291.o /tmp/cca03729.s
 /u/b60/manfred/gnu/sparc-sun-sunos4.1.3/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.2/ld -e start -dc -dp /lib/crt0.o -L/u/b60/manfred/gnu/sparc-sun-sunos4.1.3/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.2 -L/u/b60/manfred/gnu/sparc-sun-sunos4.1.3/sparc-sun-sunos4.1.3/lib -L/u/b60/manfred/gnu/sparc-sun-sunos4.1.3/lib /tmp/cca037291.o -lgcc -lc -lgcc
ld: Undefined symbol 
   _atexit

After applying the appended patch it'll work:

$ gcc -V 2.7.2 t.c
$ ./a.out
This is last_function
$ 

And here is the context diff:

>>>>>>> BEGIN OF ATEXIT PATCH FOR GCC-2.7.2 CONF. SPARC-SUN-SUNOS4.1.3 <<<<<<<<
diff --context --recursive --new-file --show-c-function --ignore-space-change /u/b60/manfred/tmp/orig/gcc-2.7.2/ChangeLog gcc-2.7.2/ChangeLog
*** /u/b60/manfred/tmp/orig/gcc-2.7.2/ChangeLog	Sun Nov 26 20:51:28 1995
--- gcc-2.7.2/ChangeLog	Fri Dec  8 16:05:06 1995
***************
*** 1,3 ****
--- 1,8 ----
+ Fri Dec  8 14:43:13 1995  Manfred Hollstein KS/EF4A 60/1F/110 #40283  <manfred@lts.sel.alcatel.de>
+ 
+	* libgcc2.c (L_exit): SunOS does have an on_exit() function but no atexit();
+	define it to simply call on_exit().
+ 
  Sun Nov 26 14:47:42 1995  Richard Kenner  <kenner@mole.gnu.ai.mit.edu>
  
  	* Version 2.7.2 released.
diff --context --recursive --new-file --show-c-function --ignore-space-change /u/b60/manfred/tmp/orig/gcc-2.7.2/libgcc2.c gcc-2.7.2/libgcc2.c
*** /u/b60/manfred/tmp/orig/gcc-2.7.2/libgcc2.c	Sun Nov 26 20:39:21 1995
--- gcc-2.7.2/libgcc2.c	Fri Dec  8 14:25:14 1995
*************** exit (status)
*** 2208,2213 ****
--- 2249,2263 ----
  
  #else
  int _exit_dummy_decl = 0;	/* prevent compiler & linker warnings */
+ 
+ #ifdef sun
+ # ifndef HAVE_ATEXIT
+ int atexit (func_ptr func)
+ {
+   return (on_exit (func, NULL));
+ }
+ # endif /* No HAVE_ATEXIT */
+ #endif /* sun */
  #endif
  
  #endif /* L_exit */
>>>>>>>> END OF ATEXIT PATCH FOR GCC-2.7.2 CONF. SPARC-SUN-SUNOS4.1.3 <<<<<<<<<

Merry Christmas and a happy new year,

yours

 Manfred Hollstein			SEL-Alcatel, Dept. KS/EF4A
 e-mail: manfred@lts.sel.alcatel.de	Lorenzstrasse 10
 Phone: +49 711 821 40283		70435 Stuttgart
 Fax:	+49 711 821 40196		Germany
Technical Details
Message-ID: <9512081623.AA20419@lts.sel.alcatel.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,dba9cff8d9c6ce59,start
X-Google-Attributes: gid113d02,public
From: manfred@lts.SEl.alcatel.DE (Manfred Hollstein KS/EF4A 60/1F/110 #40283)
Subject: gcc-2.7.2 on SunOS4.1.x does not have atexit - define it
Date: 1995/12/08
Message-ID: <9512081623.AA20419@lts.sel.alcatel.de>
X-Deja-AN: 121283040
distribution: gnu
sender: daemon@cis.ohio-state.edu
organization: GNUs Not Usenet
reply-to: manfred@lts.sel.alcatel.de
newsgroups: gnu.gcc.bug