public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/65524] New: gnatbind generates decrementing the unexisting elab-counter into finalize_library
@ 2015-03-23 14:43 demoonlit at panathenaia dot halfmoon.jp
2015-03-23 15:00 ` [Bug ada/65524] " charlet at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: demoonlit at panathenaia dot halfmoon.jp @ 2015-03-23 14:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65524
Bug ID: 65524
Summary: gnatbind generates decrementing the unexisting
elab-counter into finalize_library
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: demoonlit at panathenaia dot halfmoon.jp
I found some cases that gnatbind generates decrementing the unexisting
elaboration counter of each package Exxx.
E142 : Short_Integer; pragma Import (Ada, E142, "system__exn_lli_E");
... some Exxx are declared ...
procedure finalize_library is
begin
...
E132 := E132 - 1; -- * E132 is not declared in above *
...
end finalize_library;
A cause is a package having _finalize_spec/_finalize_body without
_elabs/_elabb.
I still have not been able to make the minimal example, but have made a patch.
In bindgen.adb, Gen_Elab_Externals refers U.Set_Elab_Entity to generate Exxx.
However, Gen_Finalize_Library does not refer it.
--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -1434,7 +1434,9 @@ package body Bindgen is
-- has a finalizer. In that case, this is where we decrement
-- the elaboration entity.
- if U.Utype = Is_Body and then Uspec.Has_Finalizer then
+ if U.Utype = Is_Body and then Uspec.Has_Finalizer
+ and then Uspec.Set_Elab_Entity
+ then
if not Lib_Final_Built then
Gen_Header;
Lib_Final_Built := True;
@@ -1548,7 +1550,9 @@ package body Bindgen is
WBI (" begin");
- if U.Utype /= Is_Spec then
+ if U.Utype /= Is_Spec
+ and then Uspec.Set_Elab_Entity
+ then
Set_String (" E");
Set_Unit_Number (Unum);
Set_String (" := E");
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug ada/65524] gnatbind generates decrementing the unexisting elab-counter into finalize_library
2015-03-23 14:43 [Bug ada/65524] New: gnatbind generates decrementing the unexisting elab-counter into finalize_library demoonlit at panathenaia dot halfmoon.jp
@ 2015-03-23 15:00 ` charlet at gcc dot gnu.org
2015-03-23 17:56 ` demoonlit at panathenaia dot halfmoon.jp
2015-03-24 9:49 ` charlet at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: charlet at gcc dot gnu.org @ 2015-03-23 15:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65524
Arnaud Charlet <charlet at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2015-03-23
CC| |charlet at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Arnaud Charlet <charlet at gcc dot gnu.org> ---
Sounds interesting/puzzling. But we really need a reproducer/test case to work
from.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug ada/65524] gnatbind generates decrementing the unexisting elab-counter into finalize_library
2015-03-23 14:43 [Bug ada/65524] New: gnatbind generates decrementing the unexisting elab-counter into finalize_library demoonlit at panathenaia dot halfmoon.jp
2015-03-23 15:00 ` [Bug ada/65524] " charlet at gcc dot gnu.org
@ 2015-03-23 17:56 ` demoonlit at panathenaia dot halfmoon.jp
2015-03-24 9:49 ` charlet at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: demoonlit at panathenaia dot halfmoon.jp @ 2015-03-23 17:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65524
--- Comment #2 from yuta tomino <demoonlit at panathenaia dot halfmoon.jp> ---
Created attachment 35115
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35115&action=edit
example
I found the way of reproducing.
A tiny change of a-tags.ads is necessary.
Insert "is null" into Ada.Tags.Register_Tag to suppress the elaboration.
(Is there a pragma or restriction for this purpose?)
Note, Unregister_Tag is unrelated.
And, make a package as Pure or Preelaborate. Add a tagged type.
So the package would have _finalize_spec without _elabs.
(The direct cause of this case is the asymmetry that _elabs is not generated if
Register_Tag is null, against that,
_fialize_spec is always generated even if Unregister_Tag is null.
Register/Unregister_XXX are sometimes suppressed in parts of customized
runtimes.
My customized runtime satisfies the conditions about this time.
However, the way is only example for reproducing.
I think another approach is possibility because Build_Finalizer in exp_ch7.adb
is very complex...)
And then, prepare a main subprogram using the package. Compile and gnatbind.
See b~main.adb.
The log of compiling the attached example:
% gnatmake -a -gnatp -g main
gnatbind -x main.ali
gnatlink main.ali -g
b~main.adb:31:10: "E81" is undefined (more references follow)
b~main.adb:34:07: "E05" is undefined (more references follow)
gnatmake: *** link failed.
By the way, sorry, I realized that my first patch is not proper fix.
For multiple-elaboration, an elaboration-counter should be generated and
incremented in adainit when a _finalize_spec/body is existing, even if _elabs
is not existing.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug ada/65524] gnatbind generates decrementing the unexisting elab-counter into finalize_library
2015-03-23 14:43 [Bug ada/65524] New: gnatbind generates decrementing the unexisting elab-counter into finalize_library demoonlit at panathenaia dot halfmoon.jp
2015-03-23 15:00 ` [Bug ada/65524] " charlet at gcc dot gnu.org
2015-03-23 17:56 ` demoonlit at panathenaia dot halfmoon.jp
@ 2015-03-24 9:49 ` charlet at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: charlet at gcc dot gnu.org @ 2015-03-24 9:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65524
Arnaud Charlet <charlet at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #3 from Arnaud Charlet <charlet at gcc dot gnu.org> ---
Using a custom runtime change isn't supported by GCC FSF.
I suspect the fix if any would be to geenrate the _elabs routine rather than
trying to patch the binder, but as you are using a customized runtime, there
might
be other issues at play and the simplest is for you to remove the use of a 'is
null' subprogram.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-24 9:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23 14:43 [Bug ada/65524] New: gnatbind generates decrementing the unexisting elab-counter into finalize_library demoonlit at panathenaia dot halfmoon.jp
2015-03-23 15:00 ` [Bug ada/65524] " charlet at gcc dot gnu.org
2015-03-23 17:56 ` demoonlit at panathenaia dot halfmoon.jp
2015-03-24 9:49 ` charlet at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).