Cross-compile rust app for powerpc-unknown-linux-muslspe

Hi, I need to compile wgautomesh for Turris 1.x which runs on a rather old PowerPC-SPE architecture.

The main issue so far as I can tell is that the latest GCC version which supports this arch is 8.4.0 but this version is no longer in nixpkgs.

I’m completely lost in how gcc is used and built in nixpkgs and I have no idea how to build v8.4.0, nor, tbh, I have any idea how to build rust apps in Nix in the first place.

So far I’ve got this WIP flake:

{
  description = "wgautomesh";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/a3073c49bc0163fea6a121c276f526837672b555";
  inputs.cargo2nix = {
    # As of 2022-10-18: two small patches over unstable branch, one for clippy and one to fix feature detection
    url = "github:Alexis211/cargo2nix/a7a61179b66054904ef6a195d8da736eaaa06c36";
    inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, cargo2nix }:
  let
    pkgs = import nixpkgs {
      system = "x86_64-linux";
      overlays = [ cargo2nix.overlays.default ];
    };
  {
    turrispkg = let
      target = "powerpc-unknown-linux-muslspe";
    in pkgs.rustPlatform.buildRustPackage {
      pname = "wgautomesh";
      version = "0.1.0-turris";
      src = "./.";
      cargoBuildFlags = [ 
        "--target=${target}"
        "-Z build-std"
      ];
      cargoLock = { lockFile = ./Cargo.lock; };
      nativeBuildInputs = [ (pkgs.gcc.override {version = "8.4.0";}) ];
    
    };
  };
}

But of course gcc doesn’t have version attr. I’ve been looking at the source of gcc derivation but I honestly have no idea what I’m looking at or whether I’m even looking in the right place :frowning:

This is a one-off so a quick’n’dirty solution (such as nix shell with manual builds) works for me, so long as I can get a statically-built binary out of it.

Any help greatly appreciated!

one more thing - I tried to build this on a Mint machine with cargo build -Z build-std --target powerpc-unknown-linux-muslspe --release and was mostly successful (stdenv built fine) except the very last step where the build failed because of missing SPE support in gcc. That’s why I think the main issue is GCC version.