Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#7004 closed bug (fixed)

Error compiling repa-algorithms with LLVM

Reported by: benl Owned by: dterei
Priority: normal Milestone:
Component: Compiler (LLVM) Version: 7.4.1
Keywords: Cc: robby@…
Operating System: MacOS X Architecture: x86_64 (amd64)
Type of failure: GHC rejects valid program Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

With LLVM 3.0 and 3.1:

$ cabal install repa-examples
Resolving dependencies...
Configuring repa-algorithms-3.2.1.1...
Building repa-algorithms-3.2.1.1...
Preprocessing library repa-algorithms-3.2.1.1...
[ 1 of 10] Compiling Data.Array.Repa.Algorithms.Randomish (
Data/Array/Repa/Algorithms/Randomish.hs,
dist/build/Data/Array/Repa/Algorithms/Randomish.o )

/var/folders/39/s54cw_0x0pg1shz3z8wd3z080000gn/T/cc-IVGvFg.s:18:2:
    error: instruction requires a CPU feature not currently enabled
    jmpl *%eax ## TAILCALL
    ^

With LLVM 2.8:

$ cabal install repa-examples
Resolving dependencies...
Configuring repa-algorithms-3.2.1.1...
Building repa-algorithms-3.2.1.1...
Preprocessing library repa-algorithms-3.2.1.1...
[ 1 of 10] Compiling Data.Array.Repa.Algorithms.Randomish (
Data/Array/Repa/Algorithms/Randomish.hs,
dist/build/Data/Array/Repa/Algorithms/Randomish.o )
LLVM ERROR: Cannot yet select: 0x1010b8310: f64 = sint_to_fp
0x10107ac10 [ORD=1990] [ID=54]
 0x10107ac10: i32,ch = load 0x101805d08, 0x1010b8210,
0x101073310<LD4[%ln4wu]> [ORD=1989] [ID=52]
   0x101805d08: ch = EntryToken [ORD=1978] [ID=0]
   0x1010b8210: i32 = add 0x1010bab10, 0x1010ba810 [ID=51]
     0x1010bab10: i32 = add 0x1010b9e10, 0x101076910 [ID=50]
...
$ xcodebuild -version
Xcode 4.1
Build version 4B110

$ opt --version
Low Level Virtual Machine (http://llvm.org/):
 llvm version 2.8
 Optimized build.
 Built Oct  7 2010 (00:21:19).
 Host: x86_64-apple-darwin11
 Host CPU: i686

 Registered Targets:
   (none)

Compiling a hello-world program works.

This report was from Robby Findler, I haven't managed to reproduce the problem yet though. Submitting the report incase anyone else recognises the problem.

Change History (9)

comment:1 follow-up: Changed 22 months ago by robby

FWIW, I am using mac os 10.7.3 on an 11" mac book air, which has an i7 (not an amd chip). Before the commands above, I just installed the platform, specifically:
Haskell Platform 2012.2.0.0 32bit.

comment:2 Changed 22 months ago by simonpj

  • Cc robby@… added
  • Difficulty set to Unknown

Maybe try a tiny foo.s file containing jumpl *%eax and see if the assembler complains?

comment:3 Changed 22 months ago by simonpj

Roman says: could this be a 32-bit GHC with a 64-bit GCC, or vice versa?

comment:4 in reply to: ↑ 1 Changed 22 months ago by chak

Replying to robby:

FWIW, I am using mac os 10.7.3 on an 11" mac book air, which has an i7 (not an amd chip). Before the commands above, I just installed the platform, specifically:
Haskell Platform 2012.2.0.0 32bit.

Roman just suggested that there is probably a mismatch between you using a 32bit Haskell Platform, but LLVM wanting to generate x86_64 code. Could you install the x86_64 version of the Haskell Platform and try again?

comment:5 Changed 22 months ago by dterei

Yes I thought this error looked familiar. I don't have time right now and probably for at least a week to look into this sadly but I'm pretty sure Roman is right.

I don't think I really support 32bit GHC on 10.7, so please use 64bit.

comment:6 Changed 22 months ago by robby

Thanks, everyone.

It appears that the 64bit Haskell Platform combined with llvm 3.0 works to be able to install repa-examples. I'm not seeing the cool programs that Manuel demo'd in China, but I do see something now.

Also, in case anyone's interested, llvm 2.8 still gives the error above, and I had trouble uninstalling the 32bit version of the Haskell Platform, but I found a thread on haskell-cafe that suggested a series of "sudo rm"s that seems to have done the trick.

comment:7 Changed 22 months ago by chak

  • Resolution set to fixed
  • Status changed from new to closed

Robby, some of the examples that I had are in repa-examples and some of them are in gloss-examples (install it with cabal install gloss-examples). Gloss is the OpenGL library that is used for visualisation in all, but the Canny edge detection.

(It is a bit confusing that these Repa examples are bundled with Gloss, but as gloss depends on Repa and these examples need both, there is really no other way to structure this. Except maybe to have a third repa-gloss-examples package.)

As I opened a separate ticket concerning a better error message in the situation that you encountered, I will close this ticket.

comment:8 Changed 22 months ago by robby

Thanks!

comment:9 Changed 22 months ago by dterei

OK so I thought this error looked familiar. This is an old error that I already fixed:

https://github.com/ghc/ghc/commit/5e383469

It is in GHC 7.4.2, current haskell platform is 7.4.1 based so it suffers the error. It only arises on a 32bit platform as well. Basically I wasn't passing though the march option to the assember (as the llvm backend now uses clang as the assembler so has a different code path than NCG).

A work around is to use this flag with ghc:

$ ghc -opta-m32

And using the 32bit HP will work fine.

Note: See TracTickets for help on using tickets.