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). 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.