ada_toolchain
Rules
Providers
ada_toolchain
load("@rules_ada//ada:ada_toolchain.bzl", "ada_toolchain")
ada_toolchain(name, ada_std, ar, args, artifact_name_patterns, bind_flags, binder, compile_flags,
compiler, compiler_id, compiler_lib, dynamic_runtime_lib, enabled_features, gcov,
known_features, static_runtime_lib, target_triple)
Defines an Ada toolchain: the GNAT compiler (gcc), binder (gnatbind) and archiver (ar), the runtime libraries, and the arguments every action is built from.
The hermetic-gnat toolchains shipped with rules_ada are created and
registered by its module extension; this rule is only needed to define a custom
toolchain around a GNAT installation that rules_ada does not ship.
How the toolchain builds its command lines is declared with
ada_args targets listed in args; rules_ada ships
complete link lines per platform family under
@rules_ada//ada/toolchains/args/... that can be reused, extended or
replaced. The GNAT runtime archives are listed in static_runtime_lib,
tasking runtime first:
load("@rules_ada//ada:ada_toolchain.bzl", "ada_toolchain")
load("@rules_ada//ada/toolchains:defs.bzl", "LINK_ACTIONS", "ada_args")
ada_args(
name = "system_libs",
actions = LINK_ACTIONS,
args = ["-lm", "-lpthread", "-ldl", "-lrt"],
)
ada_toolchain(
name = "gnat_toolchain",
compiler = "@gnat//:bin/gcc",
binder = "@gnat//:bin/gnatbind",
ar = "@gnat//:bin/ar",
ada_std = "@gnat//:ada_std",
compiler_lib = "@gnat//:compiler_lib",
gcov = "@gnat//:bin/gcov",
compile_flags = ["-O2"],
static_runtime_lib = [
"@gnat//:lib/gcc/x86_64-pc-linux-gnu/16.1.0/adalib/libgnarl.a",
"@gnat//:lib/gcc/x86_64-pc-linux-gnu/16.1.0/adalib/libgnat.a",
"@gnat//:lib/gcc/x86_64-pc-linux-gnu/16.1.0/libgcc.a",
],
args = [
"@rules_ada//ada/toolchains/args/elf:link_line",
":system_libs",
],
known_features = ["@rules_ada//ada/toolchains/features:static_libgcc"],
target_triple = "x86_64-pc-linux-gnu",
)
See the toolchains documentation for the variables available to ada_args,
the shipped link lines, features and dynamic_runtime_lib.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| ada_std | The Ada standard library (adalib and adainclude). | Label | optional | None |
| ar | The archiver executable (ar or gcc-ar). If not set, the CC toolchain's archiver is used. | Label | optional | None |
| args | ada_args and ada_args_list targets expanded, in this order, into every action they apply to. A link line is built entirely from these; see @rules_ada//ada/toolchains/args/... for the shipped ones. | List of labels | optional | [] |
| artifact_name_patterns | Output file name per category with %{name} standing for the target name. Categories: executable (default %{name}), shared_library (lib%{name}.so), static_library (lib%{name}.a). | Dictionary: String -> String | optional | {} |
| bind_flags | Additional flags for gnatbind. | List of strings | optional | [] |
| binder | The gnatbind executable for elaboration ordering and consistency checking. | Label | optional | None |
| compile_flags | Additional compiler flags for Ada compilation. | List of strings | optional | [] |
| compiler | The Ada compiler executable (gcc with GNAT support). | Label | optional | None |
| compiler_id | Identifier for the Ada compiler. Currently only 'gnat' is supported. | String | optional | "gnat" |
| compiler_lib | GCC support files (backends, shared libs, runtime libs like libgcc.a, libatomic.a). | Label | optional | None |
| dynamic_runtime_lib | Shared runtime libraries the compiler driver links implicitly when the static_libgcc feature is disabled (e.g. macOS libgcc_s.1.1.dylib). They are staged next to each linked output with a relative rpath and carried in its runfiles. Leave empty where the system provides them, as on Linux. | List of labels | optional | [] |
| enabled_features | ada_feature targets on by default for every target using this toolchain; each must also be in known_features. A target turns one off with features = ["-name"]. | List of labels | optional | [] |
| gcov | The gcov executable for coverage support. | Label | optional | None |
| known_features | ada_feature targets the toolchain understands. The arguments of enabled ones are emitted after args, in this order. @rules_ada//ada/toolchains/features:static_libgcc is the one the rules themselves know. | List of labels | optional | [] |
| static_runtime_lib | Runtime archives linked, in this order, after the dependency libraries into every executable and (on Windows) shared library: libgnarl.a first, then libgnat.a, libgcc.a, and libatomic.a where needed. GNU ld scans archives once, so the order matters. | List of labels | optional | [] |
| target_triple | GCC target triple (e.g., 'aarch64-apple-darwin24.6.0', 'x86_64-pc-linux-gnu'). | String | optional | "" |
AdaToolchainInfo
load("@rules_ada//ada:ada_toolchain.bzl", "AdaToolchainInfo")
AdaToolchainInfo(ada_std, ar, args, args_files, artifact_name_patterns, bind_flags, binder,
compile_flags, compiler, compiler_id, compiler_lib, dynamic_runtime_lib,
enabled_features, gcov, known_features, label, process_wrapper, static_runtime_lib,
target_triple)
Information about a configured Ada toolchain.
FIELDS