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

Gnum4 blocks package build on armv7 architectures #211120

Open
TheSirC opened this issue Jan 16, 2023 · 17 comments
Open

Gnum4 blocks package build on armv7 architectures #211120

TheSirC opened this issue Jan 16, 2023 · 17 comments
Labels
0.kind: bug Something is broken 6.topic: exotic Exotic hardware or software platform

Comments

@TheSirC
Copy link

TheSirC commented Jan 16, 2023

Describe the bug

The package gnum4 prevents any package to be built on armv7.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install Nix on a armv7 device
  2. Try to install any package (nix-shell -p hello for example)

Expected behavior

gnum4 should not error on build.

Additional context

The bug seems to have been documented before here since Dec 2021.
It seems to be build as a dependency to bash

[user@system:~]$ nix-shell -p hello
configuring
configure flags: --disable-dependency-tracking --prefix=/nix/store/b2sa53m24vbl7qczp9m1h22gfm75p8g5-gnum4-1.4.19 --with-syscmd-shell=/nix/store/cvzil995dqk628n017d02s1zaa6fjh4i-bootstrap-tools/bin/bash
/nix/store/irpiwq1zc4m0gpjfn0jnk1n8d2wm6fb5-bootstrap-stage1-stdenv-linux/setup: ./configure: /bin/sh: bad interpreter: No such file or directory
error: builder for '/nix/store/457iicmpyrcv6sd2wbhb2pfvxafadkbl-gnum4-1.4.19.drv' failed with exit code 126;
       last 8 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/mcayf992diwks293vs12iwx1ywgm4ijg-m4-1.4.19.tar.bz2
       > source root is m4-1.4.19
       > setting SOURCE_DATE_EPOCH to timestamp 1622228112 of file m4-1.4.19/ChangeLog
       > patching sources
       > configuring
       > configure flags: --disable-dependency-tracking --prefix=/nix/store/b2sa53m24vbl7qczp9m1h22gfm75p8g5-gnum4-1.4.19 --with-syscmd-shell=/nix/store/cvzil995dqk628n017d02s1zaa6fjh4i-bootstrap-tools/bin/bash
       > /nix/store/irpiwq1zc4m0gpjfn0jnk1n8d2wm6fb5-bootstrap-stage1-stdenv-linux/setup: ./configure: /bin/sh: bad interpreter: No such file or directory
       For full logs, run 'nix log /nix/store/457iicmpyrcv6sd2wbhb2pfvxafadkbl-gnum4-1.4.19.drv'.
error: 1 dependencies of derivation '/nix/store/7c7qzp7mpypjxsljzzcsd5xlvf0lp6ri-autoconf-2.71.drv' failed to build
error: 1 dependencies of derivation '/nix/store/hyx4185clc6kglsmy4ssghm9rj32id4p-autoconf-2.71.drv' failed to build
error: 1 dependencies of derivation '/nix/store/rq5aks4i8dwpfkjq70b7011j6a38qyr4-bison-3.8.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/1s7r44p1r1z7m80x1yzvdzpr86ha79gw-gmp-with-cxx-6.2.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/p9sk1b2acnbs4w7cvvrkznvx9bp569zn-gmp-with-cxx-stage3-6.2.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9hqjcgkwwkg9dam00p582clllbf2pw53-gmp-with-cxx-stage4-6.2.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/jgivwjzx9brri58dpa5jmcxg0fbssbwk-bash-5.2-p15.drv' failed to build
error: build of '/nix/store/187bwmfgzjhfgyf27l7n2h58c84sd6jr-stdenv-linux.drv', '/nix/store/jgivwjzx9brri58dpa5jmcxg0fbssbwk-bash-5.2-p15.drv'

Notify maintainers

@Artturin (you seem to be the last one to modify it)
@civodul
@volth
@KAction
@RasmusRendal
@SuperSandro2000
@edolstra

Metadata

attribute: gnum4

I wish I could run nix-shell -p nix-info --run "nix-info -m" but read the description.

[user@system:~]$ uname -a"
Linux raspberrypi 5.15.61-v7+ #1579 SMP Fri Aug 26 11:10:59 BST 2022 armv7l GNU/Linux

nixpkgs commit : a21493d

nix version : 2.12.0

@TheSirC TheSirC added the 0.kind: bug Something is broken label Jan 16, 2023
@KAction
Copy link
Contributor

KAction commented Jan 17, 2023

FWIW, cross-build builds something.

