GNAT Pro 27 Release Notes

We present here a few highlights of the new features in GNAT Pro 27. You can access the complete list in the GNAT Pro 27 feature file.

GCC back-end update

The GNAT Pro Ada, C and C++ has now been updated to GCC 15. See the GCC 15 changes for the corresponding capabilities as well as updates to C and C++.

GNAT Pro LLVM

The GNAT Pro LLVM for Ada compiler has now been updated to LLVM 21. See the LLVM 21 release notes for the corresponding capabilities.

New toolchains

GNAT Pro for Ada adds support for ARM 64-bit targets on Android

The GNAT Pro Ada toolchain is now available on Windows and Linux hosts targeting ARM 64-bit (aarch64) on Android OS. This enables deployment of Ada applications on Android OS 10, 11 and 14 versions.

LLVM-based Ada compilers for 32-bit Linux/Windows

Native variants of GNAT Pro LLVM for Ada are now available for 32-bit Windows and Linux (platform names x86-windows and x86-linux), complementing the already available x86_64 variants. The compilers themselves are 64-bit programs, requiring a 64-bit operating system to execute (like their GCC-based counterparts). The binaries that they produce are 32-bit binaries suitable for execution on 32-bit operating systems, targeting the Pentium 4 processor by default.

GNAT Pro LLVM for Ada targeting riscv64-elf

The new riscv64-elf-linux64 port of the LLVM-based Ada compiler targets bareboard systems using the 64-bit flavor of the RISC-V architecture. The compiler is hosted on Linux. It includes the same set of Ada runtime libraries as its GCC counterpart. Like the other GNAT Pro LLVM toolchains, it uses the LLVM back-end and links with the LLVM linker lld.

New LLVM-based C compiler package

GNAT Pro LLVM for C is a new package containing Clang, the LLVM-based C compiler, as well as support programs like the GPR tools and the code formatter clang-format. Clang is configured to use LLVM components by default, in particular the LLVM linker lld and the LLVM stack unwinder libunwind (both included in the package). GNAT Pro LLVM for C is currently available as a native toolchain for Linux and Windows on x86 and x86_64.

New LLVM capabilities

New switch -gdwarf-aranges in GNAT Pro LLVM for Ada

The new switch -gdwarf-aranges causes the compiler to emit the additional section .debug_aranges when generating debug information. The Ada runtime needs this section to produce symbolic tracebacks. The gprbuild tool adds the new switch automatically.

New switch -fno-builtin in GNAT Pro LLVM Ada

The new switch -fno-builtin disables the compiler’s implicit builtin knowledge of functions. This prevents it from detecting custom implementations of common library functions like strlen and replacing them with calls to the corresponding libc function. The intended use is bareboard environments where libc is unavailable.

New option -mllvm in GNAT Pro LLVM for Ada

The LLVM-based Ada compiler now supports “-mllvm” for forwarding arbitrary switches to LLVM, mirroring the mechanism available in Clang. Whenever the command line contains “-mllvm”, the option immediately following it is passed through to LLVM. This can be used to influence advanced LLVM features for which no command-line option exists in GNAT Pro LLVM.

GNAT Pro LLVM adds a shared Ada runtime

GNAT Pro LLVM now provides two more flavors of the native Ada runtime for all Linux and Windows targets. In addition to the static libraries (libgnat.a and libgnarl.a), it now includes a shared version of the runtime (libgnat-<version>.so/dll and libgnarl-<version>.so/dll), as well as a static PIC version (libgnat_pic.a and libgnarl_pic.a). The shared version is needed to build regular shared libraries, whereas the static PIC version is required for shared encapsulated stand-alone libraries. The GPR tools will automatically choose the right runtime flavor to build against.

New LLVM switch -menable-experimental-extensions

The new switch is needed with GNAT Pro LLVM for Ada when using RISC-V extensions that LLVM considers experimental, for example because they have not been ratified yet.

GNAT language extensions

New attribute From_Address

The From_Address attribute is a GNAT-defined attribute that (typically) takes an address and a set of array bounds and yields a value of an extended access type; that value designates an array at the given address having the given bounds.

Unsigned_Base_Range aspect

A new pragma/aspect, Unsigned_Base_Range, has been added to explicitly enforce the use of an unsigned base type for signed integer types.

Attribute subprograms

