FRidh
September 6, 2019, 3:58pm
1
I would like a stdenv that uses ccache, gcc 9 and binutils 2.32. Using ccache and gcc 9 is no problem, e.g.
stdenv = overrideCC gcc9Stdenv (ccacheWrapper.override { unwrappedCC = gcc9Stdenv.cc.cc; });
works fine.
Now, I need binutils
in there as well. I think it should be done in the following way
stdenv = let
binutils-unwrapped = pkgs.binutils.overrideAttrs(oldAttrs: rec {
version = "2.32";
name = "binutils-${version}"; # Ignore target from name
src = pkgs.fetchurl {
url = "mirror://gnu/binutils/${name}.tar.bz2";
sha256 = "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z";
};
patches = [];
});
binutils = pkgs.wrapBintoolsWith {
bintools = binutils-unwrapped;
};
gcc9Stdenv = overrideCC pkgs.gccStdenv (pkgs.wrapCCWith {
cc = pkgs.buildPackages.gcc9.cc;
bintools = binutils;
});
in overrideCC gcc9Stdenv (ccacheWrapper.override { unwrappedCC = gcc9Stdenv.cc.cc; });
Unfortunately the binutils 2.3.2 does not get picked up.
This is probably because gcc9 itself depends on binutils? So maybe you need to add gcc9 = pkgs.buildPackages.gcc9.override { inherit binutils; };
to your lets, and use it accordingly… I’m not taking into account the gcc wrapper here, so it’s probably not as simple as that.
1 Like
FRidh
September 9, 2019, 8:17am
3
So far:
gcc-unwrapped = pkgs.buildPackages.gcc9.override { bintools = binutils; };
binutils-unwrapped = pkgs.binutils.overrideAttrs(oldAttrs: rec {
version = "2.32";
name = "binutils-${version}"; # Ignore target from name
src = pkgs.fetchurl {
url = "mirror://gnu/binutils/${name}.tar.bz2";
sha256 = "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z";
};
patches = [];
});
binutils = pkgs.wrapBintoolsWith {
bintools = binutils-unwrapped;
};
gcc-wrapped = pkgs.wrapCCWith {
cc = gcc-unwrapped.cc;
bintools = binutils;
};
gccStdenv = overrideCC pkgs.gccStdenv gcc-wrapped;
in overrideCC gccStdenv (ccacheWrapper.override { unwrappedCC = gccStdenv.cc.cc; });
I think the next issue is that in pkgs/development/compilers/gcc/9/default.nix
the attribute targetPackages.stdenv.cc.bintools
is used…
FRidh
September 9, 2019, 9:41am
4
The following solutions works:
stdenv = let
gcc-unwrapped = pkgs.buildPackages.gcc9.override { bintools = binutils; };
binutils-unwrapped = pkgs.binutils-unwrapped.overrideAttrs(oldAttrs: rec {
version = "2.32";
name = "binutils-${version}"; # Ignore target from name
src = pkgs.fetchurl {
url = "mirror://gnu/binutils/${name}.tar.bz2";
sha256 = "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z";
};
patches = [];
});
binutils = pkgs.wrapBintoolsWith {
bintools = binutils-unwrapped;
};
ccacheWrapper = let
extraConfig = ''
export CCACHE_COMPRESS=1
export CCACHE_DIR=/var/cache/ccache
export CCACHE_UMASK=007
'';
in (ccache.links { unwrappedCC = gcc-unwrapped.cc; inherit extraConfig;});
gcc-wrapped = pkgs.wrapCCWith {
cc = ccacheWrapper;
bintools = binutils;
};
gccStdenv = overrideCC pkgs.gccStdenv gcc-wrapped;
in gccStdenv;