DeadCodeProductions / dead

Other
50 stars 5 forks source link

Local configuration (failed to run the init.py) #73

Closed Ghy0202 closed 1 year ago

Ghy0202 commented 1 year ago

Hi~~ When I try to build this project locally, I encountered usr/bin/ld can not find -lLLVM . And I tried to solve this problem By solving the symbolic link

(deadenv) root@today-virtual-machine:/dce/dead/callchain_checker/build# locate libLLVM
... ...
/usr/lib/x86_64-linux-gnu/libLLVM-11.so
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1
/usr/lib/x86_64-linux-gnu/libLLVM-13.so
/usr/lib/x86_64-linux-gnu/libLLVM-13.so.1
/usr/lib/x86_64-linux-gnu/libLLVM-15.so
/usr/lib/x86_64-linux-gnu/libLLVM-15.so.1
(deadenv) root@today-virtual-machine:/dce/dead/callchain_checker/build# ln -s /usr/lib/x86_64-linux-gnu/libLLVM-11.so.1 /usr/lib/x86_64-linux-gnu/libLLVM.so
(deadenv) root@today-virtual-machine:/dce/dead/callchain_checker/build# file /usr/lib/x86_64-linux-gnu/libLLVM.so
/usr/lib/x86_64-linux-gnu/libLLVM.so: symbolic link to /usr/lib/x86_64-linux-gnu/libLLVM-11.so.1

after that ,./init.py is still failed like below:

(deadenv) root@today-virtual-machine:/dce/dead/callchain_checker/build# make -j
[ 50%] Built target ccc-lib
[ 75%] Linking CXX executable ../bin/ccc
/usr/bin/ld: CMakeFiles/ccc.dir/CallChainCheckerTool.cpp.o:(.data.rel.ro._ZTIZN5clang7tooling24newFrontendActionFactoryINS_12ast_matchers11MatchFinderEEESt10unique_ptrINS0_21FrontendActionFactoryESt14default_deleteIS5_EEPT_PNS0_19SourceFileCallbacksEE28FrontendActionFactoryAdapter[_ZTIZN5clang7tooling24newFrontendActionFactoryINS_12ast_matchers11MatchFinderEEESt10unique_ptrINS0_21FrontendActionFactoryESt14default_deleteIS5_EEPT_PNS0_19SourceFileCallbacksEE28FrontendActionFactoryAdapter]+0x10): undefined reference to `typeinfo for clang::tooling::FrontendActionFactory'
/usr/bin/ld: CMakeFiles/ccc.dir/CallChainCheckerTool.cpp.o:(.data.rel.ro._ZTIZN5clang7tooling24newFrontendActionFactoryINS_12ast_matchers11MatchFinderEEESt10unique_ptrINS0_21FrontendActionFactoryESt14default_deleteIS5_EEPT_PNS0_19SourceFileCallbacksEEN28FrontendActionFactoryAdapter22ConsumerFactoryAdaptorE[_ZTIZN5clang7tooling24newFrontendActionFactoryINS_12ast_matchers11MatchFinderEEESt10unique_ptrINS0_21FrontendActionFactoryESt14default_deleteIS5_EEPT_PNS0_19SourceFileCallbacksEEN28FrontendActionFactoryAdapter22ConsumerFactoryAdaptorE]+0x10): undefined reference to `typeinfo for clang::ASTFrontendAction'
/usr/bin/ld: libccc-lib.a(CallChainChecker.cpp.o):(.data.rel.ro._ZTIN3ccc18CallChainCollectorE[_ZTIN3ccc18CallChainCollectorE]+0x10): undefined reference to `typeinfo for clang::ast_matchers::MatchFinder::MatchCallback'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/ccc.dir/build.make:99:bin/ccc] error 1
make[1]: *** [CMakeFiles/Makefile2:234:src/CMakeFiles/ccc.dir/all] error 2
make: *** [Makefile:91:all] error 2

I suspect there is a problem with the configuration of installing LLVM. If so, can you disclose the relevant commands for installing LLVM? when installing LLVM,I used the following command(Ubuntu22.04,llvm-as 14.0.6):

cmake -G Ninja -DCMAKE_BUILD_TYPE="Release" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;compiler-rt" -DLLVM_BUILD_LLVM_DYLIB=ON   -DCMAKE_INSTALL_PREFIX="/usr" ../llvm

Is there a problem with the configuration of my installation of LLVM or some other reasons that I have not noticed caused this bug?

thetheodor commented 1 year ago

undefined reference to 'typeinfo for clang::tooling::FrontendActionFactory' your LLVM is build without RTTI and callchain_checker needs it.

I haven't checked but maybe callchain_checker works without RTTI/Exceptions. You can try adding -fno-rtti -fno-exceptions in https://github.com/DeadCodeProductions/dead/blob/main/callchain_checker/CMakeLists.txt#L20

Alternatively you can enable RTTI/Exceptions when building LLVM with -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_EN=ON.

(We are currently in the process of refactoring/rewriting large parts of dead so hopefully such issues will go away)

Ghy0202 commented 1 year ago

Thank you very much for your reply. I will try these parameters.😁

At 2023-03-15 18:24:40, "Theodoros Theodoridis" @.***> wrote:

undefined reference to 'typeinfo for clang::tooling::FrontendActionFactory' your LLVM is build without RTTI and callchain_checker needs it.

I haven't checked but maybe callchain_checker works without RTTI/Exceptions. You can try adding -fno-rtti -fno-exceptions in https://github.com/DeadCodeProductions/dead/blob/main/callchain_checker/CMakeLists.txt#L20

Alternatively you can enable RTTI/Exceptions when building LLVM with -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_EN=ON.

(We are currently in the process of refactoring/rewriting large parts of dead so hopefully such issues will go away)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Ghy0202 commented 1 year ago

Succeed! rebuild LLVM by cmd like :

cmake -G Ninja -DCMAKE_BUILD_TYPE="Release" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;compiler-rt" -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_ENABLE_RTTI=ON  -DLLVM_ENABLE_EN=ON  -DCMAKE_INSTALL_PREFIX="/usr" ../llvm

thank you!😊💕