Tips for debugging a segfault?

Hi folks,

I have a big LLVM-IR (generated from clang -S -emit-llvm), and I am interested in loading it into llvmlite as a means of evaluating what llvmlite can do.

In the process of trying this, I encountered a segfault. What options do I have for debugging the cause of that segfault? Is there a debug mode of llvmlite that effectively runs the llvm passes in debug mode?

Note, after hitting issues with opaque pointers, I re-compiled the my code with clang-14, so I don’t think there should be any versioning issues.

You can do a debug build of LLVM locally and then build / link llvmlite against that. Using LLVM 15 or 16 should be OK with main. You can use 19 with this branch, but I don’t know off the top of my head whether it also works with Numba.

To use your LLVM build, you need to provide the path to its llvm-config to setup.py, e.g.:

LLVM_CONFIG=<path to llvm-config>/llvm-config python setup.py develop

If you want to use opaque pointers, you can set the environment variable LLVMLITE_ENABLE_OPAQUE_POINTERS=1.

1 Like

I am trying to build it and I get to the point where I import llvm.binding and I see some errors about loading libllvmlite.so, and it appears to boil down to.

OSError: /home/j2kun/fhe/llvmlite/llvmlite/binding/libllvmlite.so: undefined symbol: __cxa_pure_virtual

I’m not sure what this is referring to. Do I need to add specific compilation flags (maybe -fPIC?) when building LLVM?

I think there’s something wrong with the way you built LLVM or your toolchain setup, but it’s difficult to diagnose from the error alone. Can you let me know:

  • The output of numba -s (this collects a lot of info about the platform that will save me asking)
  • The tag / commit of LLVM you’re building
  • How you built it (i.e. what CMake args, etc.)

Many thanks!