# Controlling elaboration order when Ada.Real\_Time package is used

**URL:** <https://forum.ada-lang.io/t/controlling-elaboration-order-when-ada-real-time-package-is-used/4593>\
**Category:** General\
**Created:** [July 27, 2026, 5:49pm UTC](https://forum.ada-lang.io/t/controlling-elaboration-order-when-ada-real-time-package-is-used/4593 "2026-07-27T17:49:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![BottCode](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/bottcode/32/823_2.png) [@BottCode](https://forum.ada-lang.io/u/BottCode)\
**Post date:** [July 27, 2026, 5:49pm UTC](https://forum.ada-lang.io/t/controlling-elaboration-order-when-ada-real-time-package-is-used/4593/1 "2026-07-27T17:49:05Z")

</div>

I was reading the [Guide for the use of the Ada Ravenscar Profile in high integrity systems](https://www.math.unipd.it/~tullio/RTS/2019/YCS-2017.pdf), in particular the specification of `Activation_Manager` package at page 67.

```ada
with Ada.Real_Time;

package Activation_Manager is

 use Ada.Real_Time;

 function Clock return Ada.Real_Time.Time renames Ada.Real_Time.Clock;

 -- global start time relative to which all periodic events
 -- in system will be scheduled
 System_Start_Time : Ada.Real_Time.Time : constant := Clock;

 -- relative offset of task activation after elaboration (milliseconds)
 Relative_Offset : constant Natural := 100;

 Task_Start_Time : constant Ada.Real_Time.Time_Span :=
 Ada.Real_Time.Milliseconds(Relative_Offset);

 -- absolute time for synchronization of task activation after elaboration
 Activation_Time : constant Ada.Real_Time.Time :=
System_Start_Time + Task_Start_Time;

 procedure Activation_Sporadic;

 procedure Activation_Cyclic
 (Next_Time : out Ada.Real_Time.Time);

end Activation_Manager;

```

In order to avoid any _access-before-elaboration_ (ABE) error, shouldn’t be the case to control the elaboration of `Ada.Real_Time` body using `pragma Elaborate (Ada.Real_Time);`? In this way, the previous spec should be:

```ada
with Ada.Real_Time;
pragma Elaborate (Ada.Real_Time);

package Activation_Manager is

 use Ada.Real_Time;

 function Clock return Ada.Real_Time.Time renames Ada.Real_Time.Clock;

 -- global start time relative to which all periodic events
 -- in system will be scheduled
 System_Start_Time : Ada.Real_Time.Time : constant := Clock;

 ... and so on ...

end Activation_Manager;

```

I think that pragma is needed since the use of `Clock` function belonging to `Ada.Real_Time` package. It looks like the scenario described [here](https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/elaboration_order_handling_in_gnat.html#controlling-the-elaboration-order-in-ada):

 ![image](https://forum.ada-lang.io/uploads/default/original/2X/d/dd0e1eb667a305a55a74474c9b02229098ddfa40.png)

Isn’t it? Is this different because we’re talking about a dependency on a runtime package rather than an application one?

---

<div class="post-metadata">

**Author:** ![godunko](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/godunko/32/22_2.png) [@godunko](https://forum.ada-lang.io/u/godunko)\
**Post date:** [July 27, 2026, 6:12pm UTC](https://forum.ada-lang.io/t/controlling-elaboration-order-when-ada-real-time-package-is-used/4593/2 "2026-07-27T18:12:29Z")

</div>

Manual elaboration control is rare used feature now, at least in case of GNAT. Access before elaboration is almost impossible in regular Ada code.

---

<div class="post-metadata">

**Author:** ![OneWingedShark](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/onewingedshark/32/305_2.png) [@OneWingedShark](https://forum.ada-lang.io/u/OneWingedShark)\
**Post date:** [July 27, 2026, 6:48pm UTC](https://forum.ada-lang.io/t/controlling-elaboration-order-when-ada-real-time-package-is-used/4593/3 "2026-07-27T18:48:07Z")

</div>

We have some good elaboration algorithms now.  
It’s best to let the compiler handle them unless/until you need to actually specify. It’s like saying `Type This is range 0..255 with Size => 16;` — unless there’s a reason to specify the size (like low-level layouts), it’s best to let the compiler make the choice.

---

<div class="post-metadata">

**Author:** ![Nordic\_Dogsledding](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/nordic_dogsledding/32/547_2.png) [@Nordic\_Dogsledding](https://forum.ada-lang.io/u/Nordic_Dogsledding)\
**Post date:** [July 27, 2026, 7:11pm UTC](https://forum.ada-lang.io/t/controlling-elaboration-order-when-ada-real-time-package-is-used/4593/4 "2026-07-27T19:11:34Z")

</div>

> [@BottCode](#):
>
> `pragma Elaborate (Ada.Real_Time);`

You’re right, there is no pragma Preelaborate.  
However, if you are using Gnat, it has a special elaboration routine different from the one of the RM (you can get the latter with a compiler switch, -E perhaps), so it’s improbable that you’ll run into elaboration problems.  
In any case, inclusion of this pragma will not impede your code. And for true portability, it’s good advice to include it.

---

<div class="post-metadata">

**Author:** ![BottCode](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/bottcode/32/823_2.png) [@BottCode](https://forum.ada-lang.io/u/BottCode)\
**Post date:** [July 27, 2026, 7:28pm UTC](https://forum.ada-lang.io/t/controlling-elaboration-order-when-ada-real-time-package-is-used/4593/5 "2026-07-27T19:28:14Z")

</div>

Thanks for your answers. I think @Nordic_Dogsledding got the point about compiler portability. I understand that it’s unlikely for an ABE to occur these days, but this assumption is based on the use of recent versions of GNAT. It’s not unlikely that, especially on safety-critical jobs, you might use outdated Ada compilers or ones other than GNAT.

---

<div class="post-metadata">

**Author:** ![JC001](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@JC001](https://forum.ada-lang.io/u/JC001)\
**Post date:** [July 28, 2026, 7:47am UTC](https://forum.ada-lang.io/t/controlling-elaboration-order-when-ada-real-time-package-is-used/4593/6 "2026-07-28T07:47:51Z")

</div>

I compile most things with both GNAT and ObjectAda, and have never had an elaboration issue with ObjectAda with code that does not specify elaboration order.

---

<div class="post-metadata">

**Author:** ![dmitry-kazakov](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/dmitry-kazakov/32/522_2.png) [@dmitry-kazakov](https://forum.ada-lang.io/u/dmitry-kazakov)\
**Post date:** [July 28, 2026, 8:31am UTC](https://forum.ada-lang.io/t/controlling-elaboration-order-when-ada-real-time-package-is-used/4593/7 "2026-07-28T08:31:24Z")

</div>

I think that concerns are a bit misguided. In my experience GNAT rather indicates elaboration problems than attempts to work them around. Long ago there were some false positives and elaboration pragmas helped GNAT to come through. Now, as it was already pointed out, GNAT does not need that help anymore, so I stopped using elaboration pragmas.

The only real problems with elaboration I ever had were upon dynamic loading relocatable libraries. But these are totally different problems.
