Skip to content

Cannot run tests with bindist using shell.nix missing lib gmp #704

Closed
@nmattia

Description

@nmattia

Build fails when using the ghc bindist if libgmp is not installed on the system. Even adding it to the nix-shell does not help:

[nix-shell:~/projects/tweag/rules_haskell]$ echo $LD_LIBRARY_PATH 
/nix/store/rd7n0v6mymvyqbw3d307caqc23c8kc71-gmp-6.1.2/lib

The link cannot find libgmp during build:

[nix-shell:~/projects/tweag/rules_haskell]$ bazel test //tests/binary-with-lib-dynamic/...
...
ERROR: /home/nicolas/projects/tweag/rules_haskell/tests/binary-with-lib-dynamic/BUILD:9:1: error executing shell command: '/nix/store/pawkx6zfnj59zvpa0hkrrqin9f9iwika-bash/bin/bash -c
        export PATH=${PATH:-} # otherwise GCC fails on Windows

        # this is equivalent to 'readarray'. We do not use 'readarray' ...' failed (Exit 1) bash failed: error executing command /nix/store/pawkx6zfnj59zvpa0hkrrqin9f9iwika-bash/bin/bash -c ... (remaining 1 argument(s) skipped)

/nix/store/3xwc1ip20b0p68sxqbjjll0va4pv5hbv-binutils-2.30/bin/ld.gold: error: cannot find -lgmp
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
FAILED: Build did NOT complete successfully

Passing action_env and test_env does not help:

[nix-shell:~/projects/tweag/rules_haskell]$ bazel test //tests/binary-with-lib-dynamic/... --action_env=LD_LIBRARY_PATH= --test_env=LD_LIBRARY_PATH
<same error>
FAILED: Build did NOT complete successfully
[nix-shell:~/projects/tweag/rules_haskell]$ bazel test //tests/binary-with-lib-dynamic/... --action_env=LD_LIBRARY_PATH=$LD_LIBRARY_PATH --test_env=LD_LIBRARY_PATH=$LD_LIBRARY_PATH
<same error>
FAILED: Build did NOT complete successfully

Specifying --linkopt=-L/path/to/lib fixes some builds:

[nix-shell:~/projects/tweag/rules_haskell]$ bazel test //tests/binary-with-lib-dynamic/... --linkopt=-L$LD_LIBRARY_PATH
...
//tests/binary-with-lib-dynamic:binary-with-lib-dynamic         (cached) PASSED in 0.2s

Executed 0 out of 1 test: 1 test passes.
INFO: Build completed successfully, 9 total actions

But not all, the java_classpath now fails with a different error:

[nix-shell:~/projects/tweag/rules_haskell]$ bazel test //tests/java_classpath/... --linkopt=-L$LD_LIBRARY_PATH
/tweag/rules_haskell/tests/java_classpath/BUILD:8:1: error executing shell command: '/nix/store/pawkx6zfnj59zvpa0hkrrqin9f9iwika-bash/bin/bash -c
        export PATH=${PATH:-} # otherwise GCC fails on Windows

        # this is equivalent to 'readarray'. We do use 'readarray' in o...' failed (Exit 1) bash failed: error executing command /nix/store/pawkx6zfnj59zvpa0hkrrqin9f9iwika-bash/bin/bash -c ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
<command line>: can't load .so/.DLL for: libgmp.so (libgmp.so: cannot open shared object file: No such file or directory)
Target //tests/java_classpath:java_classpath failed to build
FAILED: Build did NOT complete successfully

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions