stanl@cbnewsm.ATT.COM (stanley.b.lippman) (11/10/89)
>>peter@media-lab.media.mit.edu >> I just found that without the explicit call to exit() the destructors >> never get called. Hence the outputstream just disappears (if I put >> a flush in the main() without using exit() at least it prints, but >> still does not call any destructors). Is that supposed to be so? >> I have no idea where to look as to what went wrong. Any hints? *** this behavior of the HP9000 series is discussed in the paper ``C++: From Research to Practice'' by myself and Barbara Moo, p. 127 in the 1988 Usenix C++ Conference Proceedings. the problem, in a nutshell (or kernel) is that cfront provides its own instance of exit in libC.a. this instance insures the execution of static destructors. the CC command presumes that the call cc myFoo.c libC.a libc.a will link in the first encountered instance of exit. however, unless the user's code has an explicit call of exit, the binding of exit to the libc.a instance is done outside the conventional binding rules. i'm not familiar enough with the hp line to provide any insight into its behavior. stan lippman at&t bell laboratories warren, nj
peter@mit-amt.MEDIA.MIT.EDU (Peter Schroeder) (11/11/89)
In article <6422@cbnewsm.ATT.COM> stanl@cbnewsm.ATT.COM (stanley.b.lippman) writes: > the problem, in a nutshell (or kernel) is that cfront provides > its own instance of exit in libC.a. this instance insures the > execution of static destructors. > > the CC command presumes that the call > cc myFoo.c libC.a libc.a > > will link in the first encountered instance of exit. however, > unless the user's code has an explicit call of exit, the > binding of exit to the libc.a instance is done outside the > conventional binding rules. Indeed that is the problem and it turns out that there is a flag specifically for this purpose to be sent to the linker. Someone suggested the following fix: add the line LIBRARY=${LIBRARY-"-W l,-uexit -lC"} to CC in place of the existing line LIBRARY=${LIBRARY--l${LIB_ID}} That fixes the problem. I am rebuilding everything right now and will compile a list of things to do for other HP9000/800 users when building cfront 2.0. If you are interested, send me mail and I will mail it to you. If you went through this yourself already, let me know about the things you found, you needed to do and I will merge all those `tricks'. Thanks to everyone for their help! Peter