The GNAT compiler now supports an extension feature that allows declaring primitive subprograms whose name has the form of an attribute name (where the prefix is the type for which the subprogram is a primitive), in cases where the attribute names correspond to aspects that denote a subprogram. Specifically, this is supported for the indexing aspects, user-defined literal aspects, Default_Iterator, Put_Image, stream attributes, and constructors. Declaring such a subprogram has the effect of defining the corresponding aspect for the associated type. Use of this feature requires compiling with the -gnatX0 option.

Language conformance

Component clauses for unchecked union components

The compiler now accepts component clauses for record components of unchecked union types.

Support for declare expressions of limited types

When compiling for Ada 2022, declare expressions of limited types are now accepted by the compiler.

More conformant freezing for expression functions

The implementation of the freezing rules of the language for expression functions has been improved. As a consequence, some legal constructs that were rejected by the compiler are now accepted, and some illegal constructs that were accepted by the compiler are now rejected; in this latter case, a very verbose error message is given.

Check for coupled address and alignment clauses

The compiler now performs a run-time alignment check on all machines for an object declared both with an address aspect/clause and an alignment aspect/clause, in order to avoid the erroneous execution specified by the RM 13.3(27) subclause.

Improved resolution for indexing aspects

Ada’s rules for resolving indexing aspects have been revised (by AI22-0154-1) to be more specific in terms of parameter and result types for functions denoted by those aspects. This has the effect of ensuring that within the scope of a type T that specifies an indexing aspect, other types declared in that same scope that have primitives with the same name as the function name given in T’s aspect will not make that aspect illegal.

Streamlined implementation of subpools and AI12-0331

The implementation of storage subpools has been streamlined and the Binding Interpretation specified by AI12-0331 has been implemented.

Enhanced implementation of Valid_Scalars attribute

The Valid_Scalars attribute now works for tagged extensions.

Nonconfirming size clauses on floating-point objects

Nonconfirming size clauses on objects of floating-point types are now all rejected (only those specifying a size less than that of the subtype of the objects were previously rejected).

Restriction lifted on Valid_Scalars attribute

The Valid_Scalars attribute now works for private tagged types.

Accessibility checks

Better implementation of static accessibility checks

A few loopholes have been plugged in the implementation of static accessibility checks affecting the different versions of the language:

  • in Ada 2005, illegal assignments to objects of anonymous access types done in extended return statements are now flagged,

  • in Ada 2005 and 2012, illegal conversions between access types done in extended return statements are now flagged,

  • in Ada 2012, more cases of illegal actuals passed for explicitly aliased formal parameters in calls present in return statements are now flagged,

  • in Ada 2022, the relaxed rules for explicitly aliased formal parameters are now implemented.

Better error message for static accessibility checks

The error messages given for the failure of static accessibility checks now have a more consistent wording and mention the corresponding Ada RM rule.

More robust implementation of dynamic accessibility

The implementation of the dynamic accessibility checks that are specified by the Ada RM to prevent dangling references has been overhauled.

Strict accessibility checks for container references

The compiler now generates strict accessibility checks for the manual invocation of the Reference or Constant_Reference functions of the various containers declared in the run-time library. In particular, it is no longer possible to get an access value designating a specific element of the container by using those functions and save it away; instead the element must be accessed directly through values of the reference types (possibly stored in local variables).

Run-time library

Light runtime can now be rebuilt in static PIC mode

It is now possible to rebuild the light Ada runtime in static PIC mode. To do so, set the scenario variable LIBRARY_TYPE to “static-pic” when invoking gprbuild, i.e., “gprbuild -XLIBRARY_TYPE=static-pic -P runtime_build.gpr”. Previously, only the values “static” and “dynamic” were allowed. The main use case for the static PIC build is shared encapsulated stand-alone libraries.

Better aborts for suspension objects

Aborting tasks waiting in calls to Ada.Synchronous_Task_Control.Suspend_Until_True now reliably unblocks the aborted tasks.

Bareboard No_Standard_Allocators_After_Elaboration

Restriction No_Standard_Allocators_After_Elaboration is now supported on all bareboard runtime profiles.

New Calling_Entity function

The function System.Traceback.Symbolic.Calling_Entity is now available on systems that support symbolic debugging information. It provides a convenient way to get information about the calling subprogram, for example for logging purposes.

Ada.Command_Line.Environment easier to use

Ada.Command_Line.Environment no longer requires initializing a gnat_envp variable for proper operation when used with a non-Ada main.

Bounded_Indefinite_Holders added to runtime library

The predefined unit Ada.Containers.Bounded_Indefinite_Holders, as described Ada RM A.18.32, has been added to the GNAT runtime library.

Deterministic streaming of Long_Long_Float

