Open trofi opened 1 year ago
I think the main cause is that cross-compiler version used to cross-build
gcc
does not match: cross-buildinggcc-13
requiresgcc-13
cross-compiler presence.
Yes. Unfortunately pkgsCross
has its own screwy bootstrapping scheme (see libcCrossChooser
, glibcCross
, etc). It really should work by adding extra stages to stages.nix
, but we have a bunch of assumptions in nixpkgs that there will always be exactly two stages (and no more) after the "native packageset". These two stages are in pkgs/stdenv/cross/default.nix
. If it wasn't for that restriction we could just use an extra copy of exactly the same bootstrap sequence in pkgs/stdenv/generic
to build pkgsCross
.
I started working on this, but getting rid of that "exactly two stages after the native bootstrap completes and no more" assumption is really hard to get rid of.
Anyways, I'm working on this bug; I have an idea for a temporary fix.
So apparently we have a bigger problem: there is no way to choose what compiler is used for pkgsCross.FOO.stdenv.cc.cc
. Unless I'm totally missing something.
If we had that, the fix for this bug would be to set that equal to the same version of gcc
that you want to build.
So, this is basically a special case of a more general problem with nixpkgs:
For this particular case, the solution -- for now -- is to not use pkgsCross
for this. Instead, instantiate nixpkgs
explicitly, passing an overlay. In other words, instead of
nix-instantiate . -A pkgsCross.aarch64-multiplatform.gcc13
you should use https://github.com/NixOS/nixpkgs/pull/245169 and
nix-instantiate . -A gcc13 \
--argstr crossSystem "aarch64-linux" \
--arg overlays '[(final: prev: final.lib.optionalAttrs (with prev.stdenv; hostPlatform!=targetPlatform) { default-gcc-version = 13; })]'
The important part here is that gcc.libc.stdenv.cc.cc.version
needs to exactly match gcc.version
. In prose, this means that the glibc
which is passed as the libc
argument to gcc
must have been compiled by exactly the same version of gcc
. This is because glibc
is linked against the libgcc
that came from the gcc
that compiled it.
xgcc
and gcc
.(build==host)!=target
compiler by using the same gcc
for both gccWithoutTargetLibc
and gcc
.However for a build!=(host==target)
compiler which is not the default gcc version, the final compiler will be a non-default version, but we have no way to tell pkgsCross
to compile it using something other than the default version (i.e. https://github.com/NixOS/nixpkgs/issues/245168). So we don't have any way to satisfy the requirement. So the best we can do for now is to simply change the default.
The permanent, automatic fix for this is https://github.com/NixOS/nixpkgs/pull/249301
It's still a bit WIP and I need to test it more, but it's pretty close.
Describe the bug
pkgsCross.aarch64-multiplatform.gcc13
fails to build onx86_64-linux
.Steps To Reproduce
Expected behavior
Build should succeed.
Additional context
I think the main cause is that cross-compiler version used to cross-build
gcc
does not match: cross-buildinggcc-13
requiresgcc-13
cross-compiler presence. The build usesgcc-12
(without recently added bfloat support).Similar kind of problem happens whee we try to build
nixpkgs#pkgsCross.aarch64-multiplatform.gcc11
where newly added warning ingcc12
trigger-Werror=
failures ongcc-11
.Metadata