When control flow preservation is requested, we want to be explicit about the units elaboration order in a partition, and we want to have in the executable an object file for all the units involved in the partition. This requires special processing for units which wouldn't produce any object code in normal circumstances, e.g. lone specs only defining simple types and marked with a No_Elaboration_Code pragma. Our scheme involves two parts: 1) make sure that all the units compiled with -fpreserve-control-flow have an elaboration counter, including lone specs with pragma No_Elaboration_Code. 2) arrange to have that elaboration counter updated by the binder generated code, even though there's no elab subprogram called. This materializes the unit elaboration explicitly and introduces a variable reference which will drag the unit object file in the link closure. So far, we were building an elaboration counter entity but were not advertising it in the ALI information and were not referencing it from the binder generated code. This change fixes this. For this set of sources: In subdir mylib/ library project mylib is for Languages use ("Ada"); for Source_Dirs use ("."); for Library_Name use Project'Name; for Library_Dir use "lib"; for Library_Kind use "static"; end mylib; package Types is type R is range 1 .. 500; end; And one level up: with "mylib/mylib.gpr"; project p is end p; with Types; procedure P is V : Types.R; pragma Volatile (V); begin null; end; Out of this build command: gprbuild -f -g -p -Pp.gpr p.adb -cargs -fpreserve-control-flow We expect b__p.adb to feature something like: E04 : Short_Integer; pragma Import (Ada, E04, "types_E"); procedure adainit ... E04 := E04 + 1; end adainit; and the final executable to include types.o. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-25 Olivier Hainque * bindgen.adb (Gen_Elab_Calls): Also update counter of lone specs without elaboration code that have an elaboration counter nevertheless, e.g. when compiled with -fpreserve-control-flow. * sem_ch10.adb (Analyze_Compilation_Unit): Set_Elaboration_Entity_Required when requested to preserve control flow, to ensure the unit elaboration is materialized at bind time, resulting in the inclusion of the unit object file in the executable closure at link time.