>> file  /nix/store/kqfy2fg2ga9b9g7lk0h9i4462p1q1lbp-hello-armv7l-unknown-linux-gnueabihf-2.12.1/bin/hello
/nix/store/kqfy2fg2ga9b9g7lk0h9i4462p1q1lbp-hello-armv7l-unknown-linux-gnueabihf-2.12.1/bin/hello: ELF 32-bit LSB executable, A
RM, EABI5 version 1 (SYSV), dynamically linked, interpreter /nix/store/s9alhnp7zb4pbjlp1ap730drmr3w50lb-glibc-armv7l-unknown-li
nux-gnueabihf-2.35-224/lib/ld-linux-armhf.so.3, for GNU/Linux 3.10.0, not stripped

One thing I may suggest is to try is to build /bin/sh statically yourself and try to mount it using sandbox-paths into /bin/sh of the sandbox.

@TheSirC
Copy link
Author

TheSirC commented Jan 17, 2023

One thing I may suggest is to try is to build /bin/sh statically yourself and try to mount it using sandbox-paths into /bin/sh of the sandbox.

Thank you very much for your suggestion ! I will give it a try.

I do think that the situation is not optimal : building on the host platform ought to be self-standing.

@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Jan 17, 2023

I would guess that autoconf tries to run the configure script which's shebang is not patched.

Maybe I can test this with binfmt or so.

#211233

@SuperSandro2000 SuperSandro2000 added the 6.topic: exotic Exotic hardware or software platform label Jan 17, 2023
@SuperSandro2000
Copy link
Member

I tried to preproduce this locally with nix-build -E 'with import ./. { system = "armv7l-linux"; }; pkgs.stdenv.__bootPackages.gnum4' --check which succeeded. So I think this could be a problem on your side. Do you have the sandbox on? Can you try the PR I linked?

@TheSirC
Copy link
Author

TheSirC commented Jan 18, 2023

I tried the PR on the native host platform and it failed. But I do not have sandbox on.

Given the comment of @KAction, it's not surprising that it would cross build with or without your PR. Are you cross-building or natively building ?

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-on-armv7l-fails-to-build-any-packge/16819/5

@Artturin
Copy link
Member

Artturin commented Jan 18, 2023

@TheSirC please apply the following patch and send the output of those 2 commands in nix build ".#stdenv.__bootPackages.m4"

i suspect /bin/sh is for the wrong arch (problem with the bootstrap files?)

diff --git a/pkgs/development/tools/misc/gnum4/default.nix b/pkgs/development/tools/misc/gnum4/default.nix
index 34df06ad0f4..b03796c91a8 100644
--- a/pkgs/development/tools/misc/gnum4/default.nix
+++ b/pkgs/development/tools/misc/gnum4/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchurl }:
+{ lib, stdenv, fetchurl, file }:
 
 # Note: this package is used for bootstrapping fetchurl, and thus
 # cannot use fetchpatch! All mutable patches (generated by GitHub or
@@ -19,6 +19,13 @@ stdenv.mkDerivation rec {
 
   doCheck = false;
 
+  nativeBuildInputs = [ file ];
+  preConfigure = ''
+    ls /bin
+    file /bin/sh
+    exit
+  '';
+
   configureFlags = [ "--with-syscmd-shell=${stdenv.shell}" ]
     ++ lib.optional stdenv.hostPlatform.isMinGW "CFLAGS=-fno-stack-protector";

@TheSirC
Copy link
Author

TheSirC commented Jan 18, 2023

"Funny" enough, with this patch it is one of the dependencies (zlib) of file is failing with :

       last 8 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/3yhi12pgsmv2dz0x2ialvjw51lnv4jw8-zlib-1.2.13.tar.gz
       > source root is zlib-1.2.13
       > setting SOURCE_DATE_EPOCH to timestamp 1665637615 of file zlib-1.2.13/zlib.h
       > patching sources
       > configuring
       > configure flags: --prefix=/nix/store/6kp535mzdkbipnnwsabi89pzqdb5bx8r-zlib-1.2.13 --static --shared
       > /nix/store/irpiwq1zc4m0gpjfn0jnk1n8d2wm6fb5-bootstrap-stage1-stdenv-linux/setup: ./configure: /bin/sh: bad interpreter: No such file or directory

@Artturin
Copy link
Member

Artturin commented Jan 19, 2023

the file output for /bin/bash in bootstrap tools is
(coreutils is still from bootstrapTools at that stage)

$ file $(nix build --print-out-paths --impure --expr 'with import ./. { system = "armv7l-linux"; }; stdenv.__bootPackages.stdenv.__bootPackages.coreutils')/bin/bash
/nix/store/cvzil995dqk628n017d02s1zaa6fjh4i-bootstrap-tools/bin/bash: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /nix/store/cvzil995dqk628n017d02s1zaa6fjh4i-bootstrap-tools/lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, stripped

dont know if its correct

@SuperSandro2000
Copy link
Member

But I do not have sandbox on.

That's not really supported for linux and some build failures are expected without the sandbox.
Not sure if that is the root cause of this.

@TheSirC
Copy link
Author

TheSirC commented Jan 19, 2023

I am in the process of patching a bunch of shebangs in the dependency tree... I got more than a dozen that needed massaging but I am not sure it will help in the end...

the file output for /bin/bash in bootstrap tools is
(coreutils is still from bootstrapTools at that stage)

Are you doing this on armv7l ?

But I do not have sandbox on.

That's not really supported for linux and some build failures are expected without the sandbox. Not sure if that is the root cause of this.

So you mean, using Nix not on NixOS one should always be using the sandbox option ?

@Artturin
Copy link
Member

Artturin commented Jan 19, 2023

I am in the process of patching a bunch of shebangs in the dependency tree... I got more than a dozen that needed massaging but I am not sure it will help in the end...

there's some other issue and the /bin/sh issue is just a symptom of it

the file output for /bin/bash in bootstrap tools is
(coreutils is still from bootstrapTools at that stage)

Are you doing this on armv7l ?

There shouldn't be a difference

But I do not have sandbox on.

That's not really supported for linux and some build failures are expected without the sandbox. Not sure if that is the root cause of this.

So you mean, using Nix not on NixOS one should always be using the sandbox option ?

the sandbox option is true for linux (when installed in multi-user mode) by default https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-sandbox

did you turn it off? if not then its on, if you did turn it off then turn it on

@TheSirC
Copy link
Author

TheSirC commented Jan 19, 2023

the sandbox option is true for linux by default nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-sandbox

did you turn it off? if not then its on, if you did turn it off then turn it on

Linux raspberrypi 5.15.61-v7+ #1579 SMP Fri Aug 26 11:10:59 BST 2022 armv7l GNU/Linux

I am on Linux so it should be turned on by default then (and I did not turn it off)... still I am seeing the behavior described.

There shouldn't be a difference

Seems there is though...

there's some other issue and the /bin/sh issue is just a symptom of it

What do you suggest ? I must say I am really puzzled by all of this...

@Artturin
Copy link
Member

Artturin commented Jan 19, 2023

send the output of these 3

readlink -f $(nix-build -E 'with import <nixpkgs> { system = "armv7l-linux"; }; stdenv.__bootPackages.stdenv.__bootPackages.coreutils')

readlink -f $(nix-build -E 'with import <nixpkgs> { }; stdenv.__bootPackages.stdenv.__bootPackages.coreutils')

nix-instantiate --eval --expr builtins.currentSystem

do both of these work

$(nix-build -E 'with import <nixpkgs> { system = "armv7l-linux"; }; stdenv.__bootPackages.stdenv.__bootPackages.coreutils')/bin/sh

$(nix-build -E 'with import <nixpkgs> {  }; stdenv.__bootPackages.stdenv.__bootPackages.coreutils')/bin/sh

@TheSirC
Copy link
Author

TheSirC commented Jan 19, 2023

readlink -f $(nix-build -E 'with import { system = "armv7l-linux"; }; stdenv.__bootPackages.stdenv.__bootPackages.coreutils')

/nix/store/cvzil995dqk628n017d02s1zaa6fjh4i-bootstrap-tools

readlink -f $(nix-build -E 'with import { }; stdenv.__bootPackages.stdenv.__bootPackages.coreutils')

/nix/store/cvzil995dqk628n017d02s1zaa6fjh4i-bootstrap-tools

nix-instantiate --eval --expr builtins.currentSystem

"armv7l-linux"

do both of these work

$(nix-build -E 'with import <nixpkgs> { system = "armv7l-linux"; }; stdenv.__bootPackages.stdenv.__bootPackages.coreutils')/bin/sh

$(nix-build -E 'with import <nixpkgs> {  }; stdenv.__bootPackages.stdenv.__bootPackages.coreutils')/bin/sh

Yes but I am unsure of if it is because of my patches...

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixos-iso-for-armv7l/24804/1

@bhansconnect
Copy link

I just ran into this issue on a raspberry pi 3B+ that is running raspbian 32bit. Probably not that useful of information, but I get all of the same results for #211120 (comment)

I also had left it running with the sandbox off overnight, but not sure if that actually fixed anything. Right now, the system is running super slow as it is trying to compile gcc. Maybe it is a workaround after a long wait for things to compile from source?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: exotic Exotic hardware or software platform
Projects
None yet
Development

No branches or pull requests

6 participants