Lift instance cause GHC build error: unknown symbol with CFFI

Hi everyone, I’m building a floating-point library for Clash that uses FloPoCo. The library integrates with the MPFR library via the hmpfr Haskell bindings to perform accurate software simulations of floating-point operations. I’ve encountered build errors related to linking the MPFR library: Windows: unknown symbol 'mpfr_add' in Arithmetic.o. Linux: symbol lookup error: undefined symbol 'mpfr_custom_get_size_wrap'. Interestingly, cabal repl works as expected, but cabal build fails. This suggests a linking issue specific to the build process. Steps to Reproduce Clone the repository: https://github.com/yourcomrade/FloPoCoFloat. Install MPFR: Windows: pacman -S mingw-w64-clang-x86_64-mpfr Linux: sudo apt install libmpfr6 libmpfr-dev Check out the Error_branch. Build the project using cabal build. Expected Behavior The project should compile without errors. Notably, if cabal build fails, I would expect cabal repl to fail too, but that’s not the case. Additional Info OS: Windows 11, Ubuntu WSL 5.15 Tools: GHC 9.8.2, Cabal 3.10.3, GCC 11.4 Relevant discussion: Cabal issue: https://github.com/haskell/cabal/issues/10651 I have a discussion with Cabal maintainer and he suspects that is GHC linking issue. Does anyone have insights into resolving this issue? Any help would be appreciated. Kind regards, Minh

Minh Le
Hi everyone, I’m building a floating-point library for Clash that uses FloPoCo.
Very cool; I've not heard of FloPoCo prior to this; that looks like a nice set of cores.
The library integrates with the MPFR library via the hmpfr Haskell bindings to perform accurate software simulations of floating-point operations.
I’ve encountered build errors related to linking the MPFR library: Windows: unknown symbol 'mpfr_add' in Arithmetic.o. Linux: symbol lookup error: undefined symbol 'mpfr_custom_get_size_wrap'.
Interestingly, cabal repl works as expected, but cabal build fails.
Indeed that is intriguing. Indeed you have the right `extra-libraries` entries in your Cabal file.
This suggests a linking issue specific to the build process.
I have tried to reproduce this but it would seem that the repository is missing the FPFloat module. Cheers, - Ben

Hi Ben,
The missing module FPFloat is something related in the naming of the
file. Currently, I am developing this library in Window and test it
with both Window and Linux WSL. In Linux, it has stricter naming, so
that you have to rename file fpfloat.hs and proto.hs into FPFloat.hs
and Proto.hs. It is mentioned in the discussion in the Cabal issue,
which I have included the link.
Kind regards,
Minh
On Thu, Dec 19, 2024 at 7:08 PM Ben Gamari
Minh Le
writes: Hi everyone, I’m building a floating-point library for Clash that uses FloPoCo.
Very cool; I've not heard of FloPoCo prior to this; that looks like a nice set of cores.
The library integrates with the MPFR library via the hmpfr Haskell bindings to perform accurate software simulations of floating-point operations.
I’ve encountered build errors related to linking the MPFR library: Windows: unknown symbol 'mpfr_add' in Arithmetic.o. Linux: symbol lookup error: undefined symbol 'mpfr_custom_get_size_wrap'.
Interestingly, cabal repl works as expected, but cabal build fails.
Indeed that is intriguing. Indeed you have the right `extra-libraries` entries in your Cabal file.
This suggests a linking issue specific to the build process.
I have tried to reproduce this but it would seem that the repository is missing the FPFloat module.
Cheers,
- Ben
-- ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ Le Hoang Minh Handphone: +31 684054062 Email: MinhXecole@gmail.com

Minh Le
Hi Ben, The missing module FPFloat is something related in the naming of the file. Currently, I am developing this library in Window and test it with both Window and Linux WSL. In Linux, it has stricter naming, so that you have to rename file fpfloat.hs and proto.hs into FPFloat.hs and Proto.hs. It is mentioned in the discussion in the Cabal issue, which I have included the link.
Hi Minh, I have tried reproducing this under a Debian 11 VM yet strangely it built without any trouble. I checked a few hypotheses yet nothing obvious seems wrong. I have pushed my full reproducer here [1]. I will try again under Windows when I get a chance. Cheers, - Ben [1] https://github.com/bgamari/FloPoCoFloat/tree/wip/repro
participants (2)
-
Ben Gamari
-
Minh Le