[m-rev.] diff: work around bug with atexit() being undefined

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Mar 28 18:16:35 AEST 2001


Estimated hours taken: 1
Branches: release, main

runtime/mercury_wrapper.c:
	Work around a bug in gcc/libc on venus
	(gcc 2.95.3 (prerelease), libc 2.2.2, Debian Linux):
	ensure that we link in atexit().

Workspace: /home/venus/fjh/ws-venus/mercury
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.86
diff -u -d -r1.86 mercury_wrapper.c
--- runtime/mercury_wrapper.c	2001/02/17 08:00:05	1.86
+++ runtime/mercury_wrapper.c	2001/03/28 08:14:06
@@ -276,6 +276,16 @@
 	*/
 	MR_save_regs_to_mem(c_regs);
 
+	/*
+	** XXX Ensure that we link in atexit().
+	** XXX This works around a bug in gcc 2.95.3 (prerelease) and/or
+	** libc 2.2.2 on Debian Linux, where we'd get a link error when
+	** building libmer_rt.so with --no-undefined, due to a reference
+	** to atexit() from crtendS.o, which gets linked last, after any
+	** libraries such as `-lc'.
+	*/
+	MR_global_pointer = (void *) atexit;
+
 #if defined(MR_LOWLEVEL_DEBUG) || defined(MR_TABLE_DEBUG)
 	/*
 	** Ensure stdio & stderr are unbuffered even if redirected.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list