From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: How to tell whether program finalization can be suppressed Date: Wed, 27 Dec 2017 15:49:53 +0000 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="cec595888f8967b41b3a8a8d6edeae89"; logging-data="20608"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185qvDjdCHFVYH/2mkW56Mhy6Zxk/53P7k=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:Tp/YO8oEQIO2eWvtKkoeFMdAfX0= sha1:oOGzPKihRitOFSMyazljxB98/eo= Xref: reader02.eternal-september.org comp.lang.ada:49656 Date: 2017-12-27T15:49:53+00:00 List-Id: Simon Wright writes: > In Cortex GNAT RTS[1] (a Ravenscar RTS), I've wanted to support > finalization (at present, I have the possibly GNAT-specific > restriction No_Finalization). > > Unfortunately, as reported in PR66205[2], without No_Finalization and > in the presence of other RTS-limiting features, gnatbind generates > binding code which won't compile. > > I need to find a way of determining whether the RTS actually needs > program-level finalization (that is, finalization called on program > exit), because that's where the bad code is generated. > > Clearly, if the program never exits, there will be no need for > program-level finalization. > > Amongst other things, I can test for specific restrictions, and I'm > wondering whether No_Task_Termination would be appropriate for this? > (I'm assuming that the environment task mustn't terminate, even if the > main program exits; and in this RTS, exceptions can't be propagated). > > [1] https://github.com/simonjwright/cortex-gnat-rts > [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66205 To close this thread, which has had many interesting and helpful responses: I proposed a patch based on these ideas, which worked for me but wasn't acceptable for AdaCore; some automated tests failed (I don't know the details. I guess a Ravenscar program in such a context is allowed to terminate & finalize itself!). The working fix turned out to be to tell the compiler that the "standard library" (not quite sure what that is) is supported (which I don't think it is): this is the only way to get current gnatbind to generate compilable code when it sees finalization. Then, one needs additional dummy variables which would control aspects of a full RTS (e.g. wide character encoding, locking policy, task dispatching policy, to name but a few). Thaks for the help.