Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
Simon, Unfortunately we've discovered that your patch is causing unexpected consequences and break e.g. testing of ravenscar application, where although the Ada RM requires no task termination, for practical purposes, waiting for terminating task is something we rely upon for automatic testing, so your patch is suitable after all, sorry about the oversight. After internal discussions at AdaCore, it appears that if you want Finalization, you chould set Suppress_Standard_Library_On_Target to False. All your troubles come from the fac tthat you tries to stick to Suppress_Standard_Library_On_Target set to True, but this combination (Suppress_Standard_Library_On_Target set to True, and Finalization enabled) is simpled not supported in the GNAT runtime, and the binder doesn't expect it either. So I'm going to revert your change in bindgen.adb and will let you experiment with setting Suppress_Standard_Library_On_Target to False in your system.ads. This is what we do in e.g.. our ravenscar-full runtime which supports precisely both ravenscar tasking, and finalization (among other things), on bare metal targets, which seems to correspond to what you are trying to do. Arno > gcc/ada/Changelog: > > 2017-12-05 Simon Wright> > PR ada/66205 > * bindgen.adb (Gen_AdaFinal): If the restriction > No_Task_Termination is present, generate a null body.
Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
> I've come up with a considerably simpler patch, which merely causes the > procedure adafinal to be generated with a null body if the restriction > No_Task_Termination is set (note, this restriction is part of the > Ravenscar profile; if tasks can't terminate, program level finalization > can't happen [ARM 10.2(25), "When the environment task completes > (normally or abnormally), it waits for the termination of all such tasks, > and then finalizes any remaining objects of the partition."] > > I've bootstrapped the compiler (x86_64-apple-darwin15), and "make > check-ada" produces the same results with and without the patch (the same 3 > FAILs occur in both, in gnat.sum). For the arm-eabi compiler, I > successfully make and run builds for an STM32F4 target without exception > propagation but with and without finalization. That's a much simpler and better approach indeed. OK to commit. > gcc/ada/Changelog: > > 2017-12-05 Simon Wright> > PR ada/66205 > * bindgen.adb (Gen_AdaFinal): If the restriction > No_Task_Termination is present, generate a null body. >
Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
On 7 Mar 2017, at 16:20, Simon Wrightwrote: > > On 19 Dec 2015, at 22:05, Simon Wright wrote: >> >> On 12 Nov 2015, at 10:02, Arnaud Charlet wrote: >>> > This situation arises, for example, with an embedded RTS that > incorporates the > Ada 2012 generalized container iterators. I should add, this PR is the ???other half??? of PR ada/66242, which is fixed in GCC 6; so please can it be reviewed? >>> >>> The proper patch for PR ada/66242 hasn't been committed yet (it's pending), >>> so I'd rather review the situation once PR ada/66242 is dealt with. >>> >>> I'm not convinced at all that your patch is the way to go, so I'd rather >>> consider it only after PR ada/66242 is solved properly. >> >> Looks as though PR ada/66242 has been sorted out. >> >> Since we can now *compile* code that is built with finalization enabled in a >> restricted runtime, but we can't *bind* it, could we take another look at >> this? the patch I provided in this thread still applies at snapshot 20151213 >> with minor offsets (8). > > Same problem exists in gcc version 7.0.1 20170302 (experimental) (GCC). and with gcc 8.0.0 20171102 (experimental) (r254339); and there's been no change to the affected file (bindgen.adb) since then. I've come up with a considerably simpler patch, which merely causes the procedure adafinal to be generated with a null body if the restriction No_Task_Termination is set (note, this restriction is part of the Ravenscar profile; if tasks can't terminate, program level finalization can't happen [ARM 10.2(25), "When the environment task completes (normally or abnormally), it waits for the termination of all such tasks, and then finalizes any remaining objects of the partition."] I've bootstrapped the compiler (x86_64-apple-darwin15), and "make check-ada" produces the same results with and without the patch (the same 3 FAILs occur in both, in gnat.sum). For the arm-eabi compiler, I successfully make and run builds for an STM32F4 target without exception propagation but with and without finalization. gcc/ada/Changelog: 2017-12-05 Simon Wright PR ada/66205 * bindgen.adb (Gen_AdaFinal): If the restriction No_Task_Termination is present, generate a null body. bindgen.adb.diff Description: Binary data
Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
On 19 Dec 2015, at 22:05, Simon Wrightwrote: > > On 12 Nov 2015, at 10:02, Arnaud Charlet wrote: >> This situation arises, for example, with an embedded RTS that incorporates the Ada 2012 generalized container iterators. >>> >>> I should add, this PR is the ???other half??? of PR ada/66242, which is >>> fixed >>> in GCC 6; so please can it be reviewed? >> >> The proper patch for PR ada/66242 hasn't been committed yet (it's pending), >> so I'd rather review the situation once PR ada/66242 is dealt with. >> >> I'm not convinced at all that your patch is the way to go, so I'd rather >> consider it only after PR ada/66242 is solved properly. > > Looks as though PR ada/66242 has been sorted out. > > Since we can now *compile* code that is built with finalization enabled in a > restricted runtime, but we can't *bind* it, could we take another look at > this? the patch I provided in this thread still applies at snapshot 20151213 > with minor offsets (8). Same problem exists in gcc version 7.0.1 20170302 (experimental) (GCC). Note, what may not have been clear before and is now relevant given AdaCore's -full- embedded runtimes, the problem occurs when the runtime doesn't support exception propagation but does support finalization. As far as gnatbind is concerned, "runtime does not support exception propagation" appears to be indicated by "Suppress_Standard_Library_On_Target" rather than "Cumulative_Restrictions.Set (No_Exception_Propagation)" - the latter is partition-wide, so could be used instead maybe? I attach an updated patch. I've tested the new gnatbind against gcc version 7.0.1 20170302 (experimental) (GCC) on native x86_64-apple-darwin16 by running 'make check-ada', and for --target=arm-eabi by successfully making and running builds for an STM32F4 target without exception propagation but with and without finalization. I used the same gnatbind for both targets - renamed to arm-eabi-gnatbind for those builds - seeing there's no target dependence in gnatbind itself. gcc/ada/Changelog: 2017-03-07 Simon Wright PR ada/66205 * bindgen.adb: If the restriction No_Finalization is absent (i.e. finalization is supported) but Suppress_Standard_Library_On_Target is true, then - don't import __gnat_initialize or __gnat_finalize (as Initialize, Finalize rsp). - don't call Initialize or Finalize. - don't generate or call adafinal. gcc-ada-bindgen.adb.diff Description: Binary data
Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
On 12 Nov 2015, at 10:02, Arnaud Charletwrote: > >>> This situation arises, for example, with an embedded RTS that >>> incorporates the >>> Ada 2012 generalized container iterators. >> >> I should add, this PR is the ???other half??? of PR ada/66242, which is fixed >> in GCC 6; so please can it be reviewed? > > The proper patch for PR ada/66242 hasn't been committed yet (it's pending), > so I'd rather review the situation once PR ada/66242 is dealt with. > > I'm not convinced at all that your patch is the way to go, so I'd rather > consider it only after PR ada/66242 is solved properly. Looks as though PR ada/66242 has been sorted out. Since we can now *compile* code that is built with finalization enabled in a restricted runtime, but we can't *bind* it, could we take another look at this? the patch I provided in this thread still applies at snapshot 20151213 with minor offsets (8).
Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
On 11 Nov 2015, at 19:43, Simon Wrightwrote: > This situation arises, for example, with an embedded RTS that incorporates the > Ada 2012 generalized container iterators. I should add, this PR is the “other half” of PR ada/66242, which is fixed in GCC 6; so please can it be reviewed? I didn’t make it plain that the comment I’ve put in the first hunk, -- For restricted run-time libraries (ZFP and Ravenscar) tasks -- are non-terminating, so we do not want finalization. is lifted from the unpatched code at line 480, where it relates to the use of Configurable_Run_Time_On_Target for this purpose.
Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
> > This situation arises, for example, with an embedded RTS that > > incorporates the > > Ada 2012 generalized container iterators. > > I should add, this PR is the ???other half??? of PR ada/66242, which is fixed > in GCC 6; so please can it be reviewed? The proper patch for PR ada/66242 hasn't been committed yet (it's pending), so I'd rather review the situation once PR ada/66242 is dealt with. I'm not convinced at all that your patch is the way to go, so I'd rather consider it only after PR ada/66242 is solved properly. Arno
Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
I’ve updated the original patch, which was built against 5.1.0 on x64_64-apple-darwin13, this patch is against 6.0.0-20151101 on x86_64-apple-darwin15. -- If the RTS in use is "configurable" (I believe this is the same in this context as "restricted") and includes finalization, gnatbind generates binder code that won't compile. This situation arises, for example, with an embedded RTS that incorporates the Ada 2012 generalized container iterators. I note that in the last 3 hunks of the attached patch there may be overkill; the original code checks whether the No_Finalization restriction doesn’t occur, and I’ve added a check that Configurable_Run_Time_On_Target isn’t set; I suspect, given other areas of the code, that the No_Finalization check is actually intended as a way of determining that this is a restricted runtime, and that the Configurable_Run_Time_On_Target check could replace it. The attached patch was bootstrapped/regression tested (make check-ada) against 6.0.0 on x86_64-apple-darwin15 (which confirms that the patch hasn't broken builds against the standard RTS). arm-eabi-gnatbind was successful against both an RTS with finalization and one without. gcc/ada/Changelog: 2015-11-11 Simon WrightPR ada/66205 * bindgen.adb (Gen_Adafinal): if Configurable_Run_Time_On_Target is true, generate a null body. (Gen_Main): if Configurable_Run_Time_On_Target is true, then - don't import __gnat_initialize or __gnat_finalize (as Initialize, Finalize rsp). - don't call Initialize or Finalize. gcc-6.0.0-20151101-gcc-ada-bindgen.adb.diff Description: Binary data