On some platforms, Long_Long_Float uses IEEE extended precision, which only uses 80 bits per value, but is padded to 128 bits for streaming. The compiler now consistently sets the padding bits to zero.

Windows enhancements

Thread descriptions for Ada tasks on Windows

On Microsoft Windows, GNAT now uses SetThreadDescription for the threads that underlie Ada tasks. The descriptions are the names of the tasks as found in the Ada source code. This makes it easier to identify threads created by the GNAT runtime in system-monitoring tools.

Native TLS support on Windows platforms

The compiler now implements native Thread Local Storage support on Windows platforms.

Switch from MSVCRT to UCRT on Windows platforms

The compiler now uses UCRT instead of MSVCRT as the underlying C runtime library on Windows platforms. The exception is the Win32.CRT binding, which is part of the Win32Ada library and still uses MSVCRT.

Optimizations

Better code for BIP calls with controlled components

The GNAT compiler now generates more efficient code for calls to build-in-place functions with a fixed-size limited record result that has controlled components. These formerly required allocation of the result on the secondary stack, but now the storage for the result can be allocated on the caller side.

Faster copy of small discriminated record objects

Copy operations generated between small local objects whose nominal subtype is a discriminated record type with default discriminants and a variant part are now implemented more efficiently.

Speedup of Bounded_Vectors.Append in some cases

In (any instance of) Ada.Containers.Bounded_Vectors, for the procedure overload of Append that takes exactly two parameters (one of type Vector, one of type Element_Type), the execution time is reduced in the case where either of the GNAT-defined checks Container_Checks or Tampering_Check are suppressed.

Reduced dependency footprint of ignored assertions

The compiler will now remove any dependences on packages that originate from ignored assertion pragmas.

Diagnostics

Style-check warning for indented compilation units

GNAT now emits a style-check warning on compilation units where the unit’s initial keyword (such as “package” or “procedure”) is indented.

Better error on invalid prefix in selected component

The compiler now gives a more precise and/or more verbose error message for an invalid prefix in a selected component.

Warn for unused use_package_clauses in more cases

The compiler now gives a warning for unused use_package_clauses even when a use_package_clause for a child package is also present.

Tools

Alire for GNAT Pro is now available

Alire (Ada LIbrary REpository) is now available as part of GNAT Pro. Alire for GNAT Pro provides a package manager approach to managing Ada libraries and components.

Hosts

Alire for GNAT Pro is available on the following hosts:

  • x86_64 Linux

  • x86_64 Windows

  • Aarch64 Linux

Alire Crates for GNAT Pro is now available

The initial release of Alire for GNAT Pro ships with a number of crates including:

  • gnatcoll

  • libgpr2

  • libadalang

  • xmlada

Alignment of keywords in record rep clauses

GNATformat now aligns the at and range keywords on consecutive record representation clauses.

h2ads adds subtype defs for types from other scopes

When a header uses a type from an included scope, in a variable declaration, or in a function signature, h2ads now introduces a subtype definition as a shortcut to the original type, making the bindings more user-friendly.

GNATformat keyword casing control

GNATformat now allows controlling keyword casing using the new --keyword-casing CLI option (keep [default], lower, upper) or via the Format’Keyword_Casing attribute in GPR project files.

GNATpolyglot (beta) is available

GNATpolyglot, an automated binding generating utility designed to facilitate the development of mixed language applications is available in a beta release. This includes support for binding generation to enable calling Ada code from C++, Rust, and Java.

GPRBuild2 is now selected by default

In the 26 release we introduced GPRbuild2, the successor to our build orchestration tool GPRBuild. As of the 27 release, GPRbuild2 is the build engine selected by default. GPRbuild2 models the build as a directed acyclic graph (DAG) of actions, and includes support for user-defined actions. You can find additional details about GPRbuild2 in the User Guide.

GtkAda 4 is now available

GtkAda 4 introduces many changes from GtkAda 3. GtkAda 3 will remain available for some time, and AdaCore support can assist with any issues encountered as projects are transitioned to GtkAda 4. GtkAda-specific widgets are not yet available in GtkAda 4. For more information, please consult the GtkAda transition guide in the documentation.

XML/Ada hardening

Disabling of external generics, parameters, and DTDs

New SAX features have been added for disabling the loading of external generic entities, parameter entities, and doctype definitions (DTDs).

Restricting expanded entity counts and size

New SAX limits have been added to allow restricting the maximum number of expanded entities and the total size of expanded text.

Disabling of XML Doctype Declarations processing

A new SAX feature has been added for disallowing Doctype Declarations (DTDs) entirely during parsing.