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

Failed with integer-gmp #17

Closed
nodew opened this issue Nov 7, 2021 · 3 comments
Closed

Failed with integer-gmp #17

nodew opened this issue Nov 7, 2021 · 3 comments

Comments

@nodew
Copy link

nodew commented Nov 7, 2021

I tried to build a static linked package with this docker image, there're some third-party packages depending on integer-gmp,
When I try to build my package, it failed with error

#11 244.5 'cabal copy' failed.  Error message:
#11 244.5
#11 244.5 --  While building package integer-gmp-1.0.3.0 (scroll up to its section to see the error) using:
#11 244.5       /tmp/stack-e5c68ff1884e36c5/integer-gmp-1.0.3.0/.stack-work/dist/x86_64-linux/Cabal-3.2.1.0/setup/setup --builddir=.stack-work/dist/x86_64-linux/Cabal-3.2.1.0 copy
#11 244.5     Process exited with code: ExitFailure 1
#11 244.5
#11 244.5 Possible causes of this issue:
#11 244.5 * No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.
#11 244.5 * A cabal file that refers to nonexistent other files (e.g. a license-file that doesn't exist). Running 'cabal check' may point out these issues.
#11 244.5 * The Setup.hs file is changing the installation target dir.
#11 244.5

I checked the build logs, I found it may be caused by:

integer-gmp                      > setup: can't find include file ghc-gmp.h

Is there any idea to solve the problem?

@utdemir
Copy link
Owner

utdemir commented Nov 7, 2021

That is interesting. The images usually use integer-simple, so I think it might not be possible to build things that depend on integer-gmp specifically.

Can you share your code, and if that's not public, the build-dependencies field of your .cabal file?

@nodew
Copy link
Author

nodew commented Nov 8, 2021

That is interesting. The images usually use integer-simple, so I think it might not be possible to build things that depend on integer-gmp specifically.

Can you share your code, and if that's not public, the build-dependencies field of your .cabal file?

@utdemir Sure, it's an open source project haskell-realworld-example

@utdemir
Copy link
Owner

utdemir commented Nov 8, 2021

Thanks @nodew.

So, the error you are getting is expected (does not mean that it is not annoying): A few dependencies (hashable, cryptonite) of haskell-realworld-example pull in integer-gmp, which is not supported by this project. This is by design, as libgmp has licensing restrictions when linked statically.

However, this is not a big issue:

  • Before GHC 9, GHC supports two integer implementations integer-gmp and integer-simple. Usually, libraries which depend on integer-gmp has flags to make them depend on integer-simple instead. eg: hashable.cabal
  • After GHC 9, GHC comes with a single library called ghc-bignum, which has two implementations (gmp-backend and native-backend). So the libraries can depend on ghc-bignum unconditionally and it should just work.

So, there are two solutions that can get you past the issue:

  1. Keep using 8.x, and figure out how to get your dependencies use integer-simple instead. It should be an exercise of figuring out the correct flags to pass (on cabal.project or stack.yml).
  2. Use a GHC version newer than 9.0. Then, the dependencies would use ghc-bignum which should work without any headaches.

Unfortunately, even after the above changes haskell-realworld-example does not build, as it depends on libpq which has problems with static linking. We already have an issue for that: #15

Let me know if you can get past the gmp issue (or happy with the explanation), then I suggest we close this issue. If you also get the libpq error, feel free to pitch in to #15; or create another issue if you get another error.

Thanks again for the issue.

@nodew nodew closed this as completed Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants