Can we build `pkgs.pkgsi686Linux.*` using cross-compilation?

Can we build pkgs.pkgsi686Linux.* using cross-compilation on host platform which is x86_64?

The advantages are:

  • it would allow to build huge projects like pkgsi686Linux.firefox, 32-bit compiler crashes with out-of-memory building firefox
  • C++ compilers running on x86_64 are generally faster. Build of pkgs.pkgsi686Linux.chromium currently (using a 32-bit compiler) takes about 2x time compared to pkgs.chromium
  • unlike i686-linux, pkgs.pkgsi686Linux on x86_64 can always use SSE2 instead of i387
  • using SSE2 means programs like fontforge, imagemagick, inkscape will produce on x86_32 the same output as on x86_64 and aarch64, so pkgs.pkgsi686Linux.<fonts> (not fixed-output ones) will be the same as pkgs.<fonts>.
  • pkgs.pkgsI686Linux's gcc.arch can inherit gcc.arch of the whole system. So if gcc.arch allows using for example SSE4.2 in x86_64 code, so will be in x86_32 (-march= is not the same for 32 and 64 bit, a simple conversion table will be needed)
  • it would make cross-compilation more like a first-class citizen of nixpkgs
3 Likes

Another interesting package set / platform is the x32 ABI. The ease of cross-compilation and specifying extremely granular platforms in Nixpkgs lets us explore some really unique approaches for ordinary x86_64 hardware.

1 Like

AFAIK, it requires many patches some of which are abandoned, while switching from 32-bit to 64-bit compiler to compile x64_32 looks simple, straightforward and safe.

On the other hand, 32-bit-only machines would become even more of a second-class citizen. (e.g. they couldn’t build their own packages without some extra complications) EDIT: allowing reliance on SSE2 would be even “worse” in that respect.

x32 ABI looked like an interesting idea (to me, years ago), but apparently the benefits weren’t generally enough for people to really maintain yet another architecture.

Actually, they can and currently the only way to build X86_32-bit code (even indented to run on 64-bit machine) on NixOS is to use 32-bit compilers.
Cross-compilation covers only small number of packages as its mainly supported case is building ARM code on X86. Building X86_32 on X86_64 is not well supported.