Opened 3 years ago

Closed 4 months ago

#7143 closed bug (fixed)

ghc-7.6.0.20120810-x86_64-windows.exe -> ghc can't figure out LLVM version

Reported by: cetinsert Owned by: Fanael
Priority: normal Milestone: 7.8.4
Component: Compiler (LLVM) Version: 7.6.1-rc1
Keywords: llvm Cc: shelarcy@…, dterei
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions: Phab:D190

Description

I have downloaded:

ghc: ghc-7.6.0.20120810-x86_64-windows.exe

mingw64: http://www.drangon.org/mingw/mirror.php?num=2&fname=mingw-w64-bin-x86_64-20120807.7z

llvm64: http://www.drangon.org/mingw/mirror.php?num=2&fname=llvm-3.1-w64-bin-x86_64-20120610.7z

my path contains:

/c/ghc/ghc-7.6.0.20120810/bin:/c/Users/Cetin/AppData/Roaming/cabal/bin:/c/llvm/bin:/c/mw64/bin

When I run:

ghc -fllvm --make Main.hs

I get:

[1 of 1] Compiling Main             ( Main.hs, Main.o )

<no location info>:
    Warning: Couldn't figure out LLVM version!
             Make sure you have installed LLVM

Attached is the output from:

ghc -v3 -fllvm --make Main.hs

for all Main.hs - it mentions:

*** LlVM CodeGen:
Error (figuring out LLVM version): : runInteractiveProcess: invalid argument (Invalid argument)

<no location info>:
    Warning: Couldn't figure out LLVM version!
             Make sure you have installed LLVM
*** LLVM Optimiser:
"" "C:\Users\Cetin\AppData\Local\Temp\ghc6036_0\ghc6036_0.ll" "-o" "C:\Users\Cetin\AppData\Local\Temp\ghc6036_0\ghc6036_0.bc" "-mem2reg" "--enable-tbaa=true"


Failed: "" "C:\Users\Cetin\AppData\Local\Temp\ghc6036_0\ghc6036_0.ll" "-o" "C:\Users\Cetin\AppData\Local\Temp\ghc6036_0\ghc6036_0.bc" "-mem2reg" "--enable-tb

Attachments (1)

llvm-full-version-check (6.0 KB) - added by cetinsert 3 years ago.
checking versions of llc and opt in the same session as a -v3 compilation with ghc -fllvm

Download all attachments as: .zip

Change History (26)

Changed 3 years ago by cetinsert

checking versions of llc and opt in the same session as a -v3 compilation with ghc -fllvm

comment:1 Changed 3 years ago by cetinsert

  • Summary changed from ghc-7.6.0.20120810-x86_64-windows.exe -> ghc can't figure out LLC version to ghc-7.6.0.20120810-x86_64-windows.exe -> ghc can't figure out LLVM version

comment:2 Changed 3 years ago by igloo

  • difficulty set to Unknown
  • Milestone set to 7.8.1
  • Priority changed from normal to high

Thanks for the report. I've never tried to use LLVM, but GHC's built-in native-code-generator should work, so I don't think this is urgent. I've therefore milestoned it for 7.8.

comment:3 Changed 3 years ago by dterei

  • Owner set to dterei

Thanks for the report cetinsert, I'll take a look as time permits.

comment:4 Changed 3 years ago by shelarcy

  • Architecture changed from x86_64 (amd64) to Unknown/Multiple
  • Cc shelarcy@… added

Windows 32 bit version causes same problem.

> ghc -info
 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts"," -fwrapv")
 ,("C compiler command","$topdir/../mingw/bin/gcc.exe")
 ,("C compiler flags"," -fno-stack-protector  -Wl,--hash-size=31 -Wl,--reduce-me
mory-overheads")
 ,("ar command","$topdir/../mingw/bin/ar.exe")
 ,("ar flags","q")
 ,("ar supports at file","YES")
 ,("touch command","$topdir/touchy.exe")
 ,("dllwrap command","$topdir/../mingw/bin/dllwrap.exe")
 ,("windres command","$topdir/../mingw/bin/windres.exe")
 ,("perl command","$topdir/../perl/perl.exe")
 ,("target os","OSMinGW32")
 ,("target arch","ArchX86")
 ,("target word size","4")
 ,("target has GNU nonexec stack","False")
 ,("target has .ident directive","True")
 ,("target has subsections via symbols","False")
 ,("LLVM llc command","")
 ,("LLVM opt command","")
 ,("Project version","7.6.1")
 ,("Booter version","7.4.2")
 ,("Stage","2")
 ,("Build platform","i386-unknown-mingw32")
 ,("Host platform","i386-unknown-mingw32")
 ,("Target platform","i386-unknown-mingw32")
 ,("Have interpreter","YES")
 ,("Object splitting supported","YES")
 ,("Have native code generator","YES")
 ,("Support SMP","YES")
 ,("Unregisterised","NO")
 ,("Tables next to code","YES")
 ,("RTS ways","l debug  thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debu
g_dyn")
 ,("Leading underscore","YES")
 ,("Debug on","False")
 ,("LibDir","C:\\ghc\\ghc-7.6.1\\lib")
 ,("Global Package DB","C:\\ghc\\ghc-7.6.1\\lib\\package.conf.d")
 ,("Gcc Linker flags","[\"-Wl,--hash-size=31\",\"-Wl,--reduce-memory-overheads\"
]")
 ,("Ld Linker flags","[\"--hash-size=31\",\"--reduce-memory-overheads\"]")
 ]

> ghc -fllvm Main.hs
[1 of 1] Compiling Main             ( Main.hs, Main.o )

<no location info>:
    Warning: Couldn't figure out LLVM version!
             Make sure you have installed LLVM

I used GHC 7.6.1 with LLVM official site's LLVM 2.9 binary.

> llc --version
Low Level Virtual Machine (http://llvm.org/):
  llvm version 2.9
  Optimized build.
  Built Apr  6 2011 (03:41:01).
  Host: i386-pc-mingw32
  Host CPU: i686

comment:5 Changed 2 years ago by igloo

  • Component changed from Compiler to Compiler (LLVM)

comment:6 Changed 2 years ago by shelarcy

comment:7 Changed 21 months ago by schyler

I believe I suffer from this bug also, and so does my friend who recently installed a fresh MinGW + Haskell Platform and can't get it to work. Punting.

Last edited 21 months ago by schyler (previous) (diff)

comment:8 Changed 21 months ago by schyler

Using the HP ghc on Windows you get an error like this (even if llc and opt are directly callable from the *same* command line):

<no location info>:
    Warning: Couldn't figure out LLVM version!
             Make sure you have installed LLVM

This occurs with all versions of llvm.

ghc --info is interesting:

 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts"," -fwrapv")
 ,("C compiler command","$topdir/../mingw/bin/gcc.exe")
 ,("C compiler flags"," -fno-stack-protector  -Wl,--hash-size=31 -Wl,--reduce-memory-overheads")
 ,("ar command","$topdir/../mingw/bin/ar.exe")
 ,("ar flags","q")
 ,("ar supports at file","YES")
 ,("touch command","$topdir/touchy.exe")
 ,("dllwrap command","$topdir/../mingw/bin/dllwrap.exe")
 ,("windres command","$topdir/../mingw/bin/windres.exe")
 ,("perl command","$topdir/../perl/perl.exe")
 ,("target os","OSMinGW32")
 ,("target arch","ArchX86")
 ,("target word size","4")
 ,("target has GNU nonexec stack","False")
 ,("target has .ident directive","True")
 ,("target has subsections via symbols","False")
 ,("LLVM llc command","")
 ,("LLVM opt command","")
 ,("Project version","7.6.3")
 ,("Booter version","7.4.1")
 ,("Stage","2")
 ,("Build platform","i386-unknown-mingw32")
 ,("Host platform","i386-unknown-mingw32")
 ,("Target platform","i386-unknown-mingw32")
 ,("Have interpreter","YES")
 ,("Object splitting supported","YES")
 ,("Have native code generator","YES")
 ,("Support SMP","YES")
 ,("Unregisterised","NO")
 ,("Tables next to code","YES")
 ,("RTS ways","l debug  thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debug_dyn")
 ,("Leading underscore","YES")
 ,("Debug on","False")
 ,("LibDir","C:\\Program Files (x86)\\Haskell Platform\\2013.2.0.0\\lib")
 ,("Global Package DB","C:\\Program Files (x86)\\Haskell Platform\\2013.2.0.0\\lib\\package.conf.d")
 ,("Gcc Linker flags","[\"-Wl,--hash-size=31\",\"-Wl,--reduce-memory-overheads\"]")
 ,("Ld Linker flags","[\"--hash-size=31\",\"--reduce-memory-overheads\"]")
 ]

For some reason the commands to interface with llc/opt are empty. I was able to work around it by doing this;

alias ghc-llvm="ghc -pgmlo opt -pgmlc llc -fllvm"

... and then using ghc-llvm whenever I wanted to use llvm. This works perfectly.

The 64-bit GHC from GHC HQ has the same problem, and the same workaround works for me.

Last edited 21 months ago by schyler (previous) (diff)

comment:9 Changed 21 months ago by carter

the relevant bit being that the windows build doesn't have the llvm cli operations named

 ,("LLVM llc command","")
 ,("LLVM opt command","")

comment:10 follow-up: Changed 21 months ago by carter

schyler, could you confirm that editing the relevant fields in your GHC settings file fixes things

comment:11 in reply to: ↑ 10 ; follow-up: Changed 21 months ago by schyler

Replying to carter:

schyler, could you confirm that editing the relevant fields in your GHC settings file fixes things

Confirming llvm 3.4svn and 2.9 on path work perfectly with the settings file fix.

comment:12 Changed 20 months ago by schyler

Punting for fix.

comment:13 in reply to: ↑ 11 Changed 14 months ago by is7s

Replying to schyler:

Replying to carter:

schyler, could you confirm that editing the relevant fields in your GHC settings file fixes things

Confirming llvm 3.4svn and 2.9 on path work perfectly with the settings file fix.

Where is the GHC settings file located on Windows?

comment:14 Changed 12 months ago by thoughtpolice

  • Priority changed from high to normal

comment:15 Changed 11 months ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.8.4

Moving to 7.8.4.

comment:16 Changed 9 months ago by k.gadek

Hi,

Is there a plan for fixing this soon? We hit this bug on OS X (precisely the same thing as here: http://stackoverflow.com/questions/24796874/cant-install-diagrams-arithmoi-on-mac — arithmoi now uses LLVM backened by default). My company's software can't be installed on Windows nor OS X because of this one and it's… well, quite problematic, as our customers require the Windows version (and most probably OS X too). The workaround – disabling LLVM – is not possible since we use it (vide accelerate).

In other words: solving this is crucial for our company.

Is it possible to fix it by 7.8.4?

comment:17 Changed 9 months ago by dterei

  • Cc dterei added
  • Owner dterei deleted

I'm not going to have time to look at this soon sorry but hopefully someone else will. It's a build system / config issue anyway so not specific to LLVM knowledge.

comment:18 Changed 9 months ago by k.gadek

For the record: I reinstalled LLVM on my system using brew with additional flags (notably --with-clang) and now it all appears to work.

Anyway, OS X by default is not able to build anything with -fllvm so despite the blame on Apple for doing this weird LLVM-mockery, I think this should be anticipated in some way; at least some note around download section, or – even better – give more meaningful error message.

comment:19 Changed 9 months ago by carter

@k.gadek for your use case, can't you do --ghc-options="-fasm" ?
Which accelerate package aside from accelerate-llvm (which is still prerelease quality last I checked) actually uses llvm? All the other (aside from the interpreted mode) do runtime compilation using the opencl/cuda ?

comment:20 Changed 8 months ago by Fanael

  • Owner set to Fanael

comment:21 Changed 8 months ago by Fanael

  • Differential Revisions set to Phab:D190

comment:22 Changed 8 months ago by Austin Seipp <austin@…>

In 918719b936b878ab660f20ceef8afc9e3a898c5a/ghc:

Set llc and opt commands on all platforms

Summary:
LLVM llc and opt commands should be set on all platforms, including
Windows. If they're not, GHC tries to execute an unnamed executable,
resulting in error messages such as:

    Error (figuring out LLVM version): : runInteractiveProcess: invalid argument (Invalid argument)
    <no location info>:
        Warning: Couldn't figure out LLVM version!
                 Make sure you have installed LLVM

This regression was introduced in e6bfc596.

Test Plan: Build GHC and test if --info shows sensible values of "LLVM llc command" and "LLVM opt command"

Reviewers: austin, #ghc

Reviewed By: austin, #ghc

Subscribers: austin

Projects: #ghc

Differential Revision: https://phabricator.haskell.org/D190

GHC Trac Issues: #7143

comment:23 Changed 8 months ago by Fanael

  • Status changed from new to merge

Should be fixed in HEAD.

comment:24 Changed 7 months ago by thoughtpolice

  • Milestone changed from 7.8.4 to 7.10.1

Moving (in bulk) to 7.10.4

comment:25 Changed 4 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.8.4
  • Resolution set to fixed
  • Status changed from merge to closed

Merged to 7.8.4.

Note: See TracTickets for help on using tickets.