Opened 9 years ago

Closed 9 years ago

#4995 closed bug (fixed)

Compiling pandoc with llvm backend fails with panic

Reported by: jgm Owned by: dterei
Priority: normal Milestone: 7.2.1
Component: Compiler (LLVM) Version: 7.0.2
Keywords: llvm pandoc Cc:
Operating System: MacOS X Architecture: x86
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

I decided to try compiling pandoc with the llvm backend (GHC 7.0.2 32 bit on Mac OSX 10.6). I put -fllvm in Ghc-Options in the cabal file and did a 'cabal install'. It failed eventually with the following message, which I am duly reporting:

[14 of 37] Compiling Text.Pandoc.Readers.LaTeX ( src/Text/Pandoc/Readers/LaTeX.hs, dist/build/pandoc/pandoc-tmp/Text/Pandoc/Readers/LaTeX.o )
SpecConstr
    Function `$w$j{v s62TR} [lid]'
      has two call patterns, but the limit is 1
    Use -fspec-constr-count=n to set the bound
    Use -dppr-debug to see specialisations
SpecConstr
    Function `$w$j{v s62TR} [lid]'
      has two call patterns, but the limit is 1
    Use -fspec-constr-count=n to set the bound
    Use -dppr-debug to see specialisations
[...deleted more in that vein...]
SpecConstr
    Function `$w$j{v s63cF} [lid]'
      has two call patterns, but the limit is 1
    Use -fspec-constr-count=n to set the bound
    Use -dppr-debug to see specialisations
ghc: panic! (the 'impossible' happened)
  (GHC version 7.0.2 for i386-apple-darwin):
	LLvmMangler Cannot read"_c6"as it's not an Int

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Change History (11)

comment:1 Changed 9 years ago by dterei

Owner: changed from davidterei@… to dterei

OK I'll take a look, seems to be a bug with the LLVM mangler. Its a hard process for me to test on OS X so unfortunately this bug seems to have slipped through.

Which version of LLVM are you using? If you want to you should be fine compiling pandoc on a different platform then OSX.

comment:2 Changed 9 years ago by jgm

I've got llvm version 2.8.

comment:3 Changed 9 years ago by igloo

Description: modified (diff)

comment:4 Changed 9 years ago by igloo

Milestone: 7.2.1

comment:5 Changed 9 years ago by dterei

jgm would you be able to do this for me please:

ghc -fllvm -O2 -c -keep-llvm-files -keep-s-files src/Text/Pandoc/Readers/LaTeX.hs

Then send me/attach to this bug the LaTex.s and LaTeX.ll files that should appear. I have only limited access to an OSX machine, enough to build ghc and run the ghc test suite but installing cabal packages gets a little difficult. So I think this will be the quickest and easiest way for me to be able to fix the problem.

Thanks

comment:6 Changed 9 years ago by jgm

Unfortunately there's a 256K limit on attachments, and these files are far larger.

-rw-r--r--  1 jgm  jgm  31678880 Mar  7 19:00 src/Text/Pandoc/Readers/LaTeX.ll
-rw-r--r--  1 jgm  jgm   9603608 Mar  7 19:00 src/Text/Pandoc/Readers/LaTeX.s

Should I email them to you? If so, send me an email directly so I know where to send them. jgm at berkeley dot edu

comment:7 Changed 9 years ago by dterei

Don't worry about emailing, I can reproduce the bug now. OK I know what the bug is and it should be fairly easy to fix. There is a strange and slightly worrying thing going on though for me, when the build fails, if I simply do 'cabal install' again, the same file that failed to compile will this time compile successfully. Would you be able to try this out please jgm and see if its not just my machine. The runs should produce identical output so I'm not sure where the difference is coming from (although I know what the difference is).

comment:8 Changed 9 years ago by jgm

I tried 'cabal install' again and it worked, just as you experienced.

comment:9 Changed 9 years ago by dterei

OK figured it all out. Basically one of the things the LLVM mangler searches for in the assembly instructions is 'jmp' instructions. I was naively just searching "jmp" which picks up some of the random names that ghc generates such as:

    movl    $_sjmpK_info, 4(%ebp)
    [...]
    jmp     _sjmp7_info

Ghc name generator is basically sequential, so thats why the bug only appeared after compiling a certain amount of code and why restarting the compiler fixes the bug. I have a fix ready that I'll commit soon but just restarting the compiler is a decent enough work around until the next GHC comes out. Thanks for the bug report!

comment:10 Changed 9 years ago by dterei

Status: newmerge

Fixed.

Wed Mar  9 13:53:46 PST 2011  David Terei <davidterei@gmail.com>
  * LLVM: Fix #4995, llvm mangler broken for large compiles

comment:11 Changed 9 years ago by igloo

Resolution: fixed
Status: mergeclosed

No stable branch at the moment, so no need to merge.

Note: See TracTickets for help on using tickets.