Skip to content

Please provide Android compilation example #2328

Closed
@bitestring

Description

@bitestring

Thanks for this wonderful project. I have been spending weeks in trying to build a Haskell library that exports a simple hello world function. I was able to compile it to x86_64 Linux target. But I could not figure out how to build for Android.

My flake.nix looks like this

{
  # This is a template created by `hix init`
  inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
  inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
  inputs.flake-utils.url = "github:numtide/flake-utils";
  outputs = { self, nixpkgs, flake-utils, haskellNix }:
    let
      supportedSystems = [
        "x86_64-linux"
      ];
    in
      flake-utils.lib.eachSystem supportedSystems (system:
      let
        overlays = [ haskellNix.overlay
          (final: prev: {
            hixProject =
              final.haskell-nix.hix.project {
                src = ./.;
                compiler-nix-name = "ghc984"; # Version of GHC to use
                crossPlatforms = p: [p.aarch64-android-prebuilt];
              };
          })
        ];
        pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
        flake = pkgs.hixProject.flake {};
      in flake // {
        legacyPackages = pkgs;

        packages = flake.packages // { 
          default = flake.packages."hello:exe:hello";
        };
      });

  # --- Flake Local Nix Configuration ----------------------------
  nixConfig = {
    # This sets the flake to use the IOG nix cache.
    # Nix should ask for permission before using it,
    # but remove it here if you do not want it to.
    extra-substituters = ["https://cache.iog.io"];
    extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="];
    allow-import-from-derivation = "true";
  };
}

But when building Android target, it gives following error

> checking ABI=64
> checking whether aarch64-unknown-linux-android-clang is gcc... yes
> checking compiler aarch64-unknown-linux-android-clang -O2 -pedantic ... no, gnupro alpha ev6 char spilling
> checking ABI=32
> checking whether aarch64-unknown-linux-android-clang is gcc... yes
> checking compiler aarch64-unknown-linux-android-clang -O2 -pedantic -fomit-frame-pointer ... no, gnupro alpha ev6 char spilling
> configure: error: could not find a working compiler, see config.log for details
For full logs, run 'nix log /nix/store/ayiwnmdck3qvhqwdvdkcrw39wm5s5jfx-gmp-aarch64-unknown-linux-android-6.3.0.drv'.
error: 1 dependencies of derivation '/nix/store/2fmvak2ai523613vdva0c9nn67ahdy4w-hello-exe-hello-aarch64-unknown-linux-android-1.0.0.2.drv' failed to build

Could you please share how to build for Android aarch64 targets? Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions