LLVM9 been released a while ago. Arch Linux team is looking what need to be done to bring the latest version of LLVM.
I am checking how crystal works with LLVM9. The project compiles fine with LLVM9. It seems LLVM9 does not have any breaking API changes.
$ crystal --version
Crystal 0.31.1 (2019-10-04)
LLVM: 9.0.0
Default target: x86_64-pc-linux-gnu
But when I try to compile a simple crystal app like this:
def main
channel = Channel(Int32).new(9)
(1..10).each do |i|
spawn do
channel.send(i)
end
end
result = [] of Int32
9.times do
result << channel.receive
end
puts result
end
main
compilation fails:
$ crystal main.cr
Missing hash key for value: 11 (KeyError)
Unhandled exception: Error opening file 'crystal' with mode 'r': No such file or directory (Errno)
Failed to raise an exception: END_OF_STACK
[0x56139e0bd3c6] ???
[0x56139d744e4b] __crystal_raise +43
[0x56139d746645] ???
[0x56139d75246b] ???
[0x56139d74b75c] ???
[0x56139d74adf4] ???
[0x56139daa8133] ???
[0x56139d75dd07] ???
[0x56139d7489c7] main +55
[0x7f8e21c1d153] __libc_start_main +243
[0x56139d74355e] _start +46
[0x0] ???
What does this Missing hash key for value: 11 mean?
Can you suggest an easy way to reproduce this problem on Arch Linux?
It's reproducible on mac if you build Crystal with llvm9. I included an example program and stack trace.
# app.cr
puts "hello world"
./bin/crystal app.cr
Using compiled compiler at `.build/crystal'
Missing hash key for value: 11 (KeyError)
from src/hash.cr:1081:22 in 'key_for'
from src/llvm/enums.cr:2:3 in 'from_kind'
from src/llvm/function.cr:43:5 in 'attributes'
from src/compiler/crystal/codegen/fun.cr:44:7 in 'declare_fun'
...
Edited by @asterite : reduced the callstack, with the above we can know the problem seems to be in a difference of function attributes definition between LLVM 8 and 9.
@oprypin To reproduce the problem at Arch Linux please enable testing repositories. To achieve it please edit file /etc/pacman.conf and uncomment
[testing]
Include = /etc/pacman.d/mirrorlist
[community-testing]
Include = /etc/pacman.d/mirrorlist
[multilib-testing]
Include = /etc/pacman.d/mirrorlist
repositories and then update the system with pacman -Suy.
Arch testing repositories already contain LLVM9 and crystal package rebuilt on top of LLVM9.
@asterite
the problem seems to be in a difference of function attributes definition
Do you have a patch that we can use for testing with LLVM9 and see if it fixes our issue.
No, sorry. I was just hinting at the problem so maybe someone else can fix it (I don't have much time there days).
Hi folks, do you have any bugfix that we can test with llvm9? I would like to push the fix to Arch Linux repo and help to identify any possible problems with llvm9.
Hi @anatol, no. There is no support for llvm9 I am aware of.