Attempted to add LLVM 3.4 compatibility. #856

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
4 participants

This is my admittedly probably awful attempt at adding compatibility to
Idris for LLVM v3.4.*.

There is a change to the cabal file to cater for either 3.3.8.* or
3.4.*.

There is also a change to the output function for writing the LLVM code
that needed a LLVM.General.Module.File type and not FilePath or String.

I have not been able to test this properly on LLVM 3.3 yet.

Not expecting this to be accepted as is, it feels hacky could be useful
starting point if someone feels so inclined. Will correct, improve, or adjust
as needed if people want to continue.

@mankyKitty mankyKitty Attempted to add LLVM 3.4 compatibility.
This is my admittedly probably awful attempt at adding compatibility to
Idris for LLVM v3.4.*.

There is a change to the cabal file to cater for either 3.3.8.* or
3.4.*.

There is also a change to the output function for writing the LLVM code
that needed a LLVM.General.Module.File type and not FilePath or String.

Not expecting this to be accepted but it might give someone who knows
what they are doing an idea...
d426442
Contributor

edwinb commented Feb 6, 2014

There seems to be a build failure on travis here - I've set it going again in case it was temporary. But are all the llvm versions in hackage up to date?

They were last time I checked, I’m working through a “Write your own LLVM JIT in Haskell” and I’m using the llvm-general and llvm-general-pure 3.4.* as dependencies in my cabal file.

