NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.8k stars 1.52k forks source link

extra-platforms detection should be smarter #2595

Open matthewbauer opened 5 years ago

matthewbauer commented 5 years ago

Currently, when system = x86_64-linux, we assume that we can also set extra-platforms = i686-linux. That is not always true. Specifically, you cannot run i686 in these two cases:

In these cases we should NOT set extra-platforms = i686-linux.

We also should think about the idea of "compatible" architectures. Many architectures have backwards compatible support so that:

x86-64 only supports 32 bit modes in some cases (see above). Likewise, aarch64 can only run armv7 on processors that support 32-bit mode, which is not guaranteed. Each of these ARM architectures can run in both big endian and little endian modes. Each of these rules could automatically get added to extra-platforms as well. There are similar ideas with endianness and 64/32-bit modes in PowerPC, MIPS, SPARC, RISC-V, and WASM.

Relevant code:

https://github.com/NixOS/nix/blob/812e39313c2bcf8909b83e1e8bc548a85dcd626c/src/libstore/globals.hh#L265-L270

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

r-burns commented 3 years ago

Still relevant

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

r-burns commented 3 years ago

Still relevant

patryk4815 commented 2 years ago

apple silicon M1 support only 64bit: error: cannot set 32-bit personality: Invalid argument

extra info: https://news.ycombinator.com/item?id=27278019

matthewbauer commented 2 years ago

This is running Linux on the M1 right?

Is there some other way we can what personality the system supports? I think we could just do personality(PER_LINUX32) & if it succeeds enable arm32 & then do personality() to reset it.

patryk4815 commented 2 years ago

@matthewbauer Yep, it is nixos-vm (aarch64 native) on apple M1. There are many problems, but I will create a separate issue for it.

  1. For example binfmt is working bad, because CPU not support 32bit, so choosing/detecting interpreter for binfmt is wrong:

    Zrzut ekranu 2022-03-30 o 21 43 38
  2. Even I fix binfmt for armv7l-linux, but build (trying build armv7 binary) are still failing with error: cannot set 32-bit personality: Invalid argument

  3. Example of using personality: image