Hi all, I need to work on a project using an old version of GCC (6.3.0). It needs to target armv7l-linux-gnueabihf
. I found this (blessed!) guide that explains how to build an old version of GCC, for cross compiling. I followed it and I can get a functioning arm-linux-gnueabihf-gcc
. However, for portability and to share the repo with other developers, I want to use a nix-shell
to provide a reproducible build environment, also getting some dependencies that cannot be get via CMake FetchContent.
I can’t manage, however, to get a nix-shell with the correct GCC: either is the new one, or a native one. For instance, I tried:
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05";
pkgs = import nixpkgs { config = {}; overlays = []; };
in
pkgs.callPackage(
{mkShell, gcc6}:
pkgs.mkShellNoCC {
nativeBuildInputs = with pkgs.buildPackages; [ gcc6 ];
}
) {}
that gave me a GCC 6.5.0, but not a cross compiling one. If I try to add
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05";
pkgs = import nixpkgs { config = {}; overlays = []; crossSystem = { config = "armv7l-linux"; } ; };
# HERE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
in
pkgs.callPackage(
{mkShell, gcc6}:
pkgs.mkShellNoCC {
nativeBuildInputs = with pkgs.buildPackages; [ gcc6 ];
}
) {}
it fails the compilation of the shell with
*** Configuration armv7l-unknown-linux-gnu not supported
make: *** [Makefile:4544: configure-gcc] Error 1
error: builder for '/nix/store/zkvfs4bgpw5ddr2h0j8whfb6pmlng979-armv7l-linux-nolibc-gcc-13.2.0.drv' failed with exit code 2
error: 1 dependencies of derivation '/nix/store/klc97v50zd07aqlwki3ivyksfn6rmbdl-armv7l-linux-nolibc-gcc-wrapper-13.2.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/jg72lclamkm6xxvmgc5q621g5xd51w2p-libgcc-armv7l-linux-13.2.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/nr5qq8rd57fww92in0dxrapxpfq9yxgz-stdenv-linux.drv' failed to build
error: 1 dependencies of derivation '/nix/store/vis6fx6n93zn7fbc7dhlsd42divp7dlh-glibc-armv7l-linux-2.39-52.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9zygbf63p2j7f72qxrzvcis34dqavy0x-armv7l-linux-gcc-wrapper-6.5.0.drv' failed to build
Using instead
let
pkgs' = (import <nixpkgs> {}).pkgsCross.armv7l-hf-multiplatform;
in
pkgs'.mkShell {
packages = with pkgs'; [
];
}
i obtain the GCC cross compiler, but too new (14.2).
While if i try to use a commit of Nixpkgs as old as i should need (17.03):
let
# pkgs' = (import <nixpkgs> {}).pkgsCross.armv7l-hf-multiplatform;
pkgs' = (import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/1849e695b00a54cda86cb75202240d949c10c7ce.tar.gz") {}).pkgsCross.armv7l-hf-multiplatform;
in
pkgs'.mkShell {
packages = with pkgs'; [
];
}
i get that the returned pkgs don’t have the attribute pkgsCross
Am I doing something wrong? Thanks!