❌ About FreshRSS

Reading view

There are new articles available, click to refresh the page.

Elaboration circularity detected

Hi, I am new in this forum.
I have a problem porting ada code from Red Hat 8 (gnat 8.5.0) to Red Hat 9 (gnat 11.3.1).
The linking phase on RHEL9 fails for “Elaboration circularity detected”.
I let the ada compiler to choose the module compilation order using the following instruction:
gnatmake -c
The reason is: “unit depends on its own elaboration”
The circularity detected is: "unit invokes a construct of unit at elaboration time.
What shall I do to find the exact location of the problem?
And why this problem was not detected before using other gnat versions?
Thanks a lot

6 posts - 3 participants

Read full topic

Possible compiler bug?

I have some code that is running fine for me at home using gnat/gcc 12.2. I decided to test it out on various versions of gnat, so I fired up godbolt and tried a few. I found that starting with version 13, my code throws an exception when the program ends:

raised PROGRAM_ERROR : example.adb:4 finalize/adjust raised exception

I wanted to double check and make sure I am not doing anything illegal and 13 catches it vs 13 just having a bug. I had to make a kinda convoluted example since the original code was from a much larger code base, so apologies if the generic formals and code don’t look too practical. I spent a few hours whittling it down from the original. Full code on godbolt is here:

Code is below:

example.adb:

with Ada.Text_IO; use Ada.Text_IO;
with Test;

procedure Example is

    package B is 
        type Instance is limited interface;
        function Make return Instance is abstract;
    end B;

    package C is
        type Instance is new B.Instance with null record;
        function Make return Instance is (null record);
    end C; use C;

    package T is new Test(B.Instance, C.Instance, C.Make);

    Thing : B.Instance'Class := T.Make(2);

begin
    Put_Line("Hello World");
end Example;

test.ads:

generic
    type First(<>) is abstract tagged limited private;
    type Second(<>) is new First with private;
    with function Make return Second is <>;
package Test is

    function Make(Key : Integer) return First'Class;

private

    type Some_Access is not null access function return First'Class;

    function Make_Delegate return First'Class;

    Thing_Access : constant Some_Access := Make_Delegate'Access;

end Test;

test.adb:

with Ada.Containers.Indefinite_Ordered_Maps;

package body Test is

    package Maps is new Ada.Containers.Indefinite_Ordered_Maps
        (Key_Type     => Integer,
         Element_Type => Some_Access);

    Map : Maps.Map;

    function Make(Key : Integer) return First'Class is
    begin
        return Map(Key).all;
    end Make;

    function Make_Delegate return First'Class is
    begin
        return Make;
    end Make_Delegate;

begin
    Map.Insert(2,Thing_Access);
end Test;

It’s essentially a map of function pointers (only one in this example). I had to use a wrapper function (Make_Delegate) in order to have correct accessibility to it within the generic.

7 posts - 3 participants

Read full topic

AEiC 2024 - Ada-Europe conference - 2nd Call for Contributions

The 28th Ada-Europe International Conference on Reliable Software Technologies (AEiC 2024) will take place in Barcelona, Spain from 11 to 14 June, and comprises different tracks and co-located events.

Submission deadlines: 15 January for journal track papers; 26 February for industrial track and work-in-progress track papers, tutorial and workshop proposals. Submit early: tutorial/workshop proposals will be evaluated ASAP, with decisions from 1 January 2024!

More information on the conference site, including an extensive list of topics, and details on the call for contributions for the various tracks.

www.ada-europe.org/conference2024

#AEiC2024 #AdaEurope #AdaProgramming

1 post - 1 participant

Read full topic

Gnatd.v elaboration

I wonder. Is gnatd.v a better option than
pragma preelaborate

Is preelaborate more compiler portable? Though I do not use the features that it protects against such as dynamic dispatch, so it is simply an unneeded restriction for me with Gnat. However gnatd.v seems to offer more such as in regard to uninitialised variables? Assuming it works as I had no compile issues :joy:.

see 7.7

https://docs.adacore.com/spark2014-docs/html/lrm/packages.html

2 posts - 2 participants

Read full topic

Regarding END_ERROR when using Ada.Text_IO.Set_Line on IN_FILE

When using the procedure Set_Line (File, X) after using the procedure Skip_Line(File, Y) the error, END.ERROR is raised when X <= Y
(except when X = Y = 1).

When the procedure Set_Line (File, X) is called on a File of mode IN_FILE, it internally calls Skip_Line until the file line number reaches X.
If X is not equal than the current line in the file, the procedure will continuously skip lines until it reaches another page with a matching line. (RM 2022 p.g.523)

I am curious about the reasoning for this functionality as it has caused an amusing problem in the trivial program I am writing.
The program will get the number of lines from a .txt file and select a random line to print to the console. A word of the day program.
Minimal Example of Issue:

