Ada: Difference between revisions
Appearance
Tomodachi94 (talk | contribs) m minor cleanup |
m →Building static binaries: fix indentation |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
[https://ada-lang.io/ Ada] is a programming language. | |||
The GNAT Ada toolchain is fully packaged in | == Building programs == | ||
=== GNAT === | |||
The GNAT Ada toolchain is fully packaged in [[Nixpkgs]] and can be used to build software. It has a bit less convenience than typical [[C]]/[[C++]] toolchains due to its small user base. A simple Ada program using GPR can be built as follows: | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
| Line 43: | Line 46: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
== Building | ==== Building static binaries ==== | ||
If you try to build static binaries, you need to add the static version of libc manually. For this, add <code>glibc</code> to the derivation parameters (at the top) and add the following to the derivation itself. | If you try to build static binaries, you need to add the static version of libc manually. For this, add <code>glibc</code> to the derivation parameters (at the top) and add the following to the derivation itself. | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
buildInputs = [ | |||
glibc.static | |||
]; | |||
</syntaxHighlight> | </syntaxHighlight> | ||
There is an example on [https://github.com/blitz/adahello GitHub]. | There is an example on [https://github.com/blitz/adahello GitHub]. | ||
[[Category:Languages]] | |||
Latest revision as of 07:21, 16 July 2026
Ada is a programming language.
Building programs
GNAT
The GNAT Ada toolchain is fully packaged in Nixpkgs and can be used to build software. It has a bit less convenience than typical C/C++ toolchains due to its small user base. A simple Ada program using GPR can be built as follows:
{ stdenv, gnat, gprbuild, glibc }:
stdenv.mkDerivation {
pname = "an-ada-program";
version = "1.2.3";
src = ...;
nativeBuildInputs = [
gprbuild
gnat
];
dontConfigure = true;
buildPhase = ''
runHook preBuild
gprbuild
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
# Only install what we need to run the binary.
gprinstall --prefix=$out hello.gpr \
--no-project \
--no-manifest \
--mode=usage
runHook postInstall
'';
}
Building static binaries
If you try to build static binaries, you need to add the static version of libc manually. For this, add glibc to the derivation parameters (at the top) and add the following to the derivation itself.
buildInputs = [
glibc.static
];
There is an example on GitHub.