Open Cynerd opened 1 year ago
Eh...
$ nix eval nixpkgs#legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.stdenv.hostPlatform.system
"x86_64-linux"
$ nix eval nixpkgs#legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux.stdenv.hostPlatform.system
"armv7l-linux"
$ nix eval nixpkgs#legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsMusl.stdenv.hostPlatform.system
"armv7l-linux"
It turns out that having armv7l
there is not actually something completely invalid, but rather just strange and non-intuitive. I thought that the following chain is true but no (I am ignoring target there for simplicity)..:
legacyPackages.x86_64-linux
-> build: x86_64-linux, host: x86_64-linux
legacyPackages.x86_64-linux.pkgsi686Linux
-> build: i686-linux, host: i686-linux
legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform
-> build: x86_64-linux, host: i686-linux
legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild
-> build: x86_64-linux, host: x86_64-linux
legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux
-> build: i686-linux, host: i686-linux
This would make sense to me but no... It turns out it is instead:
legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux
-> build: i686-linux, host: armv7l-linux
legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux.buildPackages
-> build: i686-linux, host: i686-linux
What makes it confusing is that this is the same package set, but it doesn't feel like it should be:
legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux
legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildHost.pkgsi686Linux
The core issue is then probably that glibc_multi
should not be possible to be built when the host is not i686
as it results in gcc_multi
build failure.
It might also be desirable to resolve the confusion I fell into here.
For completeness, my original entry point to this was stdenv_32bit
which uses gcc_multi
. The typical approach in the packaging when software needs a 32-bit host compiler, I would expect, is to use stdenv_32bit
. The same applies when I need it to compile some build tool during cross-compilation. I would simply use buildPackages.stdenv_32bit
but that doesn't work, and neither does buildPackages.buildPackages.stdenv_32bit
. Those environments consider a local system to be i686
but a host system to be the cross-compilation target.
I have more discoveries because nobody else seems to care about this... It turns out that behaviour, where pkgsi686Linux
has host and target set to the target of the original package set, is a limitation of package sets instantiation. There is only possible to pass localSystem
and crossSystem
. The pkgsi686Linux
set is generated by reevaluating the package set with these variables set to something other than the original set. The issue is that when the original set has the same host and build platform but a different target, it can only set the build and host platform. There is just no possibility of getting set where the target is different from the host directly. The only option is to use pkgsi686Linux.buildPackages
to get the correct combination of platforms.
@Cynerd I ran into this on multiple cross compilation attempts. What do you think would be a way forward?
@wucke13 I think the core issue is that we can't set a target platform. We can only set localSystem
and crossSystem
. The neighbor package set like the ones discussed here sometimes requires a custom target platform that can't be directly archived through the standard nixpkgs set evaluation. It might be possible to evaluate it with the correct crossPlatform
but then take buildPackages
of that set instead. Honestly, I am not experienced enough to fix this right now, that is also why I am writing this here and not fixing it.
I have more discoveries because nobody else seems to care about this... It turns out that behaviour, where
pkgsi686Linux
has host and target set to the target of the original package set, is a limitation of package sets instantiation. There is only possible to passlocalSystem
andcrossSystem
. Thepkgsi686Linux
set is generated by reevaluating the package set with these variables set to something other than the original set. The issue is that when the original set has the same host and build platform but a different target, it can only set the build and host platform. There is just no possibility of getting set where the target is different from the host directly. The only option is to usepkgsi686Linux.buildPackages
to get the correct combination of platforms.
I didn't fully understand this whole issue - but I fixed the fact that pkgsi686Linux
changes the localSystem instead of the crossSystem when "you are already cross" in #303849, specifically in 1028e73e8428f659f2c462c950355cd221b82107.
Can you try whatever you did here ;) on my branch again and see whether that helps?
On my branch mentioned above:
nix-repl> pkgs.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.stdenv.hostPlatform.system
"x86_64-linux"
nix-repl> pkgs.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux.stdenv.hostPlatform.system
"i686-linux"
nix-repl> pkgs.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsMusl.stdenv.hostPlatform.system
"x86_64-linux"
nix-repl> pkgs.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux.stdenv.buildPlatform.system
"x86_64-linux"
nix-repl> pkgs.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux.buildPackages.stdenv.buildPlatform.system
"x86_64-linux"
nix-repl> pkgs.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux.buildPackages.stdenv.hostPlatform.system
"x86_64-linux"
This looks a lot more what you'd expect, I guess?
Steps To Reproduce
Steps to reproduce the behavior:
nix build nixpkgs#legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.gcc_multi
Build log
From
config.log
for 32bit gcc.Additional context
The error is caused by missing file in
glibc-multi
. That is created by mergingglibc
andpkgsi686Linux.glibc
. It turns out that issue is inpkgsi686Linux.glibc
which for some reason uses some options from host platform. This is output ofnix show-derivation nixpkgs#legacyPackages.x86_64-linux.pkgsCross.armv7l-hf-multiplatform.pkgsBuildBuild.pkgsi686Linux.glibc
The system is according to it
i686-linux
but it doesn't look like it. I was unable to find the real reason for this. It might be something instage.nix
. I also tried other packages inpkgsi686Linux
; they all seem to contain paths to armv7l instead of i686.Notify maintainers
@johnae @matthewbauer @danbst
Metadata