GNAT Release Notes

GNAT Pro 21 Release Notes

Release Date: February 2021

Compiler

GCC Back-End Update

The GNAT compiler has now been updated to GCC 9.4. See this page for the corresponding capabilities of the back-end, as well as updates to C and C++.

128 bits Integer Support

Support for 128-bit integer types on all 64-bit platforms has been implemented in the compiler. This allows declaring larger integer types, for example:

type Some_Integer is range -2 ** 100 .. 2 ** 100;
V : Some_Integer := 2 ** 99;

Improved Static Resolution

The compiler has been enhanced to be able to resolve at compile time a number of expressions and computations that would previously generate run-time code. This includes allowing some imported intrinsic functions such as Shift_Left and Shift_Right, static declare expressions, static string concatenation after inlining, relational operators of static string types and some forms of aggregates containing “others”. The result is more efficient code as well as situations where elaboration code is no longer necessary.

Ada 202x Support

Ada 202x features will be implemented by GNAT on a case-by-case basis. Certain capabilities are already part of the GNAT Pro 21 release, and are enabled through the -gnat2020 switch. Others are considered experimental and can be activated through the -gnatX switch.

Language enhancements can be discussed here.

Jorvik support

Reference AI: AI12-0291

Supported by: -gnat2020

Jorvik is a subset of the Ada tasking capabilities, similar to Ravenscar and which imposes fewer restrictions, removing the following ones compared to the Ravenscar profile:

  • No_Implicit_Heap_Allocations

  • No_Relative_Delay

  • Simple_Barriers

  • Max_Entry_Queue_Length => 1

  • Max_Protected_Entries => 1

  • No_Dependence => Ada.Calendar

  • No_Dependence => Ada.Synchronous_Barriers

The configuration pragma pragma Profile now supports Jorvik as a possible value to enforce the restrictions and is available as part of the ravenscar-full runtimes on bare metal platforms.

Improvements to Image attributes

Reference AI: AI12-0225 AI12-0315 AI12-0304 AI12-0020 AI12-0340 AI12-0124

Supported by: -gnat2020

A number of improvements have been done in the way the ‘Image attribute works. In particular, this attribute can be used directly on objects (it used to be available on types), similar to how the GNAT-specific 'Img attribute works.

A new attribute 'Put_Image has been introduced, allowing an implementation for any type. The exact form of the user supplied Put_Image procedure is still under finalization at the ARG and is provided in an intermediate form in GNAT Pro 21 which will likely change in release 22. For example:

type R is record
   null;
end record with Put_Image => My_Image;

procedure My_Image...

All types have a default implementation of Put_Image.

Atomic Operations

Reference AI: AI12-0234 AI12-0321

Supported by: -gnat2020

Four new packages, System.Atomic_Operations.Exchange, System.Atomic_Operations.Test_And_Set, System.Atomic_Operations.Integer_Arithmetic and System.Atomic_Operations.Modular_Arithmetic now support accessing processor-specific atomic operations, allowing users to write thread-safe concurrent code without the use of system locks.

Big Numbers

Reference AI: AI12-0208

Supported by: -gnat2020

Two new packages Ada.Numerics.Big_Numbers.Big_Integers and Ada.Numerics.Big_Numbers.Big_Reals provide support for unbounded integer and real numbers with arithmetic operations implemented in software.

Literals for user types (Integer, Real, String) can also be specified and are supported by default for the above two packages.

Import Variadic C functions

Reference AI: AI12-0028

Supported by: -gnat2020

Importing variadic functions was not portable and implementation-specific. It is now supported via a new convention, C_Variadic_*N*, where N is the number of fixed parameters in the C profile.

‘Reduce

Reference AI: AI12-0262

Supported by: -gnatX

A new attribute 'Reduce is available for experimentation. It supports performing a map/reduce operation over the values of a container. For example:

X : Integer := (1, 2, 3)'Reduce ("+", 0);

Will add 1, 2 and 3, and store the result in X.

Declare Expressions

Reference AI: AI12-0236 AI12-0368

Supported by: -gnat2020

Ada 202x now allows declaring constants and renamings inside a declare expression, which facilitates writing more complex preconditions and postconditions.

