NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.05k stars 14.04k forks source link

pcre test fails on armv7l-linux #187720

Open tanshihaj opened 2 years ago

tanshihaj commented 2 years ago

Steps To Reproduce

Steps to reproduce the behavior:

  1. on linux machine add armv7l-linux to the extra-platforms config in /etc/nix/nix.conf
  2. try to build pcre package: nix-build '<nixpkgs>' -A pcre --argstr system armv7l-linux
  3. got an error on check phase

Build log

Ive build it with nix-shell ... && unpackPhase && patchPhase && configurePhase && buildPhase && checkPhase but result is the same as running nix-builx ...: https://gist.github.com/tanshihaj/c5c4beef9724cb6921427fc2818b01b8

Additional context

Testing system of pcre project a bit complicated, cannot understand what goes wrong (even understanding which exactly test failed is not easy). If there anyone who understands how to debut it that would be great if he will help me.

Metadata

[root@nixos:~]# nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.60, NixOS, 22.05 (Quokka), 22.05.2583.00e376e3f3c`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - channels(root): `"nixos-22.05, unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
enkiusz commented 1 year ago

I have ran into the same problem while trying to build for armv6l and have discovered the cause.

The tests fail because readdir() fails. With 32-bit code running in a 64-bit OS the code needs to be compiled with -D_FILE_OFFSET_BITS=64 because the file sizes and inode numbers will be returned as 64-bit ints. See https://stackoverflow.com/a/62077925 and https://stackoverflow.com/questions/27554325/readdir-32-64-compatibility-issues for more info.

System info

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.79, NixOS, 22.05 (Quokka), 22.05.4351.fecf05d4861`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

First the build as-is fails with the same error as you encountered:

$ uname -a
Linux nixbox 5.15.79 #1-NixOS SMP Wed Nov 16 08:58:31 UTC 2022 x86_64 GNU/Linux
$ nix-build '<nixpkgs>' -A pcre --argstr system armv6l-linux
this derivation will be built:
  /nix/store/bfia62b24raa57xdhlxj9h38njaddbpn-pcre-8.45.drv
building '/nix/store/bfia62b24raa57xdhlxj9h38njaddbpn-pcre-8.45.drv'...
unpacking sources
[...]
=================================
   PCRE 8.45: ./test-suite.log
=================================

# TOTAL: 3
# PASS:  2
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: RunGrepTest
=================

Testing pcregrep version 8.45 2021-06-15
Testing pcregrep main features
--- ./testdata/grepoutput       2015-08-05 17:42:49.000000000 +0000
+++ testtrygrep 2022-12-05 21:40:15.322281457 +0000
@@ -371,12 +371,8 @@
 ---------------------------- Test 34 -----------------------------
 RC=2
 ---------------------------- Test 35 -----------------------------
-./testdata/grepinput8
-./testdata/grepinputx
 RC=0
 ---------------------------- Test 36 -----------------------------
-./testdata/grepinput3
-./testdata/grepinputx
 RC=0
 ---------------------------- Test 37 -----------------------------
 aaaaa0
@@ -680,20 +676,12 @@
 testdata/grepinputx:complete pair
 RC=0
 ---------------------------- Test 96 -----------------------------
-./testdata/grepinput3
-./testdata/grepinput8
-./testdata/grepinputx
 RC=0
 ---------------------------- Test 97 -----------------------------
-./testdata/grepinput3
-./testdata/grepinputx
 RC=0
 ---------------------------- Test 98 -----------------------------
-./testdata/grepinputx
 RC=0
 ---------------------------- Test 99 -----------------------------
-./testdata/grepinput3
-./testdata/grepinputx
 RC=0
 ---------------------------- Test 100 ------------------------------
 ./testdata/grepinput:zerothe.
FAIL RunGrepTest (exit status: 1)

============================================================================
Testsuite summary for PCRE 8.45
============================================================================
# TOTAL: 3
# PASS:  2
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See ./test-suite.log
============================================================================
make[3]: *** [Makefile:2703: test-suite.log] Error 1
make[3]: Leaving directory '/build/pcre-8.45'
make[2]: *** [Makefile:2811: check-TESTS] Error 2
make[2]: Leaving directory '/build/pcre-8.45'
make[1]: *** [Makefile:3057: check-am] Error 2
make[1]: Leaving directory '/build/pcre-8.45'
make: *** [Makefile:3059: check] Error 2
error: builder for '/nix/store/bfia62b24raa57xdhlxj9h38njaddbpn-pcre-8.45.drv' failed with exit code 2;
       last 10 log lines:
       > ============================================================================
       > See ./test-suite.log
       > ============================================================================
       > make[3]: *** [Makefile:2703: test-suite.log] Error 1
       > make[3]: Leaving directory '/build/pcre-8.45'
       > make[2]: *** [Makefile:2811: check-TESTS] Error 2
       > make[2]: Leaving directory '/build/pcre-8.45'
       > make[1]: *** [Makefile:3057: check-am] Error 2
       > make[1]: Leaving directory '/build/pcre-8.45'
       > make: *** [Makefile:3059: check] Error 2
       For full logs, run 'nix log /nix/store/bfia62b24raa57xdhlxj9h38njaddbpn-pcre-8.45.drv'.

now if we modify the CFLAGS and run via nix-shell:

$ export NIX_CFLAGS_COMPILE="-D_FILE_OFFSET_BITS=64"
$ nix-shell '<nixpkgs>' -A pcre --argstr system armv6l-linux
$ unpackPhase && cd pcre-8.45 && configurePhase && buildPhase && checkPhase
[...]
make[2]: Entering directory '/home/vagrant/armv6l-linux/pcre-8.45'
make[3]: Entering directory '/home/vagrant/armv6l-linux/pcre-8.45'
PASS: pcre_jit_test
PASS: RunTest
PASS: RunGrepTest
============================================================================
Testsuite summary for PCRE 8.45
============================================================================
# TOTAL: 3
# PASS:  3
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
make[3]: Leaving directory '/home/vagrant/armv6l-linux/pcre-8.45'
make[2]: Leaving directory '/home/vagrant/armv6l-linux/pcre-8.45'
make[1]: Leaving directory '/home/vagrant/armv6l-linux/pcre-8.45'

the build is successful. I changed the package file for pcre (pkgs/development/libraries/pcre/default.nix) by adding the following:

preBuild = ''
    export NIX_CFLAGS_COMPILE="-D_FILE_OFFSET_BITS=64 $NIX_CLFAGS_COMPILE"
  '';

and it allowed the package to be built but I don't know whether this is a proper way to fix this issue. I'm afraid that we might want to apply -D_FILE_OFFSET_BITS=64 to a wider set of packages as I feel that a lot more can be broken. But this at least allows me to continue my armv6 nixos-generators build for now. Let's see what break next ;).