Nixpkgs: hmatrix: broken libgfortran linkage

Created on 27 Oct 2017  路  9Comments  路  Source: NixOS/nixpkgs

Issue description

I compile self little package with hmatrix in dependencies and get troubles with linkage:

.../lts-9.10/8.0.2/bin/robodist: error while loading shared libraries: libgfortran.so.3: cannot open shared object file: No such file or directory
$ ldd executable
        linux-vdso.so.1 (0x00007ffe9feea000)
        libblas.so => /nix/store/wgryyb0rx955fimy9qk2k74cw0092m44-blas-3.5.0/lib/libblas.so (0x00007fd9f29bb000)
        libm.so.6 => /nix/store/xzx1bv1d7z4mgg6sg6ly0jx609qvka4x-glibc-2.25-49/lib/libm.so.6 (0x00007fd9f26a8000)
        libgmp.so.10 => /nix/store/h4hz48cvx05f1gw6mcqrdkxvq8b2s2d5-gmp-6.1.2/lib/libgmp.so.10 (0x00007fd9f2415000)
        librt.so.1 => /nix/store/xzx1bv1d7z4mgg6sg6ly0jx609qvka4x-glibc-2.25-49/lib/librt.so.1 (0x00007fd9f220d000)
        libdl.so.2 => /nix/store/xzx1bv1d7z4mgg6sg6ly0jx609qvka4x-glibc-2.25-49/lib/libdl.so.2 (0x00007fd9f2009000)
        libpthread.so.0 => /nix/store/xzx1bv1d7z4mgg6sg6ly0jx609qvka4x-glibc-2.25-49/lib/libpthread.so.0 (0x00007fd9f1deb000)
        libc.so.6 => /nix/store/xzx1bv1d7z4mgg6sg6ly0jx609qvka4x-glibc-2.25-49/lib/libc.so.6 (0x00007fd9f1a4c000)
        /nix/store/xzx1bv1d7z4mgg6sg6ly0jx609qvka4x-glibc-2.25-49/lib/ld-linux-x86-64.so.2 (0x00007fd9f2c11000)
        libgfortran.so.3 => not found
        libgfortran.so.3 => /nix/store/b2dny33b8sdx6rw2l1gfa00a244nm37s-gfortran-6.4.0-lib/lib/libgfortran.so.3 (0x00007fd9f1727000)
        libgcc_s.so.1 => /nix/store/xzx1bv1d7z4mgg6sg6ly0jx609qvka4x-glibc-2.25-49/lib/libgcc_s.so.1 (0x00007fd9f1511000)
        libquadmath.so.0 => /nix/store/b2dny33b8sdx6rw2l1gfa00a244nm37s-gfortran-6.4.0-lib/lib/libquadmath.so.0 (0x00007fd9f12d2000)

In my opinion linkage broken in

       libgfortran.so.3 => not found
       libgfortran.so.3 => /nix/store/b2dny33b8sdx6rw2l1gfa00a244nm37s-gfortran-6.4.0-lib/lib/libgfortran.so.3 (0x00007fd9f1727000)

Steps to reproduce

Compile haskell executable with hmatrix as dependency.

Technical details

  • System: 17.09.1869.cd9ce6dd60 (Hummingbird)
  • Nix version: nix-env (Nix) 1.11.15
  • Nixpkgs version: 17.09.1869.cd9ce6dd60
  • Sandboxing enabled: build-use-sandbox = false
bug haskell

Most helpful comment

It will work if you add gfortran.cc.lib to your packages.

All 9 comments

Can you provide more details about the expression you're evaluating to get this output?

I experience the same problem using stack/nix setup. My project is minimal, it depends on base and hmatrix only and doesn't contain any (almost) logic at all. Though stack build works, but stack ghci fails with the same as PR author had shared. Adding gfortran to packages section of stack.yaml doesn't help.

  1. stack new foo

stack.yaml

+nix:
+  packages: [ blas liblapack ]

foo.cabal

+     hmatrix
  1. stack build