Val : Integer := (declare X : constant Integer := Random_Value; begin X + X);
Static Expression Functions

Reference AI: AI12-0075

Supported by: -gnat2020

Ada 202x defines a new aspect Static that can be specified on expression functions. Such an expression function can be called in contexts requiring static expressions when the actual parameters are all static, allowing for greater abstraction in complex static expressions. For example:

function Half_Size (S : Integer) return Integer is (S / 2) with Static;

type T is range 0 .. 10 with Size => Half_Size (Integer'Size);
Contracts on Access-to-Subprogram Types

Reference AI: AI12-0220

Supported by: -gnat2020

Aspects Pre and Post can now be specified on access to subprogram types. As a consequence, when a call is made from such a type, the contract of the type will be executed, together with the specific contracts of the called subprogram if any.

Iterator Filters

Reference AI: AI12-0250

Supported by: -gnat2020

Iterators can now be provided with an optional filter. This can be used in loops or in the new container aggregates and reduce expressions. For example:

for E of Some_Array when E /= 0 loop
   Put_Line (E'Img);
end loop;
User-Defined Literals

Reference AI: AI12-0249 AI12-0295 AI12-0342

Supported by: -gnat2020

Compiler support is added for three new aspects (Integer_Literal, Real_Literal, and String_Literal). This allows to create types initialized by these literals.

Parallelism

GNAT Pro support for parallel computing is still under evaluation, which also includes experiments with other language-based technologies, in particular CUDA and OpenCL.

Common Code Generator (CCG)

The Common Code Generator (CCG) is an Ada-to-C compiler that can leverage a target C compiler to deploy Ada code to a platform that is not yet supported by GNAT Pro. The subset of the language supported by this tool has been extended, to include in particular subprogram instantiation, better variants records, more representation clauses and elaboration code restrictions.

IDE

You will find this information in the GNAT Studio release notes.

GNATbench now supports Eclipse 4.17 as well as WindRiver Workbench 4 provided as part of the SR0650 release.

Libraries

Libadalang

The Libadalang Ada analysis library has been augmented with a number of predefined properties, support for aggregate projects and other optimizations. See more details in the Libadalang documentation

GNATcoll

A new module in gnatcoll-bindings is added providing high-level bindings to the OpenMP library. Support for parallel sort is available currently.

Platforms

New Targets

The following platforms are now supported:

  • Bare Metal RISC-V 32 bits, hosted on Windows and Linux, for Ada and C

  • Linux ARM 32 bits hosted on Windows, for Ada, C and C++

  • VxWorks 7 version 630+, on ARM, x86 and PowerPC for Ada and C++

  • Bare Metal Leon3 products now support Leon3v7

Host Support

GNAT Pro 21 will support the following representative Linux distributions:

  • Red Hat Enterprise Linux 7 and 8

  • SuSE Linux Enterprise Server 12 and 15

  • Ubuntu 18.04 LTS and 20.04 LTS

The following distributions will no longer be supported:

  • Red Hat Enterprise Linux 6

Windows support is kept unchanged with the following versions:

  • Windows 8.1 and 10

  • Windows Server 2012, 2012R2, 2016 and 2019

Platform Status Changes

The following platforms are now supported in Long Term Support mode. This means that they will still receive fixes and minor improvements, but will not be upgraded to new major versions of the technology:

  • VxWorks 6 (LTS on GNAT Pro 20)

The following platforms are now only available on GNAT Pro Assurance as a Sustained Branch. A Sustained Branch is a stabilized branch on the technology on which only critical fixes can be provided, suitable for high-integrity and certified application development.

  • VxWorks 653 2.x (Sustained Branches available up to GNAT Pro 20)

  • VxWorks 6 Cert (Sustained Branches available up to GNAT Pro 20)

The following platforms are now Baselined. A Baselined platform is a supported platform that will no longer be updated with fixes. AdaCore can still provide advice and workarounds on the technology.

  • VxWorks 5 (Baselined on GNAT Pro 7.4 LTS 20)

  • iOS (Baselined on GNAT Pro 19 LTS 19)

  • MacOS X (Baselined on GNAT Pro 20)