Opened 8 years ago

Closed 8 years ago

#5403 closed bug (worksforme)

LLVM's llc pass does not print all the error messages to the console.

Reported by: kgardas Owned by: dterei
Priority: normal Milestone: 7.4.1
Component: Compiler Version: 7.3
Keywords: Cc:
Operating System: Linux Architecture: arm
Type of failure: Other Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Hello, when working on ARM port I've noticed that when LLVM's llc tool provides nicely formated error message for more than one line then GHC does not print all the lines out to the error output but just forgets them. This is bad IMHO since having it printed all the info is needed in case of the LLVM's errors I got: this was full backtrace of assert inside llc -- very helpful for debugging of what's going on. Also such assert was easily solved later by just adding proper -optlc= option to be passed to LLVM llc. So this is not just for new port developers, but will probably also helps general GHC audience, i.e. GHC users on platform where LLVM is used.

Change History (11)

comment:1 Changed 8 years ago by dterei

Component: CompilerCompiler (LLVM)
Owner: set to dterei

Hmmm. I don't think I've seen this behaviour, I've always seen llc print all its error messages. Can you provide sample output at all of how llc is cut off?

comment:2 Changed 8 years ago by kgardas

Hmm, it took me some time to get it from the head when this issue happened, but now I think this was once issue on ARM I've been fighting in the past. The issue was that I've not been able to get whole stack trace although it was printed by llc. The output of compilation looked:

"inplace/bin/ghc-stage1"   -H64m -opta=-march=armv7a -opta=-mfpu=vfpv3   -package-name ghc-prim-0.2.0.0 -hide-all-packages -i -ilibraries/ghc-prim/. -ilibraries/ghc-prim/dist-install/build -ilibraries/ghc-prim/dist-install/build/autogen -Ilibraries/ghc-prim/dist-install/build -Ilibraries/ghc-prim/dist-install/build/autogen -Ilibraries/ghc-prim/.   -optP-include -optPlibraries/ghc-prim/dist-install/build/autogen/cabal_macros.h -package rts-1.0  -package-name ghc-prim -XHaskell98 -XCPP -XMagicHash -XForeignFunctionInterface -XUnliftedFFITypes -XUnboxedTuples -XEmptyDataDecls -XNoImplicitPrelude -opta=-march=armv7a -opta=-mfpu=vfpv3 -no-user-package-conf -rtsopts     -odir libraries/ghc-prim/dist-install/build -hidir libraries/ghc-prim/dist-install/build -stubdir libraries/ghc-prim/dist-install/build -hisuf hi -osuf  o -hcsuf hc -c libraries/ghc-prim/./GHC/Magic.hs -o libraries/ghc-prim/dist-install/build/GHC/Magic.o
Formal argument #8 has unhandled type i32UNREACHABLE executed at /export/home/karel/vcs/llvm-head-2-steve-arm-support-vfp3/lib/CodeGen/CallingConvLower.cpp:81!
Stack dump:
make[1]: *** [libraries/ghc-prim/dist-install/build/GHC/Magic.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2 

Please note *Stack dump:* the real stack dump follows but it's not printed by ghc. This issue makes debugging of GHC/LLVM not easy as you will always need to save temporaries and run llc just from command-line to see the stack dump.

comment:3 Changed 8 years ago by dterei

Component: Compiler (LLVM)Compiler
Status: newinfoneeded

Can you provide me with a means to reproduce on X86? Since LLVM includes all backends if you give me a file that crashes under ARM I should still be able to reproduce on x86. I can't really tackle this without a testcase though.

If you are able to look yourself at the code, place to look I think is compiler/main/SysTools.lhs function 'builderMainLoop'.

This also isn't just an LLVM issue but all tools run by GHC.

comment:4 Changed 8 years ago by kgardas

IMHO this should be quite simple and you don't need to duplicate it on llc itself. (1) compile GHC with LLVM support (2) move llc out of your PATH and add llc script or binary to your PATH which prints several lines of text Test what GHC prints to you when you try to compile with -fllvm.

comment:5 Changed 8 years ago by dterei

That was the first thing I did to try to reproduce. For me all the lines of text are printed and I can't see anything in the GHC code base that would necessarily stop anything being printed. All I can think of right now is that LLC detects how its being run and differs its printing.

comment:6 Changed 8 years ago by kgardas

OK, but have you also tried mixing stdout/stderr outputs? Or just printing to stderr? That might be the reason...

comment:7 Changed 8 years ago by dterei

Previously I think just stderr, just tried then though. I still get all output but it is rearranged as all the stderr will be printed together not interleaved with stdout.

e.g heres my testcase output:

$ ghc -fllvm M.hs
[1 of 1] Compiling M                ( M.hs, M.o )
1 Hello world aaAaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
3 Hello world aaAaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
4 Hello world aaAaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
6 Hello world aaAaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
7 Hello world aaAaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
8 Hello world aaAaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
12 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
13 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
14 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
15 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
16 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
2a ----------------- START ------------------------------------------
2 stderr world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
5 stderr world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
9 stderr world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
10 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
11 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
20 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
21 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
22 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
23 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
24 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
27 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
28 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
35 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
36 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
37 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
38 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
39 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
40 stderr world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
41 -------------------- END ------------------------------------------
42 stxxx world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
43 stxxx world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
17 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
18 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
19 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
25 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
26 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
29 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
30 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
31 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
32 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
33 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
34 Hello world aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
47 Hello world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
44 stxxx world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
45 stxxx world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc
46 stxxx world aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccc

comment:8 Changed 8 years ago by dterei

stdxxx = printed to both stderr and stdout stderr = printed only to stderr _ = printed only to stdout

comment:9 Changed 8 years ago by igloo

Milestone: 7.4.1

comment:10 Changed 8 years ago by dterei

Hey Karel,

If you can provide any update on this then that would be great. Otherwise I'm going to close as I've never been able to reproduce.

comment:11 Changed 8 years ago by dterei

Resolution: worksforme
Status: infoneededclosed

actually, just closing now but feel free to reopen if you have an update.

Note: See TracTickets for help on using tickets.