Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

'html-test' crashes on 8.4.1 #767

Closed
harpocrates opened this issue Mar 8, 2018 · 11 comments
Closed

'html-test' crashes on 8.4.1 #767

harpocrates opened this issue Mar 8, 2018 · 11 comments

Comments

@harpocrates
Copy link
Collaborator

On MacOS and using the newly released GHC-8.4.1, html-tests fail at runtime.

 $ git clone https://github.com/haskell/haddock.git
 $ cd haddock
 haddock$ git checkout ghc-8.4
 haddock$ cabal new-test -w ghc-8.4.1 html-test

Here is the output from re-running the last command:

haddock$ cabal new-test -w ghc-8.4.1 html-test
In order, the following will be built (use -v for more details):
 - haddock-2.19.0 (test:html-test) (first run)
Preprocessing test suite 'html-test' for haddock-2.19.0..
Building test suite 'html-test' for haddock-2.19.0..
Running 1 test suites...
Test suite html-test: RUNNING...
Haddock version 2.19.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
8.4.1
haddock:
lookupSymbol failed in relocateSection (RELOC_GOT)
/Users/atheriault/.stack/programs/x86_64-osx/ghc-8.4.1/lib/ghc-8.4.1/integer-gmp-1.0.1.0/HSinteger-gmp-1.0.1.0.o: unknown symbol `___gmp_rands'
Failed to run Haddock on specified test files
Generating documentation...
Test suite html-test: FAIL
Test suite logged to:
/Users/atheriault/Code/haddock/dist-newstyle/build/x86_64-osx/ghc-8.4.1/haddock-2.19.0/c/html-test/test/haddock-2.19.0-html-test.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal: Tests failed for test:html-test from haddock-2.19.0.

/cc @bgamari this is what I was talking about.

@alexbiehl
Copy link
Member

I experienced this as well.

@alexbiehl
Copy link
Member

here are some observations I made:

  • it's not the test suite per se; just try haddock on a test file which uses TemplateHaskell
  • this doesn't happen with the release provided haddock, only with local built haddock
  • Herbert suggest a broken gmp, reinstalling didn't help
  • Googling reveals https://mail.haskell.org/pipermail/ghc-devs/2017-June/014325.html by Richard Eisenberg, so this seems to be a somewhat old issue.

@LeventErkok
Copy link

LeventErkok commented Mar 18, 2018

I've observed the same with doctest:

$ doctest Data/SBV/Examples/Polynomials/Polynomials.hs
doctest:
lookupSymbol failed in relocateSection (RELOC_GOT)
/usr/local/lib/ghc-8.4.1/integer-gmp-1.0.1.0/HSinteger-gmp-1.0.1.0.o: unknown symbol `___gmp_rands'
doctest: doctest: unable to load package `integer-gmp-1.0.1.0'

Unfortunately brew install gmp (as suggested in the previous comment by @alexbiehl) does not solve the issue for me either. Did you guys find some other workaround?

@harpocrates
Copy link
Collaborator Author

This indeed only hits me when I'm building Haddock myself, and only on files using TH (no matter how small).

-- Main.hs
{-# LANGUAGE TemplateHaskell #-}

main = pure ()

$(pure [])

@harpocrates
Copy link
Collaborator Author

It appears the unexpected behaviour comes from typecheckModule function from the GHC API (doctest calls this too, so I'm not surprised it would come across the same behaviour). Building a fresh 8.4.1 now to debug further...

@LeventErkok
Copy link

Should this be filed against GHC? (Maybe there already is a ticket?)

@harpocrates
Copy link
Collaborator Author

This is a mess. I suspect Cabal is partially to blame.

  • [manually built GHC-8.4, new-style cabal] After rebuilding GHC 8.4, I returned to build Haddock against it. With the new-style build commands, I eventually came up against a shadowed dependency error:
$ cabal new-build -w ./ghc/inplace/bin/ghc-stage2
In order, the following will be built (use -v for more details):
 - haddock-api-2.19.0.1 (lib) (first run)
 - haddock-2.19.0.1 (exe:haddock) (first run)
Preprocessing library for haddock-api-2.19.0.1..
Building library for haddock-api-2.19.0.1..
<command line>: cannot satisfy -package-id ghc-paths-0.1.0.9-f1132a3630dfd069ac6c748c11485c2bc7a77709c7f89a58360749883bab0d93:
    ghc-paths-0.1.0.9-f1132a3630dfd069ac6c748c11485c2bc7a77709c7f89a58360749883bab0d93 is unusable due to shadowed dependencies:
      base-4.11.0.0
    (use -v for more information)
cabal: Failed to build haddock-api-2.19.0.1 (which is required by exe:haddock
from haddock-2.19.0.1).
  • [manually built GHC-8.4, old-style cabal] With the old-style commands, I got a bit further: I was able to build everything, testsuite included. Unfortunately, with old-style commands, cabal test isn't smart enough to handle a custom GHC version. However, the haddock executable I built did not crash when fed files that use TemplateHaskell.
$ cabal test html-test
Preprocessing executable 'haddock' for haddock-2.19.0.1..
Building executable 'haddock' for haddock-2.19.0.1..
Preprocessing test suite 'html-test' for haddock-2.19.0.1..
Building test suite 'html-test' for haddock-2.19.0.1..
Running 1 test suites...
Test suite html-test: RUNNING...
Haddock version 2.19.0.1, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
8.4.1
Couldn't find base test dependency: array
Test suite html-test: FAIL
Test suite logged to: dist/test/haddock-2.19.0.1-html-test.log
0 of 1 test suites (0 of 1 test cases) passed.
  • [binary release GHC-8.4, old-style cabal] To fix the problems about running the testsuite, I went back to using the release binary for GHC 8.4:
$ cabal build -w ghc-8.4
$ cabal test html-test
Preprocessing executable 'haddock' for haddock-2.19.0.1..
Building executable 'haddock' for haddock-2.19.0.1..
Preprocessing test suite 'html-test' for haddock-2.19.0.1..
Building test suite 'html-test' for haddock-2.19.0.1..
Running 1 test suites...
Test suite html-test: RUNNING...
Haddock version 2.19.0.1, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
8.4.1
haddock:
lookupSymbol failed in relocateSection (RELOC_GOT)
/Users/atheriault/.stack/programs/x86_64-osx/ghc-8.4.1/lib/ghc-8.4.1/integer-gmp-1.0.1.0/HSinteger-gmp-1.0.1.0.o: unknown symbol `___gmp_rands'
Failed to run Haddock on specified test files
Generating documentation...
Test suite html-test: FAIL
Test suite logged to: dist/test/haddock-2.19.0.1-html-test.log
0 of 1 test suites (0 of 1 test cases) passed.
  • [binary release GHC-8.4, new-style cabal] Trying again with the new-style commands and the release binary for GHC 8.4, I again hit the same error.