akru@krakov ~/devel/foo $ ldd .stack-work/install/x86_64-linux-nix/lts-10.2/8.2.2/lib/x86_64-linux-ghc-8.2.2/libHSfoo-0.1.0.0-CTCRiTYOB3j81v1wLDBJbt-ghc8.2.2.so                                                                                                     

        libHSstorable-complex-0.2.2-4WEqCO29MfMHlD0g6H5VIw-ghc8.2.2.so => /home/akru/.stack/snapshots/x86_64-linux-nix/lts-10.2/8.2.2/lib/x86_64-linux-ghc-8.2.2/libHSstorable-complex-0.2.2-4WEqCO29MfMHlD0g6H5VIw-ghc8.2.2.so (0x00007f2479fe6000)
        libHSsplit-0.2.3.2-7cayvoeRj5XIrIBUB58mMy-ghc8.2.2.so => /home/akru/.stack/snapshots/x86_64-linux-nix/lts-10.2/8.2.2/lib/x86_64-linux-ghc-8.2.2/libHSsplit-0.2.3.2-7cayvoeRj5XIrIBUB58mMy-ghc8.2.2.so (0x00007f2479dcd000)
        libHSrandom-1.1-LLUGZ7T9DqQ5vN0Jbcd0We-ghc8.2.2.so => /home/akru/.stack/snapshots/x86_64-linux-nix/lts-10.2/8.2.2/lib/x86_64-linux-ghc-8.2.2/libHSrandom-1.1-LLUGZ7T9DqQ5vN0Jbcd0We-ghc8.2.2.so (0x00007f2479b6b000)
        libHStime-1.8.0.2-ghc8.2.2.so => /nix/store/sr6pskh0xl1xm035p473scq2ac0bggci-ghc-8.2.2/lib/ghc-8.2.2/time-1.8.0.2/libHStime-1.8.0.2-ghc8.2.2.so (0x00007f247986e000)
        libHSbinary-0.8.5.1-ghc8.2.2.so => /nix/store/sr6pskh0xl1xm035p473scq2ac0bggci-ghc-8.2.2/lib/ghc-8.2.2/binary-0.8.5.1/libHSbinary-0.8.5.1-ghc8.2.2.so (0x00007f24795ca000)
        libHScontainers-0.5.10.2-ghc8.2.2.so => /nix/store/sr6pskh0xl1xm035p473scq2ac0bggci-ghc-8.2.2/lib/ghc-8.2.2/containers-0.5.10.2/libHScontainers-0.5.10.2-ghc8.2.2.so (0x00007f24790ec000)
        libHSbytestring-0.10.8.2-ghc8.2.2.so => /nix/store/sr6pskh0xl1xm035p473scq2ac0bggci-ghc-8.2.2/lib/ghc-8.2.2/bytestring-0.10.8.2/libHSbytestring-0.10.8.2-ghc8.2.2.so (0x00007f2478df8000)
        libHSdeepseq-1.4.3.0-ghc8.2.2.so => /nix/store/sr6pskh0xl1xm035p473scq2ac0bggci-ghc-8.2.2/lib/ghc-8.2.2/deepseq-1.4.3.0/libHSdeepseq-1.4.3.0-ghc8.2.2.so (0x00007f2478bdf000)
        libHSarray-0.5.2.0-ghc8.2.2.so => /nix/store/sr6pskh0xl1xm035p473scq2ac0bggci-ghc-8.2.2/lib/ghc-8.2.2/array-0.5.2.0/libHSarray-0.5.2.0-ghc8.2.2.so (0x00007f247895b000)
        libHSbase-4.10.1.0-ghc8.2.2.so => /nix/store/sr6pskh0xl1xm035p473scq2ac0bggci-ghc-8.2.2/lib/ghc-8.2.2/base-4.10.1.0/libHSbase-4.10.1.0-ghc8.2.2.so (0x00007f2477d94000)
        libHSinteger-gmp-1.0.1.0-ghc8.2.2.so => /nix/store/sr6pskh0xl1xm035p473scq2ac0bggci-ghc-8.2.2/lib/ghc-8.2.2/integer-gmp-1.0.1.0/libHSinteger-gmp-1.0.1.0-ghc8.2.2.so (0x00007f2477b59000)
        libHSghc-prim-0.5.1.1-ghc8.2.2.so => /nix/store/sr6pskh0xl1xm035p473scq2ac0bggci-ghc-8.2.2/lib/ghc-8.2.2/ghc-prim-0.5.1.1/libHSghc-prim-0.5.1.1-ghc8.2.2.so (0x00007f24774bd000)
        libblas.so => /nix/store/d86l8zyls7immy3hq9sydjxl28b797v4-blas-3.7.1/lib/libblas.so (0x00007f2477267000)
        libgmp.so.10 => /nix/store/2p7a3yb6hilmjch90p3bw56shn76a0h5-gmp-6.1.2/lib/libgmp.so.10 (0x00007f2476fd4000)
        libc.so.6 => /nix/store/glb7dzs11di2cl66rsi8f49wraaj0pqd-glibc-2.26-75/lib/libc.so.6 (0x00007f2476c21000)
        /nix/store/glb7dzs11di2cl66rsi8f49wraaj0pqd-glibc-2.26-75/lib64/ld-linux-x86-64.so.2 (0x00007f247baec000)
        libgfortran.so.3 => not found
        libgfortran.so.3 => /nix/store/bk86fm18kp3c0mr89vvjls9r3v0g0irz-gfortran-6.4.0-lib/lib/libgfortran.so.3 (0x00007f24768fc000)
        libgcc_s.so.1 => /nix/store/glb7dzs11di2cl66rsi8f49wraaj0pqd-glibc-2.26-75/lib/libgcc_s.so.1 (0x00007f24766e6000)
        libquadmath.so.0 => /nix/store/bk86fm18kp3c0mr89vvjls9r3v0g0irz-gfortran-6.4.0-lib/lib/libquadmath.so.0 (0x00007f24764a7000) 

It will work if you add gfortran.cc.lib to your packages.

cc @peti probably hmatrix should link out of the box

I ran into this problem as well. I was able to fix it by using the suggestion by @Fuuzetsu. I am using a relatively recent version of nixpkgs unstable.

I'm running into this as well (calling stack ghci with hmatrix). It appears liblapack in nixpkgs no longer has shared objects (if it ever did)? See below.

@Fuuzetsu, adding gfortran.cc.lib works well, but then this error arises

$ stack ghci
<command line>: can't load .so/.DLL for: liblapack.so 
  (liblapack.so: cannot open shared object file: No such file or directory)
tree /nix/store/pk0qn3xg3awg1354lm4xjl5nhxyi0dll-liblapack-3.8.0
`-- lib
    |-- cmake
    |   `-- lapack-3.8.0
    |       |-- lapack-config-version.cmake
    |       |-- lapack-config.cmake
    |       |-- lapack-targets-release.cmake
    |       `-- lapack-targets.cmake
    |-- libblas.a
    |-- liblapack.a
    `-- pkgconfig
        |-- blas.pc
        `-- lapack.pc

EDIT: Upon further inspection into the derivation, I see I can override and add shared libs.

{ config ? {                                                                                                                                   
    allowUnfree = true;                                                                                                                        
    packageOverrides = pkgs: {                                                                                                                 
      liblapack = pkgs.liblapack.override { shared = true; };                                                                                  
    };                                                                                                                                         
  }                                                                                                                                            
, json ? builtins.fromJSON (builtins.readFile ./nixpkgs.json)                                                                                  
, pkgs ? with json; import (builtins.fetchTarball {                                                                                            
    url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";                                                                            
    inherit sha256;                                                                                                                            
  }) { inherit config; }                                                                                                                       
, compiler ? "ghc844"                                                                                                                          
}:                  

cc @Fuuzetsu disregard please :)

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

I think it's still broken.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthiasbeyer picture matthiasbeyer  路  3Comments

domenkozar picture domenkozar  路  3Comments

grahamc picture grahamc  路  3Comments

ayyess picture ayyess  路  3Comments

ob7 picture ob7  路  3Comments