Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

GHC 7.10.1 has GMP linking issues #38315

Closed
lukehoersten opened this issue Apr 2, 2015 · 22 comments
Closed

GHC 7.10.1 has GMP linking issues #38315

lukehoersten opened this issue Apr 2, 2015 · 22 comments

Comments

@lukehoersten
Copy link

After having ghc 7.10.1 installed via brew then trying to install a simple library, I get this error:
ld: warning: directory not found for option '-L/private/tmp/ghc20150402-41611-1b15z9c/ghc-7.10.1/gmp-static'

When using ghc 7.10.1 form Haskell for OS X the library installs fine.

$ clang --version
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
@FranklinChen
Copy link
Contributor

I just saw this too.

$ clang --version
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix

@tdsmith
Copy link
Contributor

tdsmith commented Apr 6, 2015

Does the library install succeed or fail? That looks like a warning, not a failure.

Is this resolved after brew update && brew reinstall ghc?

@tdsmith
Copy link
Contributor

tdsmith commented Apr 6, 2015

It looks like this is related to #38236, since the formula didn't use a "gmp-static" path before, so I don't expect that reinstalling will help.

@pthariensflame
Copy link
Contributor

The whole GMP situation was weird with Homebrew's GHC for a while. It recently got cleared up (sort of…), but any installations from before said cleanup will have a problem. As @tdsmith suggested, try uninstalling and reinstalling GHC after updating Homebrew; that should fix it.

@hvr
Copy link

hvr commented Apr 6, 2015

@pthariensflame as the any-issues-with-integer-gmp-1.0-culprit, I'm curious what the weirdness/issues were with Homebrew and GHC 7.10.1 related to integer-gmp;

Moreover, what's the contents of the installed ghc-gmp.h and HsIntegerGmp.h header on Homebrew, currently?

@lukehoersten
Copy link
Author

@tdsmith brew update && brew reinstall ghc did not fix the problem. Looking at #38236, it looks like that change was already in the version I was looking at.

Anyway, the problem still persists.

I'm able to reproduce the problem while trying to cabal get seqid; cabal build. It fails with the mentioned error for me but works for others on IRC.

@pthariensflame
Copy link
Contributor

