Skip to content

Library tests fail #14

@khazaddum

Description

@khazaddum

Hello,

This library has been incredibly useful for a couple of apps I've developed. I'm currently working on implementing Nix Flakes for my apps to ease distribution and I have run into an interesting issue, running cabal test inside a Nix shell fails with this error:

$ cabal test
Resolving dependencies...
Build profile: -w ghc-9.6.5 -O1
In order, the following will be built (use -v for more details):
 - foreign-rust-0.2.0 (lib) (configuration changed)
 - foreign-rust-0.2.0 (test:test-foreign-rust) (configuration changed)
Configuring library for foreign-rust-0.2.0...
Preprocessing library for foreign-rust-0.2.0...
Building library for foreign-rust-0.2.0...
Configuring test suite 'test-foreign-rust' for foreign-rust-0.2.0...
Preprocessing test suite 'test-foreign-rust' for foreign-rust-0.2.0...
Building test suite 'test-foreign-rust' for foreign-rust-0.2.0...
[1 of 8] Compiling Test.Serialisation.Types ( test/Test/Serialisation/Types.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.5/foreign-rust-0.2.0/t/test-foreign-rust/build/test-foreign-rust/test-foreign-rust-tmp/Test/Serialisation/Types.o, dist-newstyle/build/x86_64-linux/ghc-9.6.5/foreign-rust-0.2.0/t/test-foreign-rust/build/test-foreign-rust/test-foreign-rust-tmp/Test/Serialisation/Types.dyn_o ) [Flags changed]

<no location info>: error:
    /home/rav/Documents/programs/haskell-foreign-rust/dist-newstyle/build/x86_64-linux/ghc-9.6.5/foreign-rust-0.2.0/build/libHSforeign-rust-0.2.0-inplace-ghc9.6.5.so: undefined symbol: haskell_ffi_external_ptr

The library builds fine and I can use it on other Nix Flakes (if I disable the default run of the test suites). This "undefined symbol" issue also happens when using cabal repl inside the Nix shell.

It's clear that it is looking for the companion Rust library, but when I use cabal test outside of the Nix shell, the tests compile and succeed. I suspect that I need to explicitly tell Nix where to look for this symbol, but it's not clear to me where does cabal find it in the first place.

Any pointers would be greatly appreciated.

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