GNAT on aarch64-darwin

I’m trying to use Ada on Apple Silicon Mac, I found that aarch64-darwin is unsupported (however Nixpkgs Package Index says that aarch64-darwin is supported) and Hydra has no history of it:

~> nix-shell -p gnat
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'shell'
         whose name attribute is located at /nix/store/9l0mfil5wrqk7sf8885mk0m8nrb057w6-source/pkgs/stdenv/generic/make-derivation.nix:541:11

       … while evaluating attribute 'buildInputs' of derivation 'shell'
         at /nix/store/9l0mfil5wrqk7sf8885mk0m8nrb057w6-source/pkgs/stdenv/generic/make-derivation.nix:593:11:
          592|           depsHostHost = elemAt (elemAt dependencies 1) 0;
          593|           buildInputs = elemAt (elemAt dependencies 1) 1;
             |           ^
          594|           depsTargetTarget = elemAt (elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: Unsupported system: aarch64-darwin

Then I use --show-trace and found the why it is unsupported.

In the derivation gnat-bootstrap:

It will download alire’s gnat 12/13/14 binaries on GitHub (alire-project/GNAT-FSF-builds).

GNAT Version x86_64-linux aarch64-linux x86_64-darwin aarch64-darwin
12/13 O X O X
14 O O O X

O = Defined in the versionMap; X = Undefined in the versionMap.

But actually, GNAT 13/14/15/16 provides binaries for aarch64-darwin.

So what is the reason that prevents us from adding these binaries into versionMap and make aarch64-darwin a supported platform?

1 Like

I don’t know but maybe no good reason :person_shrugging:

Did you try?

Nit: that’s a wrong link. The /nixos/ jobsets only have *-linux.
So like Making sure you're not a bot! exists (though it fails recently) here you’d look at Making sure you're not a bot!

EDIT: uh, link preview is making this bad, but I hope people figure this out easily.

1 Like

I forked nixpkgs and added the aarch64-darwin binary:

diff --git a/pkgs/development/compilers/gnat-bootstrap/default.nix b/pkgs/development/compilers/gnat-bootstrap/default.nix
index ef7ed876e..0368d612b 100644
--- a/pkgs/development/compilers/gnat-bootstrap/default.nix
+++ b/pkgs/development/compilers/gnat-bootstrap/default.nix
@@ -60,6 +60,11 @@ stdenv.mkDerivation (
             hash = "sha256-DNHcHTIi7pw0rsVtpyGTyLVElq3IoO2YX/OkDbdeQyo=";
             upstreamTriplet = "x86_64-apple-darwin21.6.0";
           };
+          aarch64-darwin = {
+            inherit url;
+            hash = "sha256-Bjl6iuM2xLknezR92j/kpDYpxqTcxK1v8rffmivOAVw=";
+            upstreamTriplet = "aarch64-apple-darwin23.2.0";
+          };
           x86_64-linux = {
             inherit url;
             hash = "sha256-DC95udGSzRDE22ON4UpekxTYWOSBeUdJvILbSFj6MFQ=";
@@ -77,6 +82,11 @@ stdenv.mkDerivation (
             hash = "sha256-3YOnvuI6Qq7huQcqgFSz/o+ZgY2wNkKDqHIuzNz1MVY=";
             upstreamTriplet = "x86_64-apple-darwin21.6.0";
           };
+          aarch64-darwin = {
+            inherit url;
+            hash = "sha256-3YOnvuI6Qq7huQcqgFSz/o+ZgY2wNkKDqHIuzNz1MVY="; # TODO
+            upstreamTriplet = "aarch64-apple-darwin23.2.0";
+          };
           x86_64-linux = {
             inherit url;
             hash = "sha256-pH3IuOpCM9sY/ppTYcxBmgpsUiMrisIjmAa/rmmZXb4=";
@@ -236,7 +246,8 @@ stdenv.mkDerivation (
         "x86_64-linux"
         "x86_64-darwin"
       ]
-      ++ lib.optionals (lib.versionAtLeast majorVersion "14") [ "aarch64-linux" ];
+      ++ lib.optionals (lib.versionAtLeast majorVersion "13") [ "aarch64-darwin" ]
+      ++ lib.optionals (lib.versionAtLeast majorVersion "14") [ "aarch64-linux" "aarch64-darwin" ];
       sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
     };
   }

But I’m currently stuck: during the build process (GNAT 13), a patch failed.

The nix log:

patching file gcc/ada/gcc-interface/Makefile.in
Hunk #4 FAILED at 791.
1 out of 4 hunks FAILED -- saving rejects to file gcc/ada/gcc-interface/Makefile.in.rej

Thoughts:

  1. Identify the failing path
  2. What is it about?
  3. Is it still relevant?