# Steps to implement the distributed annex from scratch

**URL:** https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144
**Category:** General
**Created:** [January 26, 2026, 6:07am UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144 "2026-01-26T06:07:01Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![charlie5](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/charlie5/32/626_2.png) [@charlie5](https://forum.ada-lang.io/u/charlie5)
#### Post date: [January 26, 2026, 6:07am UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/1 "2026-01-26T06:07:01Z")

</div>

I’ve spent a little time looking into this since @dmitry-kazakov question in the other recent Polyorb topic, since I am also very curious.

Let me begin by admitting that my ‘advisor’ AIn’t all that reliable, so please take with a grAIn (or 2) of salt.

It appears that to implement DSA, you need to provide several DSA-related ‘System’ packages in a folder which is listed in the Source\_Dirs in your gnat project file (or in a GPR which is ‘with’ed). In the standard runtime, these packages are just stubs. If Gprbuild/Gnatmake detect your own versions within the ‘Source\_Dirs’, they will go into ‘distributed’ mode and generate the necessary ‘glue’ code to enable a distributed build.

By comparing Polyorb and Garlic implementations, the following files appear to be required …

- s-dsaser.ads/b (System.DSA\_Services)

Only in Garlic are …

- s-rpc.ads/b (System.RPC)

Frankly, I’m not certain how reliable any of this is. I’m hoping it might provoke some better informed discussion. Perhaps @Max (who maintains the Garlic repo) might be able to help/elucidate.

Regards.

---

<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: [January 26, 2026, 9:54am UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/2 "2026-01-26T09:54:20Z")

</div>

My attempt was this. I implemented s-rpc. Then I tried to compile a client with the interface package like this:

```ada
package Test_DSA_Server_Interface is
   pragma Remote_Call_Interface;

   procedure Increment_Count;
   function Get_Count return Natural;
   procedure Publish (Text : String);

end Test_DSA_Server_Interface;

```

Building fails with:

```ada
Compile
   [Ada] test_dsa_server_interface.ads
cannot generate code for file test_dsa_server_interface.ads (package spec)

```

s-rpc is ignored. E.g. when modified, gprbuild does not compile it.

---

<div class="post-metadata">

### Author: ![Max](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/max/32/21_2.png) [@Max](https://forum.ada-lang.io/u/Max)
#### Post date: [January 26, 2026, 5:14pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/3 "2026-01-26T17:14:27Z")

</div>

It depends on the functionality needed. For example, shared passive implementations only require a couple of routines that are called before/after reading/writing an object.

To build the distributed system, the compiler is invoked twice with different switches. The `-gnatzc` switch is used to create a stub on the client when compiling the remote module specification (.ads). The `-gnatzr` switch is used to create a wrapper on the server when compiling the body (.adb).

```ada
-gnatzc Distribution stub generation for caller stubs
-gnatzr Distribution stub generation for receiver stubs

```

The resulting binary modules call DSA routines; their approximate appearance can be viewed in the expanded code using the `-gnatD` switch.

There are two DSA support systems: the older Garlic and the more recent PolyORB. The compiler first determines which one is active by checking the `s-parint.ads` module, namely

`PCS_Version : constant := 1;` – means Garlic

Note, to let compiler find DSA support files they should be located in a special way. All `.ali`, `.ad[sb]` and `libgarlic.a` should be in the same folder (`${PREFIX}/lib/garlic` in my case).

Garlic is based on Ada.Streams. You need to provide a Stream implementation that the compiler will use to serialize arguments/results of remote routine calls. This should be written in System.RPC (type Params\_Stream\_Type). Then you’ll need to write a system for keeping track of remote units and partitions. The compiler identifies compilation units by name using a string type, and partitions by numeric identifiers. To avoid messing with compiler invocations and the -gnatzc/-gnatzr switches, they created the `gnatdist` utility. (Now that `gprbuild` is available, it’s probably not difficult to make it work without `gnatdist`.) It manages the system build, but the Garlic version is outdated, doesn’t handle project files, and requires an update. (Perhaps we should try the PolyORB version and see if it still works with Garlic, then turn it into an Alire crate.) I don’t know how PolyORB DSA works, because I focused on a simplest solution.

If you’re interested, we can start by creating a trivial DSA support system.

---

<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: [January 26, 2026, 5:42pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/4 "2026-01-26T17:42:48Z")

</div>

I did not understand anything of this complicated stuff. I do not want to use DSA, Garlic or PolyORB. I have a full implementation of System.RPC totally independent on these. Partitions are identified by numbers as they start. I can change that to the system process IDs. The backend supports both ways. So far my problem is that System.RPC is not recognized as such.

The purpose of stubs is unclear to me. In my simple mind if Remote\_Call\_Interface is specified the calls must go through my System.RPC. On the server side my RPC\_Receiver is called. That is, no?

---

<div class="post-metadata">

### Author: ![Max](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/max/32/21_2.png) [@Max](https://forum.ada-lang.io/u/Max)
#### Post date: [January 26, 2026, 6:07pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/5 "2026-01-26T18:07:11Z")

</div>

GNAT supports two DSA (Garlic, PolyORB). If you want your own you can 1) emulate one of these or 2) write new Ada compiler/hack GNAT. In my point of view the simplest way is to emulate Garlic. To make GNAT believe that there is Garlic installed you need PCS\_Version in s-parint.ads, then place s-parint.ads, s-parint.adb, s-parint.ali in a folder findable by compiler.

> The purpose of stubs is unclear to me.

Perhaps if you read Garlic docs you will understand better

> <https://github.com/reznikmm/garlic/blob/927ee2f2c726d188464527dab03766d769597c32/Doc/glade_ug.md>

Client’s stub is executed to make remote call instead of execution local implementation. Server’s side stub is executed by server’s thread in response on remote invocation. The first one serializes parameters into a stream and send it to the second. Server’s stub deserialize stream into arguments and call users code on the server side.

---

<div class="post-metadata">

### Author: ![Lucretia](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/lucretia/32/17_2.png) [@Lucretia](https://forum.ada-lang.io/u/Lucretia)
#### Post date: [January 26, 2026, 6:11pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/6 "2026-01-26T18:11:59Z")

</div>

I think it would be better to have a better api which could allow people to provide their own implementation. GNAT would need to use this api and garlic/polyorb would be modified to fit the api.

---

<div class="post-metadata">

### Author: ![Max](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/max/32/21_2.png) [@Max](https://forum.ada-lang.io/u/Max)
#### Post date: [January 26, 2026, 6:25pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/7 "2026-01-26T18:25:33Z")

</div>

We could try to make adapter from Garlic to a better API as the first step.

---

<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: [January 26, 2026, 6:46pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/8 "2026-01-26T18:46:32Z")

</div>

So the answer is, the stuff is hard wired and cannot be replaced. 😒

