jmmartinez / easy-just-in-time

LLVM Optimization to extract a function, embedded in its intermediate representation in the binary, and execute it using the LLVM Just-In-Time compiler.
BSD 3-Clause "New" or "Revised" License
509 stars 32 forks source link

Jump to LLVM 7.0 #42

Open jmmartinez opened 5 years ago

castigli commented 2 years ago

Hi @jmmartinez,

I think this is a cool project and I would be interested in trying it out.

As a first step I was trying to compile it with a recent LLVM. The bump to LLVM 7.0 is trivial and worked easily.

However, when I try more recent versions (8.0 and higher) I get a segfault on the front end. Any chance you could point me in the right direction to solve this issue?

Stack dump:
0.  Program arguments: /usr/lib/llvm-8/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib/llvm-8/lib/clang/8.0.0 -I /home/gcastigl/Codes/easy-just-in-time/include -I/home/gcastigl/intel/compilers_and_libraries_2020.1.217/linux/mkl/include -I/home/gcastigl/intel/tbb/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/include/clang/8.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include --std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/gcastigl/Codes/test-easyjit -ferror-limit 19 -fmessage-length 192 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -load /home/gcastigl/Codes/easy-just-in-time/build-8/bin/EasyJitPass.so -o /tmp/test-61748b.o -x c++ test.cpp -faddrsig 
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 8.0.0-3~ubuntu18.04.2 (tags/RELEASE_800/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: note: diagnostic msg: Error generating preprocessed source(s).
jmmartinez commented 2 years ago

Hello @castigli ,

Thanks for showing interest in the project.

One way to proceed is to compile your own LLVM+Clang with assertions and debug info, instead of using the package that is distributed with your system. This should provide us a more accurate stacktrace when the fail happens. From there, it should be easier to find the root cause of the problem.

To do this, you have to clone llvm's repository, and build with the options CMAKE_RELEASE_TYPE=Debug LLVM_ENABLE_ASSERTIONS=ON .

Best,

castigli commented 2 years ago

Hi @jmmartinez, That is what I was thinking, thanks for the pointer, I'll report back if I succeed! Cheers,

cnergyone commented 2 years ago

Any progress on getting the library working on more recent LLVM versions? On LLVM-12-dev I get the message: Unknown CMake command "add_llvm_loadable_module".

Would be great to get the library working on a modern clang so we can use constexpr and other nice features of C++20 together with JITing.

castigli commented 2 years ago

Hi @cnergyone, unfortunately not much progress on my side as I am focusing on other projects. Regarding your error, that's a deprecated function, you should replace it with add_llvm_library(yourLib MODULE ...)

kathlenehurt-sifive commented 1 year ago

I've made some progress on moving to LLVM 14.0.6 (see https://github.com/jmmartinez/easy-just-in-time/issues/51). @cnergyone would love to collaborate on getting this library updated!