I want to use gcc with different version other than the default gcc10 when crossing compile
With the following config:
let
pkgs = import <nixpkgs> { };
pkgsCross = import <nixpkgs> {
crossSystem = { config = "x86_64-unknown-linux-gnu"; };
};
localSystem = pkgs.lib.systems.elaborate builtins.currentSystem;
crossSystem =
pkgs.lib.systems.elaborate { config = "aarch64-unknown-linux-gnu"; };
crGcc10 = pkgs.wrapCCWith {
cc = pkgs.gcc10.cc.override {
libcCross = pkgsCross.libcCross;
stdenv = pkgs.stdenv.override {
hostPlatform = localSystem;
buildPlatform = localSystem;
targetPlatform = crossSystem;
};
};
};
in crGcc10
but with no luck, yielding error:
configure: error: cannot execute: /nix/store/fh1a6sp991q60d93nb78h75rq429cl41-binutils-wrapper-2.35.2/bin/aarch64-unknown-linux-gnu-ld: check --with-ld or env. var. DEFAULT_LINKER
There is only ld
under that folder, no aarch64-unknown-linux-gnu-ld
I also tried with:
with import <nixpkgs> {
crossSystem = { config = "x86_64-unknown-linux-gnu"; };
};
let
localSystem = lib.systems.elaborate builtins.currentSystem;
crossSystem = lib.systems.elaborate { config = "aarch64-unknown-linux-gnu"; };
crGcc10 = wrapCCWith {
cc = gcc10.cc.override {
stdenv = stdenv.override {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = crossSystem;
};
};
};
in crGcc10
According to env-vars
, CC is set to x86_64-unknown-linux-gnu-gcc
which is unwrapped in PATH. Yielding that config
cannot compile anything