$ ./dist-newstyle/build/x86_64-osx/ghc-8.4.1/haddock-2.19.0.1/c/html-test/build/html-test/html-test
Haddock version 2.19.0.1, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
8.4.1
Generating documentation...
haddock:
lookupSymbol failed in relocateSection (RELOC_GOT)
/Users/atheriault/.stack/programs/x86_64-osx/ghc-8.4.1/lib/ghc-8.4.1/integer-gmp-1.0.1.0/HSinteger-gmp-1.0.1.0.o: unknown symbol `___gmp_rands'
Failed to run Haddock on specified test files

At this point, I am at a complete loss for what to try next. Ideas welcome.

@LeventErkok
Copy link

This is still happening with 8.4.2 for me, using doctest. Can anyone else confirm?

@harpocrates
Copy link
Collaborator Author

This appears to still be broken in 8.4.2. 😢

@harpocrates
Copy link
Collaborator Author

harpocrates commented May 8, 2018

Alright, I think I'm close to nailing this. I think there is something suspicious about the HSinteger-gmp-1.0.2.0.o file from GHC's integer-gmp lib folder. I think all that we need to do to fix this issue is remove this file. When I do that, everything starts working again.

Note that the symbols provided by this object file are already in the static library of the same name. Furthermore, when I manually install GHC (after building from source), this troublesome file is not present.

I'm obviously still investigating, but I figured I'd ask if anyone knows any reason HSinteger-gmp-1.0.2.0.o should not be deleted...

EDIT

Further evidence this is the issue: GHC 8.4.1 and GHC 8.4.2 are the versions that cause this issue. They are also the only versions where the tarball distributed at https://downloads.haskell.org includes the problematic object file.

@harpocrates
Copy link
Collaborator Author

This was never fixed in the GHC 8.4.*. It is however fixed in GHC 8.6.*.

Closing since this ended up being a GHC-side bug (and it is now fixed upstream).

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

3 participants