> [@Max](#):
>
> Client’s stub is executed to make remote call instead of execution local implementation. Server’s side stub is executed by server’s thread in response on remote invocation. The first one serializes parameters into a stream and send it to the second. Server’s stub deserialize stream into arguments and call users code on the server side.

To me System.PC specification in ARM is pretty clear. If the pragma provided the compiler must serialize parameters into a stream and then call Do\_RPC or Do\_APC. On the server side RPC\_Receiver is called.

The term stub confused me. Normally, “stub” means an implementation that does nothing to be replaced later.

---

<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: [January 26, 2026, 6:50pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/9 "2026-01-26T18:50:22Z")

</div>

Yes. System.RPC must have an abstract tagged type to derive from. The DSA pragmas/aspects must have the derived type as a parameter.

---

<div class="post-metadata">

### Author: ![Lucretia](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/lucretia/32/17_2.png) [@Lucretia](https://forum.ada-lang.io/u/Lucretia)
#### Post date: [January 26, 2026, 6:53pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/10 "2026-01-26T18:53:11Z")

</div>

An interface is a better api.

---

<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: [January 26, 2026, 7:13pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/11 "2026-01-26T19:13:12Z")

</div>

> [@dmitry-kazakov](#):
>
> `cannot generate code for file test_dsa_server_interface.ads (package spec)`

That error happens when you’re trying to compile the spec for a package which requires a body.

> [@Lucretia](#):
>
> I think it would be better to have a better api which could allow people to provide their own implementation.

IIRC, the Ada spec allows for this already.

---

<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: [January 26, 2026, 7:29pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/12 "2026-01-26T19:29:58Z")

</div>

> [@OneWingedShark](#):
>
> > [@dmitry-kazakov](#):
> >
> > `cannot generate code for file test_dsa_server_interface.ads (package spec)`
> 
> That error happens when you’re trying to compile the spec for a package which requires a body.

It does not requires body because of:

`pragma Remote_Call_Interface`

---

<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: [January 26, 2026, 7:33pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/13 "2026-01-26T19:33:14Z")

</div>

Yes, of course, if possible.

---

<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: [January 26, 2026, 7:35pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/14 "2026-01-26T19:35:28Z")

</div>

> [@OneWingedShark](#):
>
> IIRC, the Ada spec allows for this already.

Not really. Hacking system packages is not proper API.

---

<div class="post-metadata">

### Author: ![Lucretia](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/lucretia/32/17_2.png) [@Lucretia](https://forum.ada-lang.io/u/Lucretia)
#### Post date: [January 26, 2026, 7:51pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/15 "2026-01-26T19:51:14Z")

</div>

This should be a GSOC project. Abstract out the Distributed Annex into an interface to allow for multiple back ends. Look for extensions to add to the next version of Ada.

---

<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: [January 26, 2026, 11:12pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/16 "2026-01-26T23:12:11Z")

</div>

> [@dmitry-kazakov](#):
>
> Not really. Hacking system packages is not proper API.

?  
That has almost nothing at all to do with what the Ada LRM says about the DSA.  
A compiler could have a system that uses user-defined bodies if present in the project, defaulting to the current default; kind of like having a `generic` with an `is null` `procedure` parameter: you can override the default ‘do nothing’ with what you instantiate with.

> [@Lucretia](#):
>
> Abstract out the Distributed Annex into an interface to allow for multiple back ends. Look for extensions to add to the next version of Ada.

I was sure there was some explicit things in the LRM, check out Section E.5.

---

<div class="post-metadata">

### Author: ![Lucretia](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/lucretia/32/17_2.png) [@Lucretia](https://forum.ada-lang.io/u/Lucretia)
#### Post date: [January 26, 2026, 11:41pm UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/17 "2026-01-26T23:41:30Z")

</div>

> [@OneWingedShark](#):
>
> I was sure there was some explicit things in the LRM, check out Section E.5.

It’s limited and should be updated.

---

<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: [January 27, 2026, 10:56am UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/18 "2026-01-27T10:56:06Z")

</div>

> [@OneWingedShark](#):
>
> > [@dmitry-kazakov](#):
> >
> > Not really. Hacking system packages is not proper API.
> 
> ?

See ARM E.5. It provides no means to provide implementation in a **legal** Ada way = per **instantiation** be it generic or tagged extension.

> [@OneWingedShark](#):
>
> A compiler could have a system that uses user-defined bodies if present in the project, defaulting to the current default; kind of like having a `generic` with an `is null` `procedure` parameter: you can override the default ‘do nothing’ with what you instantiate with.

= hacking system packages.

---

<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: [January 27, 2026, 10:58am UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/19 "2026-01-27T10:58:54Z")

</div>

> [@OneWingedShark](#):
>
> I was sure there was some explicit things in the LRM, check out Section E.5.

There is a very easy way to confirm this. Just provide steps to implement the annex. It is actually the topic of this discussion.

---

<div class="post-metadata">

### Author: ![charlie5](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/charlie5/32/626_2.png) [@charlie5](https://forum.ada-lang.io/u/charlie5)
#### Post date: [January 28, 2026, 6:26am UTC](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144/20 "2026-01-28T06:26:13Z")

</div>

> [@Max](#):
>
> If you’re interested, we can start by creating a trivial DSA support system.

That would be ideal. I’m very interested and willing to spend considerable time coding/documenting, if given direction. Maybe we could start a git repo, perhaps named mini\_DSA or similar ?

[Next page](https://forum.ada-lang.io/t/steps-to-implement-the-distributed-annex-from-scratch/4144.md?page=2)
