numba / llvmlite

A lightweight LLVM python binding for writing JIT compilers
https://llvmlite.pydata.org/
BSD 2-Clause "Simplified" License
1.88k stars 316 forks source link

llvmlite 0.16.0 crashes when creating target machine (Ubuntu 14.04, Python 3.5.1) #247

Open scizzorz opened 7 years ago

scizzorz commented 7 years ago

I'm unable to execute the following code on CircleCI's test runners with llvmlite 0.16.0.

import llvmlite.binding as llvm

llvm.initialize()
llvm.initialize_native_target()
llvm.initialize_native_asmprinter()

target = llvm.Target.from_default_triple()
target_machine = target.create_target_machine()
# crashes here and never prints
print('done')

I installed llvm-3.9 like this:

sudo echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" >> /etc/apt/sources.list
sudo echo "deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" >> /etc/apt/sources.list
wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install llvm-3.9 clang-3.9
sudo rm /usr/bin/llvm-config
sudo ln -s /usr/bin/llvm-config-3.9 /usr/bin/llvm-config
sklam commented 7 years ago

can you check the output of llvm-config --version --prefix --components --targets-built --host-target?

scizzorz commented 7 years ago
3.9.1
/usr/lib/llvm-3.9
aarch64 aarch64asmparser aarch64asmprinter aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils all all-targets amdgpu amdgpuasmparser amdgpuasmprinter amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgpuutils analysis arm armasmparser armasmprinter armcodegen armdesc armdisassembler arminfo asmparser asmprinter bitreader bitwriter bpf bpfasmprinter bpfcodegen bpfdesc bpfinfo codegen core coverage debuginfocodeview debuginfodwarf debuginfopdb engine executionengine globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interpreter ipo irreader libdriver lineeditor linker lto mc mcdisassembler mcjit mcparser mips mipsasmparser mipsasmprinter mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmprinter msp430codegen msp430desc msp430info native nativecodegen nvptx nvptxasmprinter nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit passes powerpc powerpcasmparser powerpcasmprinter powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata runtimedyld scalaropts selectiondag sparc sparcasmparser sparcasmprinter sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzasmprinter systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target transformutils vectorize x86 x86asmparser x86asmprinter x86codegen x86desc x86disassembler x86info x86utils xcore xcoreasmprinter xcorecodegen xcoredesc xcoredisassembler xcoreinfo
AArch64 AMDGPU ARM BPF Hexagon Mips MSP430 NVPTX PowerPC Sparc SystemZ X86 XCore
x86_64-unknown-linux-gnu
sklam commented 7 years ago

Check the value of llvm.get_process_triple() and llvm.get_default_triple(). If they are too different, you may need to do llvm.Target.from_triple(llvm.get_process_triple()) and/or llvm.initialize_all_targets()

scizzorz commented 7 years ago

llvm.get_process_triple() and llvm.get_default_triple() are both 'x86_x64-unknown-linux-gnu', so I don't think that's the problem.

scizzorz commented 7 years ago

Everything still works correctly with llvmlite 0.15 and LLVM 3.8.

sklam commented 7 years ago

Is this happening only on CircleCI test env? Were you able to replicate this on other setup?

And, just to be sure, what is which llvm-config just before you build llvmlite

scizzorz commented 7 years ago

I tried it on an Arch Linux machine where it worked perfectly with 0.16 / 3.9. I haven't been able to try it on a different Ubuntu machine yet - I'll have access to one in a few hours to check it out.

sklam commented 7 years ago

Can you use miniconda to get prebuilt llvmlite? Or, perhaps the wheel package. I am testing a 0.16.0 wheel. See https://github.com/numba/llvmlite/pull/222#issuecomment-279548150

scizzorz commented 7 years ago

It works on a brand new Ubuntu 16.04 installation after installing LLVM-3.9 in the same way as on the CircleCI test runner. I'll poke around with the test runner later and give that wheel / miniconda a shot.

scizzorz commented 7 years ago

This actually seems to be the same bug as #93, which has been closed for quite some time.