I acquired them via cabal from hackage, I’ve not investigated further though. :(

On 6 Feb 2014, at 4:09 pm, Edwin Brady notifications@github.com wrote:

There seems to be a build failure on travis here - I've set it going again in case it was temporary. But are all the llvm versions in hackage up to date?


Reply to this email directly or view it on GitHub.

Oh bugger I think I know what it is... sigh... don't forget your coffee/tea if you're going to submit PRs... The version values I've used in the cabal file try to allow you to use 3.3.8.* or 3.4.* ...I wasn't able to test 3.3.8.*... just checked the hackage docs but the older versions aren't listed there.. I'll pull one down and have a look.

Sorry mate.

Okay, I'm a genius and pushed a non-backwards compatible change.

Those functions in 3.3.8.0 are

writeAssemblyToFile :: TargetMachine -> FilePath -> Module -> ErrorT String IO ()
writeObjectToFile :: TargetMachine -> FilePath -> Module -> ErrorT String IO ()

But in 3.4.0 are

writeAssemblyToFile :: TargetMachine -> File -> Module -> ErrorT String IO ()
writeObjectToFile :: TargetMachine -> File -> Module -> ErrorT String IO ()

I'll have another go when I have a chance, sorry for the run around.

Contributor

edwinb commented Feb 6, 2014

Righto, no worries, I'll just leave this until travis says it's okay. These API changes seem to have a history of happening with llvm-general…

I am generally happy to defer to others' wisdom with LLVM - being optional, it's not a disaster if it doesn't install everywhere, although obviously we'd like to be as compatible as possible overall.

On 6 Feb 2014, at 15:26, Sean Chalmers notifications@github.com wrote:

Okay, I'm a genius and pushed a non-backwards compatible change.

Those functions in 3.3.8.0 are

writeAssemblyToFile :: TargetMachine -> FilePath -> Module -> ErrorT String IO ()
writeObjectToFile :: TargetMachine -> FilePath -> Module -> ErrorT String IO ()

But in 3.4.0 are

writeAssemblyToFile :: TargetMachine -> File -> Module -> ErrorT String IO ()
writeObjectToFile :: TargetMachine -> File -> Module -> ErrorT String IO ()

I'll have another go when I have a chance, sorry for the run around.


Reply to this email directly or view it on GitHub.

mankyKitty added some commits Feb 10, 2014

@mankyKitty mankyKitty Update llvm-general and llvm-general-pure deps.
I originally was trying to be 'clever' and ensure Idris could handle
both llvm 3.3.8.* and 3.4.*. This wasn't really working so I've opted
for simply 3.4.* dependencies to match the latest version of the LLVM
packages on Hackage.

There are some non-backwards compatible changes for this and I've tried
to fix some of the obvious ones but I might have missed some more subtle ones.
7cf2a99
@mankyKitty mankyKitty Update .travis config for correct LLVM Version
The travis build was failing because the incorrect LLVM version was
being installed. This changes it up for version 3.4.
b1b19b4
Contributor

LeifW commented Feb 18, 2014

This enables Idris to build against llvm 3.4 for me, but then I get errors trying to use the llvm backend (where ordinarily the llvm backend would work fine).
Where Main.idr is a hello world:

idris -o foo --codegen llvm Main.idr                                                                                                             /tmp/foo 1:02AM
*** Error in `idris': free(): invalid size: 0x00007f8c5e004940 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x731ff)[0x7f8c5e26a1ff]
/usr/lib/libc.so.6(+0x789ae)[0x7f8c5e26f9ae]
/usr/lib/libc.so.6(+0x796b6)[0x7f8c5e2706b6]
idris[0xdbf3b5]
======= Memory map: ========
00400000-0218a000 r-xp 00000000 00:10 2404442                            /usr/bin/idris
0238a000-0250c000 r-xp 01d8a000 00:10 2404442                            /usr/bin/idris
0250c000-0260b000 rwxp 01f0c000 00:10 2404442                            /usr/bin/idris
0260b000-02625000 rwxp 00000000 00:00 0 
03c9c000-03cbd000 rwxp 00000000 00:00 0                                  [heap]
03cbd000-03cdf000 rwxp 00000000 00:00 0                                  [heap]
03cdf000-03ce8000 rwxp 00000000 00:00 0                                  [heap]
03ce8000-03d09000 rwxp 00000000 00:00 0                                  [heap]
03d09000-03d2a000 rwxp 00000000 00:00 0                                  [heap]
03d2a000-03d4b000 rwxp 00000000 00:00 0                                  [heap]
03d4b000-03d5b000 rwxp 00000000 00:00 0                                  [heap]
7f8c4f500000-7f8c4f600000 rwxp 00000000 00:00 0 
... on and on ...
zsh: abort (core dumped)  idris -o foo --codegen llvm Main.idr

x64 Arch Linux, llvm 3.4, llvm-general 3.4.1.0

Thanks for that! (moar crash data)

I have it giving me plenty of information thanks to the travis server as well, which matches what you’re experiencing. I’m super busy and sort of between continents at the moment so i won’t have too much time to dedicate to this at the moment. But I will be back onto it when I can!

I’m pretty awful with Idris at the moment, being a dependent type newbie so I thought this might be a nice way to contribute. Hopefully it’s not too big for me! :D

Sean

On 18 Feb 2014, at 7:07 pm, Leif Warner notifications@github.com wrote:

This enables Idris to build against llvm 3.4 for me, but then I get errors trying to use the llvm backend (where ordinarily the llvm backend would work fine).
Where Main.idr is a hello world:

idris -o foo --codegen llvm Main.idr /tmp/foo 1:02AM
*** Error in `idris': free(): invalid size: 0x00007f8c5e004940 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x731ff)[0x7f8c5e26a1ff]
/usr/lib/libc.so.6(+0x789ae)[0x7f8c5e26f9ae]
/usr/lib/libc.so.6(+0x796b6)[0x7f8c5e2706b6]
idris[0xdbf3b5]
======= Memory map: ========
00400000-0218a000 r-xp 00000000 00:10 2404442 /usr/bin/idris
0238a000-0250c000 r-xp 01d8a000 00:10 2404442 /usr/bin/idris
0250c000-0260b000 rwxp 01f0c000 00:10 2404442 /usr/bin/idris
0260b000-02625000 rwxp 00000000 00:00 0
03c9c000-03cbd000 rwxp 00000000 00:00 0 [heap]
03cbd000-03cdf000 rwxp 00000000 00:00 0 [heap]
03cdf000-03ce8000 rwxp 00000000 00:00 0 [heap]
03ce8000-03d09000 rwxp 00000000 00:00 0 [heap]
03d09000-03d2a000 rwxp 00000000 00:00 0 [heap]
03d2a000-03d4b000 rwxp 00000000 00:00 0 [heap]
03d4b000-03d5b000 rwxp 00000000 00:00 0 [heap]
7f8c4f500000-7f8c4f600000 rwxp 00000000 00:00 0
... on and on ...
zsh: abort (core dumped) idris -o foo --codegen llvm Main.idr
x64 Arch Linux, llvm 3.4, llvm-general 3.4.1.0


Reply to this email directly or view it on GitHub.

Unfortunately I do not have the time to commit to this right now. I can leave this issue open if people would like to use where I've started, not that it's really a starting point. But please close it to make way for a more meaningful contribution if need be. :)

Sorry everyone. :(

Contributor

david-christiansen commented Sep 24, 2014

The LLVM backend has been factored out into a different repository. My understanding is that they are updating the version there, so I'll close this.

Thanks for starting it, @mankyKitty!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment