From: Piotr Trojanek Date: Thu, 22 May 2025 14:46:17 +0000 (+0200) Subject: ada: Fix ALI elaboration flags for ghost compilation units X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=176e9d801490511675772182b7d2b04b2a658ca4;p=thirdparty%2Fgcc.git ada: Fix ALI elaboration flags for ghost compilation units 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. --- diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index ec57cd23731..52063c8067f 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -1352,7 +1352,15 @@ begin -- 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;