with Ada.Text_IO; use Ada.Text_IO;

procedure Main is

   File_Name : constant String := "TEST.txt";
   Test_File : File_Type;

begin
   Create (Test_File, Out_File, File_Name);

   for I in 1 .. 10 loop
      Put_Line (Test_File, "Line :" & Integer'Image (I));
   end loop;

   Close (Test_File);
   Open (Test_File, In_File, "Test.txt");

   Skip_Line (Test_File, 5);

   Set_Line (Test_File, 4);

end Main;
--Will raise End_Error

I would think that the procedure would check if X < File.Line then perform further actions. While am able to work around this, I am interested to understand the reasoning.
Thanks.

9 posts - 5 participants

Read full topic

Advent of Code 2023

It’s that time of year again!

Advent of Code is a series of daily programming puzzles from December 1st to 25th, becoming progressively more difficult each day. The puzzles can be completed in any programming language- inputs are short text files and the solutions are integers. Many people use these puzzles to learn a new language or try new techniques.

Last year, we had lively daily discussions and solutions in both Ada and SPARK on the forum. This year, I want to open the conversation up to any language with a focus on safety or reliability- Ada, SPARK, MISRA-C, or any other metallic compounds.

I think we can reuse last year’s leaderboard code 1708445-6a8f7730, which you can join on the Private Leaderboards page while logged into your AoC account.

5 posts - 3 participants

Read full topic

Using Long_Float in inline assembler for ARM

Hi,
Using GNAT v11.2/0-4 for ARM (Alire), the following procedure Unbiased_Rounding for Float works as expected.

function Unbiased_Rounding (X : Float) return Float is
Y : Float;
begin
Asm (“vrintn.f32 %0,%1”,
Outputs => Float’asm_output (“=t”, Y),
Inputs => Float’asm_input (“t”, X));
return Y;
end Unbiased_Rounding;

according to Machine Constraints (Using the GNU Compiler Collection (GCC))
the constraint t means "VFP floating-point registers s0-s31. Used for 32 bit values” and the constraint w means "VFP floating-point registers d0-d31 and the appropriate subset d0-d15 based on command line options. Used for 64 bit values only”

therefore we wrote our long_float version as

function Unbiased_Rounding (X : Long_Float) return Long_Float is
Y : Long_Float;
begin
Asm (“vrintn.f64 %0,%1”,
Outputs => Long_Float’asm_output (“=w”, Y),
Inputs => Long_Float’asm_input (“w”, X));
return Y;
end Unbiased_Rounding;

however this fails to compile.
GNAT 11.2/0-4 (Alire) complains
Error: invalid instruction shape – `vrintn.f64 s14,s14’

presumably because the operands are S registers rather than double precisions D registers.
Is this a bug or have we misunderstood something?

Best wishes,
Ahlan

8 posts - 4 participants

Read full topic

Gnatprove detailed counterexample trace outside GNAT Studio?

When gnatprove is used with “–counterexamples=on” inside GNAT Studio it is able to present a detailed trace[1]:

counterexample

This nice trace only seems to work inside GNAT Studio, not inside the VSCode AdaCore.ada plugin. Is there a way to output this trace to a text console (e.g. by passing an option to the gnatprove command-line command) so that this trace feature can be used outside GNAT Studio?

[1] 7.2. How to View GNATprove Output — SPARK User's Guide 25.0w

2 posts - 2 participants

Read full topic

Understanding `select or delay until` in tasks

I’m playing with tasks and have a question about select with delay until.

I have a task with the following body (the full implementation is on GitHub):

Wait : loop
   select
      -- Wait for pings. When they come, reset Last_Ping.
      accept Ping do
          Log.Debug ("Received ping.");
          Last_Ping := Clock;
      end Ping;
   or
      -- If there is no ping within the expected interval, do something.
      delay until (Last_Ping + Expected_Ping_Interval);
      Log.Error ("Timeout!");
      -- Do something.
      -- Is there any way to keep running the task loop here? 
   end select;
end loop Wait;

From how I understand the select, it waits for the specified delay - if there is a Ping before the end of the delay, the loop iteration is finished and the next iteration is started, again waiting for the specified delay or accepting a Ping.

Now, when the delay is over and there was no entry in Ping, it does not proceed with the next loop iteration but is finished, right? Why is that? And is there a way to write this loop so the task continues running?

(Also happily take pointers to good resources for learning about task behavior in more depth. :slight_smile:)

6 posts - 3 participants

Read full topic

Add section to main page about "projects to work on"?

Hi all!

I would like to propose a new section in the main of Ada-Lang.io. I want to start a conversation and get some feedback from the community before working on this idea. The feedback would need to be positive and the Website admins would have to approve it.

I would like to add a “Projects to work on” (or something similar) at the top navigation bar and mention this section in a couple of places. This section would list some projects and ideas where the community could work on in order to improve the general Ada ecosystem. Notice that I said “Ada Ecosystem” and not “Ada projects”!

For example, it could list projects such as:

  • Ada programming
    • Improve whatever thing in Alire
    • Help the IronClad kernel
    • Create some RTS for Zephyr RTOS, *BSD…
    • Create or improve high quality Ada bindings to some C libraries that people could make use of… Think of SDL2, MIDI, etc…
    • Create some highly desired Ada project
  • Quality assurance
    • Test Alire v2
    • Test Alire on Windows
    • Test GNAT/LLVM-GNAT on some systems and report bugs or improvements…
  • Integration on other systems
    • Improve Ada support in FreeBSD/NetBSD, etc…
    • Add Ada syntax support in LaTeX-lstlistings (for example, this would require very little Ada experience!)
    • Ada on Macs, Apple systems.
    • Ada and WASM
    • Ada and Android
  • Documentation
    • Write tutorials on topics such as “Getting started with Ada programming in RTEMS…”
    • Give feedback to guides or systems such as the “Learn Ada” website
  • Marketing
    • Make posts about Ada projects or news in general programming websites such as HackerNews, general subReddits, etc. (I would ask people to not be obnoxious or just post things for the shake of posting. Posts should be high quality and impactful in order to create momentum!)
    • Response accurately and nicely to comments and questions about Ada in social media
  • Help
    • Be present in forums, chats, etc in order to help new people getting started.
    • Compile a list of general Ada pitfalls that should be improved for newbees and general programmers.

This section would not be one where people just list their desires and own personal projects. It would mainly focus on general tools, outreach, easy to get-started projects for new Ada programmers, cool projects that could make Ada grow in the eyes of other programming circles, etc.

So… What do you think? I believe this is a great idea and it allows us, the community, to focus on basic structural issues, create a better “First impression/First experience” when getting started with Ada, and large projects that can be later be used to gain popularity and outreach.

Best regards,
Fer

26 posts - 12 participants

Read full topic

Spark with a private global log store

I have a log package with a private global variable that passes silver mode except for a couple of low upper bound string issues. It has a fixed sized global variable as the log store.

However any external procedure running in spark mode that tries to execute a log function is wanted by spark to have the state or log store listed in it’s global aspect even though it has no access to the private log store directly.

I assume that I am missing something and shall keep reading but any help would be much appreciated? It isn’t workable for me to create global aspects for any procedure that uses my log package. I guess I could pass the log store but I am not sure that that is a good solution.

Thanks

3 posts - 2 participants

Read full topic

Gnu Emacs ada-mode - passing the torch

8.1.0 is my last release as Emacs ada-mode maintainer; it’s time for
me to retire.

I’m not using Ada for any serious projects (other than ada-mode
itself), my health is declining, and all my available energy is taken
by my darling baby grandaughter (FIXME: attach photo).

So I’m looking for someone to take over as maintainer. Ideally, this
would be someone employed by a company that values Ada and Emacs, but
anyone with sufficient interest, energy, and time can do the job.

I’ll be available to teach the new maintainer what they need to know.

If you are interested, contact me via the Emacs ada-mode mailing list
(Emacs Ada mode - Mailing Lists [Savannah]) or directly at
[email protected].

What’s involved in being ada-mode maintainer?

  • Wisitoken parser generator and runtime

    • All Ada (very small amount of C in the lexer wrapper)
      • 92 files, 18k statements
    • uses re2c lexer generator (generates C code)
    • generalized LR, error-correction, incremental
    • very complex Ada code
    • User grammar source file is parsed by a WisiToken parser
    • full test suite
      • 52 Ada files, 3492 statements
      • 45 grammar files
    • some documentation of algorithms
  • gnat-compiler package

    • elisp wrapper to call gnat tools in various ways
    • 3 elisp files, 1938 lines
  • gpr-query package

    • Provides project-wide cross reference for Ada
    • mix of elisp and Ada
      • 1 Ada file 211 statements, 1 elisp file 1075 lines
    • The Ada code is evolved from an old AdaCore utility
    • it uses gnatcoll packages to query a database built from .ali
      files produced by the GNAT compiler.
  • wisi indentation, face, navigation package

    • mix of Emacs lisp and Ada
      • 19 Ada files, 2592 statements
      • 8 elisp files, 7097 lines
    • interfaces to wisitoken parser in a separate process
    • Uses rules in the grammar, and the syntax tree produced by parser,
      to compute indentation, face, navigation.
    • tested by the ada-mode test suite
  • ada-mode package

    • Uses wisi, gnat-compiler
    • uses gpr-query or ada_language_server via eglot for cross-reference.
    • some Ada code to customize wisi computations
      • 15 Ada files generated by wisitoken
      • 15 Ada files, 2361 statements
      • 7 elisp files 4102 lines
    • ada_annex_p.wy grammar file derived from ARM Annex P. (3037 lines)
    • also supports ada_language server via eglot
  • gpr-mode package

    • for GNAT .gpr files
    • uses wisi, gnat-compiler
    • small amount of Ada code to customize wisi computations
    • gpr.wy grammar file derived from gprbuild user guide.
  • wisitoken-grammar-mode

    • for .wy files
    • uses wisi
    • grammar file derived from that used to generate WisiToken grammar
      source file parser
  • ada-ref-man package

    • Provides info version of Ada Reference Manual as an ELPA package
    • Has Ada code that adds info capability to the official ARM formatting program

There could be one maintainer for all of the above, or several to
share the work as they see fit.

I’ve had a lot of fun maintaining ada-mode over the years (I’ve lost
track of when I started; sometime around 1995?). While I was working
at NASA writing Ada for dynamic simulators, it was very nice to be
able to just fix ada-mode to do what I wanted. Adding error correction
and incremental parsing to the parser was very challenging, and very
satisfying when it worked. The occasional thanks from users is also
very satisfying.

There are several paths forward for a new maintainer:

  1. Learn all the current code, and maintain it.

  2. Drop the wisitoken parser generator and runtime, use tree-sitter
    instead. This requires writing a wrapper for tree-sitter to match
    the wisitoken syntax-tree API; then the current wisi indentation
    code can be used.

    This maintains all of the ada-mode features, while reducing the
    maintenance burden significantly.

    I believe the tree-sitter error correction is less powerful than
    wisitoken, but it would be interesting to see if that matters in
    practice.

  3. Drop everything except the grammar; use tree-sitter parser and
    emacs tree-sitter queries for indentation, face, navigation.

    It will not be possible to match the current ada-mode indentation
    styles, and some ada-mode features will be lost. Even more
    maintenance burden reduction.

  4. Just use eglot and AdaCore ada_language_server.

    Even larger deviation from current styles, even more features lost.
    But could work with AdaCore to improve things; that would also
    improve GNAT Studio.

If you are interested in handling all or part of this work, contact me
via the Emacs ada-mode mailing list
(Emacs Ada mode - Mailing Lists [Savannah]) or directly at
[email protected].

3 posts - 3 participants

Read full topic

Lightweight Parallelism library based on Ada 2022 features

A full implementation of the parallel features of Ada 2022 is yet to be released. In the meantime, here is a light-weight-threading library that provides essentially all of the parallel features of Ada 2022, using various generics, etc. Scheduling is provided using a plug-in architecture. If no scheduler is plugged in, the light-weight threads are simply executed sequentially. If a light-weight-thread scheduler is plugged in, then the light-weight threads spawned by instances of the various generic packages are managed by that scheduler.

There are currently two LWT scheduler plug-ins:

  • a wrapper for the GNU implementation of OpenMP (lwt-openmp.ads)
  • a work-stealing based plug-in, written entirely in Ada (lwt-work_stealing.ads)

Below is a link to the “readme.md” documentation for the GitHub lwt library. It is currently part of the ParaSail GitHub repository, but the files in “lwt” are actually independent of ParaSail. ParaSail has its own work-stealing-based scheduler built-in, but at some point we plan to shift over to using the “lwt” library. But at the moment, there is no dependence either way between the ParaSail interpreter/compiler and the lwt library.

Feel free to open GitHub Issues if you find problems with the implementation, or have suggestions for improvements.

Enjoy!

-Tucker Taft

The ParaSail GitHub repository was created by my colleague Olivier Henley, and he has also helped to improve the documentation and testing scripts. Much appreciated!

2 posts - 2 participants

Read full topic

Gnu Emacs Ada mode 8.1.0 released

Gnu Emacs Ada mode 8.1.0 is now available in GNU ELPA.

wisi-incremental-parse-enable is now t by default; incremental parse
is always better than partial parse, except in really huge files.

The Ada grammar used by ada-mode is now compatible with tree-sitter; a
tree-sitter grammar source file is produced by the generate step.

ada-mode is tested with gnat 13 (current compiler in Alire).

gpr-query and gpr-mode are separate GNU ELPA packages. You must
install them separately (Emacs install-package doesn’t support
“recommended packages” like Debian does).

The required Ada code requires a manual compile step, after the normal
list-packages installation:

cd ~/.emacs.d/elpa/ada-mode-*
./build.sh
./install.sh

If you have Alire installed, these scripts use it.

1 post - 1 participant

Read full topic

❌