When GNAT was compiling a ghost unit, the ALI file wrongly suggested that this
unit includes elaboration code, which caused linking errors to non-existing
elaboration counters. This was because elaboration code is only detected in
Gigi, which is skipped for ignored ghost units, because we don't generate
object code for them
gcc/ada/ChangeLog:
* gnat1drv.adb (Gnat1drv): Do minimal decoration of the spec and body
of an ignored ghost compilation unit.
-- Exit the gnat driver with success, otherwise external builders
-- such as gnatmake and gprbuild will treat the compilation of an
-- ignored Ghost unit as a failure. Be sure we produce an empty
- -- object file for the unit.
+ -- object file for the unit, while indicating for the ALI file
+ -- generation that neither spec or body has elaboration code
+ -- (which in ordinary compilation is indicated in Gigi).
+
+ Set_Has_No_Elaboration_Code (Main_Unit_Node);
+
+ if Present (Library_Unit (Main_Unit_Node)) then
+ Set_Has_No_Elaboration_Code (Library_Unit (Main_Unit_Node));
+ end if;
Ecode := E_Success;
Back_End.Gen_Or_Update_Object_File;