NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.73k stars 13.86k forks source link

libselinux doesn't cross-compile from i686 #143903

Closed dwf closed 2 years ago

dwf commented 2 years ago

Describe the bug

Cross-compiling libselinux from i686 currently fails.

Steps To Reproduce

Steps to reproduce the behavior:

  1. nix-build -A pkgsi686Linux.pkgsCross.raspberryPi.libselinux '<nixpkgs>'

Expected behavior

The derivation builds successfully.

Additional context

The build fails with

armv6l-unknown-linux-gnueabihf-gcc: error: unrecognized command-line option '-mno-tls-direct-seg-refs'

This boils down to a line in the Makefile using uname -m to detect the architecture, which gives the wrong answer for cross-compiles. This should be fixed upstream too, but could be fixed by patching the Makefile in the meantime.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[nix-shell:~/cross-system]# nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.74, NixOS, 21.05.3892.70904d4a992 (Okapi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.16`
 - channels(root): `"nixos-21.05.3892.70904d4a992, unstable-21.11pre323695.9aeeb7574fb"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
r-burns commented 2 years ago

It looks like buildroot has a simple for fix - we can provide the host ARCH explicitly:

https://git.busybox.net/buildroot/commit/?id=cfa74ee3218d4a39615870abb72a0b15bf21eba4

I will open a PR for this shortly.

I would suggest also filing an upstream issue in libselinux for this, as using uname to detect the host platform is clearly incorrect.