@hvr The issue was present long before integer-gmp got overhauled. Basically, Homebrew was having GHC link to a dynamic GMP library, but that forced a GMP dependency onto every Haskell program. @MikeMcQuaid recently tried to tried to force GHC to link against GMP statically instead, but his first attempt caused all kinds of problems. His second attempt cleared up the problems he was seeing, but, given this issue, there are apparently still weirdnesses involved. :(

@tdsmith
Copy link
Contributor

tdsmith commented Apr 6, 2015

Does #38236 need to be reverted? Can someone verify that the libraries you're trying to install are actually failing, and not just printing a warning message?

@lukehoersten
Copy link
Author

@tdsmith It looks like the example I gave you is indeed just a warning and the library still builds though I think I had other cases of failures. Trying to reproduce now. Stay tuned.

@lukehoersten
Copy link
Author

Here's what lead me to believe GMP was causing errors but it could be just a coincidence that the error and warning happen at the same time. Without changing any code, both of these issues started happening after the 7.10 upgrade.

At this point I'm going to assume these are unrelated and we only have a warning about gmp.

Exit code: 1
Stderr:
ld: warning: directory not found for option '-L/private/tmp/ghc20150402-41611-1b15z9c/ghc-7.10.1/gmp-static'
hpc: can not find text_IINWRW1LxFGIctooOLjJAI/Data.Text.Unsafe in ["./.hpc","./dist/hpc/prof/mix/project-test"]

PS any ideas about this hpc error I'm getting would be helpful!

@FranklinChen
Copy link
Contributor

I only get a warning, not an error. An unrelated (?) gmp error I got a long while back was a different issue that has a solution: #35203

@slashfoo
Copy link

slashfoo commented Apr 6, 2015

I get what I pasted below, which I believe is related. One of the lines from brew's output ends with "--with-gmp-libraries=/pr" which I believe is truncated but not reflecting the real command. Otherwise it complains about not being able to execute ghc-config and about a missing file.

$ brew install ghc --with-tests
==> Downloading https://downloads.haskell.org/~ghc/7.10.1/ghc-7.10.1-src.tar.xz
Already downloaded: /Library/Caches/Homebrew/ghc-7.10.1.tar.xz
==> Downloading http://ftpmirror.gnu.org/gmp/gmp-6.0.0a.tar.bz2
Already downloaded: /Library/Caches/Homebrew/ghc--gmp-6.0.0a.tar.bz2
==> ./configure --prefix=/private/tmp/ghc20150406-69079-1my0pu7/ghc-7.10.1/gmp-static --enable-cxx --enable-shared=no
==> make
==> make check
==> make install
==> Downloading https://downloads.haskell.org/~ghc/7.8.4/ghc-7.8.4-x86_64-apple-darwin.tar.xz
Already downloaded: /Library/Caches/Homebrew/ghc--binary-7.8.4.tar.xz
==> ./configure --prefix=/private/tmp/ghc20150406-69079-1my0pu7/ghc-7.10.1/subfo --with-gcc=clang
==> make -j1 install
==> ./configure --prefix=/usr/local/Cellar/ghc/7.10.1 --build=x86_64-apple-darwin --with-gcc=clang --with-gmp-includes=/private/tmp/ghc20150406-69079-1my0pu7/ghc-7.10.1/gmp-static --with-gmp-libraries=/pr
==> make
==> Downloading https://downloads.haskell.org/~ghc/7.10.1/ghc-7.10.1-testsuite.tar.xz
Already downloaded: /Library/Caches/Homebrew/ghc--testsuite-7.10.1.tar.xz
==> make CLEANUP=1 THREADS=1 fast

../mk/boilerplate.mk:168: ../mk/ghcconfig_private_tmp_ghc20150406-69079-1my0pu7_ghc-7.10.1_subfo_bin_ghc.mk: No such file or directory
../mk/ghc-config "/private/tmp/ghc20150406-69079-1my0pu7/ghc-7.10.1/subfo/bin/ghc" >"../mk/ghcconfig_private_tmp_ghc20150406-69079-1my0pu7_ghc-7.10.1_subfo_bin_ghc.mk"; if [ $? != 0 ]; then rm -f "../mk/ghcconfig_private_tmp_ghc20150406-69079-1my0pu7_ghc-7.10.1_subfo_bin_ghc.mk"; exit 1; fi
/bin/sh: ../mk/ghc-config: cannot execute binary file
make: *** [../mk/ghcconfig_private_tmp_ghc20150406-69079-1my0pu7_ghc-7.10.1_subfo_bin_ghc.mk] Error 1

READ THIS: https://git.io/brew-troubleshooting

These open issues may also help:
GHC 7.10.1 has GMP linking issues (https://github.com/Homebrew/homebrew/issues/38315)
ghc can't bootstrap itself on snow leopard (https://github.com/Homebrew/homebrew/issues/38312)
ghc failed to build in 10.8.5 (https://github.com/Homebrew/homebrew/issues/32557)
ghc: $HOMEBREW_PREFIX search path breaks user's linker options (https://github.com/Homebrew/homebrew/issues/34626)

@lukehoersten
Copy link
Author

Using the --with-tests flag causes GHC to be built from source. I believe a prebuilt binary is installed otherwise so the compile paths may not be the same.

@MikeMcQuaid
Copy link
Member

As discussed above this is a warning and not an error and seems unrelated to your other problems. I'm open to solutions to remove that warning somehow but I think a harmless warning is superior to forcing a dynamic gmp dependency on everything that builds with ghc.

@lukehoersten
Copy link
Author

Agreed - we didn't realize the warning wasn't causing compile failures afterwards until you guys pointed it out.

@cartazio
Copy link

Ok, heres how you're supposed to build ghc on mac to have static linked GMP

https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/MacOSX#ImportantConsiderations
@hvr is that still correct for 7.10? (i updated those docs as of 7.8/7.9)

@hvr
Copy link

hvr commented Apr 10, 2015

@cartazio looks fine to me (so on OSX you're supposed to use the linked-in intree-gmp?)

PS: the docs will have to change for GHC HEAD/7.12 again though, as integer-gmp2 is gone (and renamed back to integer-gmp) -- build.mk.sample in GHC HEAD already shows that...

@MikeMcQuaid
Copy link
Member

Ok, heres how you're supposed to build ghc on mac to have static linked GMP

https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/MacOSX#ImportantConsiderations
@hvr is that still correct for 7.10? (i updated those docs as of 7.8/7.9)

@cartazio Is our current formula working/broken in that case? If it's looking broken could you submit a PR? Thanks!

@cartazio
Copy link

I can see a few ways the build could be made a bit nicer both wrt linkery, support window, etc

https://github.com/Homebrew/homebrew/blob/master/Library/Formula/ghc.rb#L63-L163
is the relevant range of the build formula for those who are curious.

yes, the way it does the gmp static linking isn't the mechanism that ghc devs or the haskell platform maintainer do, i'll try to find some time to at least post some notes here, or an outright PR.

I will note that any PR WILL likely also bring along my opinions about other parts of the formula :)

@MikeMcQuaid
Copy link
Member

I will note that any PR WILL likely also bring along my opinions about other parts of the formula :)

I'm open to PRs but if you can try and keep one change per-PR then it'll make it easier to review/merge. Thanks!

@MikeMcQuaid
Copy link
Member

This PR will fix it: #39025

@DomT4
Copy link
Member

DomT4 commented Jun 22, 2015

Should have been resolved by #39134.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants