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

Can't build numpy cross package for armv7 due to failure compiling gfortran needed in lapack and blas dependencies #88449

Closed
satshabad-cr opened this issue May 20, 2020 · 4 comments
Assignees
Labels
0.kind: bug 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on

Comments

@satshabad-cr
Copy link

Describe the bug
I'd like to build the python numpy package on an x86 machine for the armv7 architecture.

numpy requires liblapack and blas, which require gfortran

I already fixed one issue which is that liblapack couldn't find the gfortran compiler (see the overlay below)

I'm trying to use the 20.03 release, latest commit.

Here's what I'm running exactly:

let overlay = self: super: {
      liblapack = super.liblapacklapack.overrideAttrs (oldAttrs: {
        cmakeFlags = oldAttrs.cmakeFlags ++
                     [
                       "-DCMAKE_Fortran_COMPILER=${self.buildPackages.gfortran}/bin/armv7l-unknown-linux-gnueabihf-gfortran"
                     ];
      }
      );
    };
    pinnedPkgs = import (builtins.fetchGit {
      name = "nixos-stable-20.03";
      url = "https://github.com/nixos/nixpkgs-channels/";
      ref = "refs/heads/nixos-20.03";
      rev = "82b5f87fcc710a99c47c5ffe441589807a8202af";
    });
    pkgs = (pinnedPkgs { overlays = [ overlay ]; }).pkgsCross.armv7l-hf-multiplatform;
in
#pkgs.lapack
pkgs.blas
#pkgs.python38.pkgs.numpy
#pkgs.python38.withPackages(ps: [ps.numpy])

To Reproduce
Steps to reproduce the behavior:

  1. nix-build that_file.nix

here's the error I get

libtool: link: armv7l-unknown-linux-gnueabihf-gcc -O2 -g -I/nix/store/5nhxmvjs137aym9dpiwgl3jgmmdz6q9i-glibc-2.30-armv7l-unknown-linux-gnueabihf-dev/include -B/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib/ -idirafter /nix/store/5nhxmvjs137aym9dpiwgl3jgmmdz6q9i-glibc-2.30-armv7l-unknown-linux-gnueabihf-dev/include -idirafter /nix/store/4n9fi2r61i3q3qp09qcdfj9hvlq763jx-armv7l-unknown-linux-gnueabihf-stage-final-gcc-debug-9.2.0/lib/gcc/armv7l-unknown-linux-gnueabihf/9.2.0/include-fixed -Wl,-rpath,/nix/store/ymknlm466j74dvlsvfs8qsqmyawv9pw5-gfortran-debug-9.2.0-armv7l-unknown-linux-gnueabihf-lib/lib -Wl,-L/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,-rpath -Wl,/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,-L/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib    -shared  -fPIC -DPIC  .libs/alloc.o .libs/atomic.o .libs/barrier.o .libs/critical.o .libs/env.o .libs/error.o .libs/icv.o .libs/icv-device.o .libs/iter.o .libs/iter_ull.o .libs/loop.o .libs/loop_ull.o .libs/ordered.o .libs/parallel.o .libs/sections.o .libs/single.o .libs/task.o .libs/team.o .libs/work.o .libs/lock.o .libs/mutex.o .libs/proc.o .libs/sem.o .libs/bar.o .libs/ptrlock.o .libs/time.o .libs/fortran.o .libs/affinity.o .libs/target.o .libs/splay-tree.o .libs/libgomp-plugin.o .libs/oacc-parallel.o .libs/oacc-host.o .libs/oacc-init.o .libs/oacc-mem.o .libs/oacc-async.o .libs/oacc-plugin.o .libs/oacc-cuda.o .libs/priority_queue.o .libs/affinity-fmt.o .libs/teams.o   -ldl  -Wl,-rpath -Wl,/nix/store/ymknlm466j74dvlsvfs8qsqmyawv9pw5-gfortran-debug-9.2.0-armv7l-unknown-linux-gnueabihf-lib/lib -Wl,-L/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,-rpath -Wl,/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,-L/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -pthread -Wl,-rpath -Wl,/nix/store/ymknlm466j74dvlsvfs8qsqmyawv9pw5-gfortran-debug-9.2.0-armv7l-unknown-linux-gnueabihf-lib/lib -Wl,-L/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,-rpath -Wl,/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,-L/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,-O1 -Wl,-rpath -Wl,/nix/store/ymknlm466j74dvlsvfs8qsqmyawv9pw5-gfortran-debug-9.2.0-armv7l-unknown-linux-gnueabihf-lib/lib -Wl,-L/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,-rpath -Wl,/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,-L/nix/store/lc4nci84vnna9lqa8390669f1zyy1ghc-glibc-2.30-armv7l-unknown-linux-gnueabihf/lib -Wl,--version-script -Wl,libgomp.ver   -Wl,-soname -Wl,libgomp.so.1 -o .libs/libgomp.so.1.0.0
libtool: link: (cd ".libs" && rm -f "libgomp.so.1" && ln -s "libgomp.so.1.0.0" "libgomp.so.1")
libtool: link: (cd ".libs" && rm -f "libgomp.so" && ln -s "libgomp.so.1.0.0" "libgomp.so")
libtool: link: ar rc .libs/libgomp.a  alloc.o atomic.o barrier.o critical.o env.o error.o icv.o icv-device.o iter.o iter_ull.o loop.o loop_ull.o ordered.o parallel.o sections.o single.o task.o team.o work.o lock.o mutex.o proc.o sem.o bar.o ptrlock.o time.o fortran.o affinity.o target.o splay-tree.o libgomp-plugin.o oacc-parallel.o oacc-host.o oacc-init.o oacc-mem.o oacc-async.o oacc-plugin.o oacc-cuda.o priority_queue.o affinity-fmt.o teams.o
libtool: link: ranlib .libs/libgomp.a
libtool: link: ( cd ".libs" && rm -f "libgomp.la" && ln -s "../libgomp.la" "libgomp.la" )
make[4]: Leaving directory '/build/build/armv7l-unknown-linux-gnueabihf/libgomp'
make[3]: Leaving directory '/build/build/armv7l-unknown-linux-gnueabihf/libgomp'
make[2]: Leaving directory '/build/build/armv7l-unknown-linux-gnueabihf/libgomp'
make[1]: Leaving directory '/build/build'
make: *** [Makefile:935: all] Error 2
note: keeping build directory '/tmp/nix-build-gfortran-debug-9.2.0-armv7l-unknown-linux-gnueabihf.drv-0'
builder for '/nix/store/3v45xj9mpzxi04jgk03qcc31jdg56i97-gfortran-debug-9.2.0-armv7l-unknown-linux-gnueabihf.drv' failed with exit code 2
cannot build derivation '/nix/store/0pa528hxi7zpyq7a0x4zdgrjisqhnw0l-gfortran-debug-wrapper-9.2.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/hpshxgrpjpvkc95v0rbc94vzcinz2war-blas-3.8.0-armv7l-unknown-linux-gnueabihf.drv': 1 dependencies couldn't be built
error: build of '/nix/store/hpshxgrpjpvkc95v0rbc94vzcinz2war-blas-3.8.0-armv7l-unknown-linux-gnueabihf.drv' failed

Expected behavior
The derivation builds

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

copying path '/nix/store/9c9mjrmfdschylny0bhkxxd7y0m90piw-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 4.15.0-99-generic, Ubuntu, 18.04.4 LTS (Bionic Beaver)`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.4`
 - channels(satshabad): `"nixpkgs-20.09pre226107.62e866e4fd6"`
 - nixpkgs: `/home/satshabad/.nix-defexpr/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: numpy liblapack blas
@veprbl veprbl added the 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on label May 20, 2020
@satshabad-cr
Copy link
Author

Maybe related to: #53450 ?

@matthewbauer
Copy link
Member

I'm not getting this in NixOS. It looks like a sandboxing issue.

Can you try running this:

NixOS/nix#2636 (comment)

@satshabad-cr
Copy link
Author

Thanks for responding!

I launched this build on NixOs using an AMI on EC2 and I get the same result as in the issue report, here are the system details:

 - system: `"aarch64-linux"`
 - host os: `Linux 5.4.41, NixOS, 20.03.1926.f45ccd9d20b (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.4`
 - channels(root): `"nixos-20.03.1926.f45ccd9d20b"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

@swflint
Copy link
Contributor

swflint commented May 23, 2020

A similar issue exists on unstable when building for x86.

Traceback (most recent call last):
  File "nix_run_setup", line 8, in <module>
    exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
  File "setup.py", line 540, in <module>
    setup_package()
  File "setup.py", line 536, in setup_package
    setup(**metadata)
  File "/nix/store/qb19waw8994w0jm43rsxn43b244i8a0v-python3.7-numpy-1.18.1/lib/python3.7/site-packages/numpy/distutils/core.py", line 137, in setup
    config = configuration()
  File "setup.py", line 435, in configuration
    raise NotFoundError(msg)
numpy.distutils.system_info.NotFoundError: No lapack/blas resources found.

Currently on:

  • system: "x86_64-linux"
  • host os: Linux 5.6.5, NixOS, 20.09pre222244.22a3bf9fb9e (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.4
  • channels(root): "nixos-20.09pre222244.22a3bf9fb9e, nix1709-17.09.3269.14f9ee66e63, nix1803-18.03.133402.cb0e20d6db9, nix1809-18.09.2574.a7e559a5504, nix1903-19.03.173553.6420e2649fa, unstable"
  • channels(swflint): "nix2003-20.03.1950.48723f48ab9, nixos-20.09pre226148.0f5ce2fac0c, nixos-unstable"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

@matthewbauer matthewbauer self-assigned this May 29, 2020
@FRidh FRidh closed this as completed in f42aa7e Aug 24, 2020
rvem pushed a commit to serokell/nixpkgs that referenced this issue Nov 8, 2022
We need to set FC so that CMake and other tools can find the fortran
compiler. Also we need to limit the hardening flags since fortify and
format don’t work with fortran.

Fixes NixOS#88449
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on
Projects
None yet
Development

No branches or pull requests

4 participants