Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib, treewide: Add missing MIPS arches, and fix existing usage #35247

Merged
merged 1 commit into from Feb 27, 2018

Conversation

telent
Copy link
Contributor

@telent telent commented Feb 20, 2018

This is just the barest minimum so that nixpkgs can recognize mips/mipsel as systems - although required for building individual derivations for MIPS boards, it is not sufficient if you want to actually build NixOS or even the majority of the nixpkgs collection on those targets.

Motivation for this change

For me this is necessary so that I can build MIPS binaries for NixWRT. I don't expect it to have any other effect.

(I note in passing that there is an existing system mips64el which has bits = 32 set, which seems ... odd. Perhaps it's for a system with a 64 bit kernel and 32 bit userland, but I haven't touched it)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@dtzWill
Copy link
Member

dtzWill commented Feb 21, 2018

Offhand this looks reasonable. It's a bit of groundwork for mips32, but AFAIK not enough to even try to evaluate a mips build just yet.

I ask because other doubles have entries there, and because when I try to use these configs I get something like:

$ nix build -f . --arg crossSystem '{config="mips-unknown-linux-gnu";}' bash
error: while evaluating the attribute 'stdenv' of the derivation 'bash-4.4-p12-mips-unknown-linux-gnu' at /home/will/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating the attribute 'defaultNativeBuildInputs' of the derivation 'stdenv' at /home/will/nixpkgs/pkgs/stdenv/generic/default.nix:72:14:
while evaluating the attribute 'gcc' at /home/will/nixpkgs/pkgs/top-level/all-packages.nix:5798:3:
while evaluating 'lowPrio' at /home/will/nixpkgs/lib/meta.nix:52:13, called from /home/will/nixpkgs/pkgs/top-level/all-packages.nix:5958:10:
while evaluating 'addMetaAttrs' at /home/will/nixpkgs/lib/meta.nix:15:28, called from /home/will/nixpkgs/lib/meta.nix:52:18:
while evaluating 'wrapCC' at /home/will/nixpkgs/pkgs/top-level/all-packages.nix:6713:12, called from /home/will/nixpkgs/pkgs/top-level/all-packages.nix:5958:19:
while evaluating 'wrapCCWith' at /home/will/nixpkgs/pkgs/top-level/all-packages.nix:6697:16, called from /home/will/nixpkgs/pkgs/top-level/all-packages.nix:6713:16:
while evaluating 'callPackageWith' at /home/will/nixpkgs/lib/customisation.nix:113:35, called from /home/will/nixpkgs/pkgs/top-level/all-packages.nix:6698:7:
while evaluating 'makeOverridable' at /home/will/nixpkgs/lib/customisation.nix:72:24, called from /home/will/nixpkgs/lib/customisation.nix:117:8:
while evaluating anonymous function at /home/will/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:8:1, called from /home/will/nixpkgs/lib/customisation.nix:74:12:
while evaluating the attribute 'configureFlags' of the derivation 'glibc-2.26-131-mips-unknown-linux-gnu' at /home/will/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating the attribute 'ARCH' of the derivation 'linux-headers-4.4.10-mips-unknown-linux-gnu' at /home/will/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating the attribute 'platform.kernelArch' at /home/will/nixpkgs/lib/systems/default.nix:25:7:
attribute 'kernelArch' missing, at /home/will/nixpkgs/pkgs/os-specific/linux/kernel-headers/default.nix:17:12

Are more similar changes coming? O:)

@Ericson2314
Copy link
Member

Ericson2314 commented Feb 21, 2018

Can you look at lib/systems/examples.nix? I think the one that is there should be mips32el. Try

nix-store -r /nix/store/jlfhcadzpjyls8y22v3l9f86j86lisxz-mips64el-unknown-linux-gnu-binutils-2.28
nix-store -r /nix/store/pcm4j6k546fprai1fghqyn93faa3mdgc-hello-2.10-mips64el-unknown-linux-gnu
/nix/store/jlfhcadzpjyls8y22v3l9f86j86lisxz-mips64el-unknown-linux-gnu-binutils-2.28/bin/mips64el-unknown-linux-gnu-readelf -a /nix/store/pcm4j6k546fprai1fghqyn93faa3mdgc-hello-2.10-mips64el-unknown-linux-gnu/bin/hello
/nix/store/jlfhcadzpjyls8y22v3l9f86j86lisxz-mips64el-unknown-linux-gnu-binutils-2.28/bin/mips64el-unknown-linux-gnu-ld --help

I see "32s" everywhere.

@telent
Copy link
Contributor Author

telent commented Feb 23, 2018

According to google, the Fuloong MiniPC is based on a Loongson 2F, which wikipedia says is a MIPS64. That doesn't stop it from running 32 bit code (MIPS64 specifies a backward compatibility mode) and it does look rather like whoever set it up for nixpkgs is expecting to do just that. https://en.wikipedia.org/wiki/Loongson#Loongson_2F

For nixwrt so far I've been defining the systems inline where I needed it - e.g. https://github.com/telent/nixwrt/blob/nixwrt/nixwrt/default.nix#L18 but maybe that's a completely back to front way of doing it. I am happy to add an example system and platform for "generic mips-based router" to this PR if you think that makes it more generally useful to other people?

@dtzWill
Copy link
Member

dtzWill commented Feb 23, 2018

I do, because it saves me sorting out what a reasonable configuration might be if I wanted to quickly test targeting mips32 O:).

But that's not a great reason-- I think ideally a suitable "basic" configuration (setting kernelArch) would be automagically inferred from the basic triple?

Anyway don't think this should block on account of any of this, I was just eager to give it a go :).

@Ericson2314
Copy link
Member

Ericson2314 commented Feb 24, 2018

I added some more changes, fixing what is there finally. I was going to point https://hydra.nixos.org/jobset/nixpkgs/ericson2314-cross-trunk at your branch to help you finish things off, but hydra is down ATM. Ping me to do that later if I forget.

Existing "mips64el" should be "mipsel".

This is just the barest minimum so that nixpkgs can recognize them as
systems - although required for building individual derivations onto
MIPS boards, it is not sufficient if you want to actually build nixos on
those targets
@Ericson2314 Ericson2314 changed the title add mips 32-bit and mipsel 32-bit systems lib, treewide: Add missing MIPS arches, and fix existing usage Feb 24, 2018
@dtzWill
Copy link
Member

dtzWill commented Feb 26, 2018

Not that you forgot but just FYI hydra is back up! \o/ @Ericson2314

@Ericson2314
Copy link
Member

Heheh I did. I just did an eval now https://hydra.nixos.org/build/70240205 . It at least evals, though we are getting that same weird "lto isn't a supported language" error in GCC. Whatever, this is still progress so I'm merging.

@Ericson2314 Ericson2314 merged commit dfc5d78 into NixOS:master Feb 27, 2018
@Ericson2314
Copy link
Member

@telent https://hydra.nixos.org/jobset/nixpkgs/cross-trunk will soon include the evaling, but broken fuloong builds. Feel free to replace that with a more relevant/modern mips platform. If you could maintain MIPS jobs if your choosing, that what would be great!

@vcunat
Copy link
Member

vcunat commented Feb 28, 2018

This merge broke stdenv on aarch64. https://hydra.nixos.org/build/70246649

@vcunat
Copy link
Member

vcunat commented Feb 28, 2018

Even changing non-cross stdenv was probably not intended, but I haven't read this.

@Ericson2314
Copy link
Member

Indeed, not intended at all.

dtzWill added a commit to dtzWill/nixpkgs that referenced this pull request Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants