mchalupa / dg

[LLVM Static Slicer] Various program analyses, construction of dependence graphs and program slicing of LLVM bitcode.
MIT License
474 stars 131 forks source link

install error #431

Closed freexxxyyy closed 2 years ago

freexxxyyy commented 2 years ago

Hi, When I use "cmake .", it gives me such errors: /usr/bin/ld: cannot find libs/build/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan_static-x86_64.a: No such file or directory /usr/bin/ld: cannot find libs/build/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a: No such file or directory But I remember that these two .a files are discarded by clang? How should I fix it? Thanks

mchalupa commented 2 years ago

Hi, What is the output of cmake configuration? Try to use -DUSE_SANITIZERS=off.

(Or re-build LLVM with sanitizers)

freexxxyyy commented 2 years ago

Hi,

Thanks for your reply! I re-build LLVM with sanitizers and now the cmake is successfuly. But when I "make -j$(nproc), it gives me such errors: /usr/bin/ld: cannot find -lLLVM

collect2: error: ld returned 1 exit status
make[2]: *** [tools/CMakeFiles/llvm-to-source.dir/build.make:84: tools/llvm-to-source] Error 1
make[1]: *** [CMakeFiles/Makefile2:1544: tools/CMakeFiles/llvm-to-source.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 21%] Linking CXX shared library libdgpta.so
[ 21%] Built target dgpta
/home/user/libs/dg/lib/llvm/ValueRelations/StructureAnalyzer.cpp: In member function ‘void dg::vr::StructureAnalyzer::initializeCallRelations()’:
/home/user/libs/dg/lib/llvm/ValueRelations/StructureAnalyzer.cpp:692:39: error: ‘const class llvm::CallInst’ has no member named ‘getNumArgOperands’; did you mean ‘getNumOperands’?
  692 |                 if (argCount >= call->getNumArgOperands())
      |                                       ^~~~~~~~~~~~~~~~~
      |                                       getNumOperands
make[2]: *** [lib/CMakeFiles/dgllvmvra.dir/build.make:102: lib/CMakeFiles/dgllvmvra.dir/llvm/ValueRelations/StructureAnalyzer.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 23%] Linking CXX shared library libdgdda.so
[ 23%] Built target dgdda
make[1]: *** [CMakeFiles/Makefile2:1332: lib/CMakeFiles/dgllvmvra.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Should I change the "getNumArgOperands" to "getNumOperands"? Or it is due to other errors?

mchalupa commented 2 years ago

This is probably that DG has not been ported to LLVM 14 yet. I'll do a proper port when I have a bit of time, but for now there should be an easy fix: replace getNumArgOperands() with arg_size().

freexxxyyy commented 2 years ago

Hi,

After the replacing, there is another error

[  4%] Built target dgvra
[  4%] Built target dganalysis
[  7%] Built target dgcda
[  8%] Linking CXX executable llvm-to-source
[ 14%] Built target dgpta
[ 14%] Linking CXX shared library libdgllvmvra.so
[ 18%] Built target dgdda
/usr/bin/ld: cannot find -lLLVM
collect2: error: ld returned 1 exit status
make[2]: *** [tools/CMakeFiles/llvm-to-source.dir/build.make:84: tools/llvm-to-source] Error 1
make[1]: *** [CMakeFiles/Makefile2:1544: tools/CMakeFiles/llvm-to-source.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 19%] Built target dgsdg
[ 20%] Linking CXX shared library libdgllvmpta.so
/usr/bin/ld: cannot find -lLLVM
collect2: error: ld returned 1 exit status
make[2]: *** [lib/CMakeFiles/dgllvmvra.dir/build.make:146: lib/libdgllvmvra.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:1332: lib/CMakeFiles/dgllvmvra.dir/all] Error 2
/usr/bin/ld: cannot find -lLLVM
collect2: error: ld returned 1 exit status
make[2]: *** [lib/CMakeFiles/dgllvmpta.dir/build.make:236: lib/libdgllvmpta.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:1455: lib/CMakeFiles/dgllvmpta.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Is it still related to the LLVM14 issue? Should I compile it using the older LLVM, such llvm-13?

mchalupa commented 2 years ago

Nope, it doesn't seem LLVM-14 related. It looks that you compiled LLVM as a static library only? Try specifying -DLLVM_LINK_DYLIB=off when running cmake for DG (what is the output of cmake?) (or re-compile LLVM as a shared library too)

freexxxyyy commented 2 years ago

Here are the output of cmake

cmake . -DLLVM_LINK_DYLIB=off
-- The CXX compiler identification is GNU 9.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Build type not set. Setting default.
-- Build type: RelWithDebInfo
-- Performing Test Terminfo_LINKABLE
-- Performing Test Terminfo_LINKABLE - Success
-- Found Terminfo: /usr/lib/x86_64-linux-gnu/libtinfo.so  
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.10") 
-- Found LLVM 14.0.0
-- Using LLVMConfig.cmake in: /home/user/libs/build/llvm-14-san/lib/cmake/llvm
-- LLVM binaries: /home/user/libs/build/llvm-14-san/bin
-- Linker detection: GNU ld
-- LLVM include dir: /home/user/libs/build/llvm-14-san/include
-- LLVM libraries dir: /home/user/libs/build/llvm-14-san/lib
-- LLVM definitions: -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- Looking for headers in: /home/user/libs/build/llvm-14-san/include
-- Looking for libraries in: /home/user/libs/build/llvm-14-san/lib
-- LLVM linking: static
-- Using compiler: /usr/bin/c++
-- Performing Test HAS_FUZZER
-- Performing Test HAS_FUZZER - Failed
-- Will NOT build fuzzing tests (requires Clang 6 or newer)
-- Using compilation flags: -O2 -g -DNDEBUG
-- Additional compilation flags:  -std=c++14 -fno-rtti -Wall -Wextra -fno-exceptions
-- CMAKE_INSTALL_LIBDIR: "lib"
-- CMAKE_INSTALL_INCLUDEDIR: "include"
-- Found Git: /usr/bin/git (found version "2.25.1") 
-- clang: /home/user/libs/build/llvm-14-san/bin/clang
-- llvm-link: /home/user/libs/build/llvm-14-san/bin/llvm-link
-- lli: /home/user/libs/build/llvm-14-san/bin/lli
-- opt: /home/user/libs/build/llvm-14-san/bin/opt
-- Performing test sanitizers_work with /home/user/libs/build/llvm-14-san/bin/clang
-- Performing test sanitizers_work with /home/user/libs/build/llvm-14-san/bin/clang - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/libs/dg

Here are the errors for make

[  2%] Built target dganalysis
[  4%] Built target dgvra
[  7%] Built target dgcda
[  8%] Built target llvm-to-source
[ 14%] Built target dgpta
[ 18%] Built target dgdda
[ 23%] Built target dgllvmvra
[ 24%] Built target dgsdg
[ 25%] Built target llvm-vr-dump
[ 35%] Built target dgllvmpta
[ 37%] Built target dgllvmforkjoin
[ 54%] Built target dgllvmthreadregions
[ 59%] Built target dgllvmdda
[ 65%] Built target dgllvmcda
[ 68%] Built target llvm-thread-regions-dump
[ 70%] Built target dgllvmsdg
[ 71%] Built target llvm-ntscd-dump
[ 76%] Built target dgllvmdg
[ 80%] Built target dgllvmslicer
Scanning dependencies of target llvm-pta-ben
[ 81%] Building CXX object tools/CMakeFiles/llvm-pta-dump.dir/llvm-slicer-metadata.cpp.o
[ 82%] Building CXX object tools/CMakeFiles/llvm-cda-dump.dir/llvm-slicer-metadata.cpp.o
[ 84%] Built target llvm-cg-dump
[ 85%] Built target llvm-cda-bench
[ 86%] Built target llvm-dg-dump
[ 89%] Built target llvm-cda-stress
[ 91%] Built target llvm-pta-compare
[ 91%] Building CXX object tools/CMakeFiles/llvm-dda-dump.dir/llvm-slicer-metadata.cpp.o
[ 92%] Built target llvm-slicer
[ 93%] Built target llvm-sdg-dump
[ 95%] Building CXX object tools/CMakeFiles/llvm-pta-ben.dir/llvm-pta-ben.cpp.o
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:9:20: error: ‘map’ in namespace ‘std’ does not name a template type
    9 | using MapTy = std::map<const llvm::Value *, CVariableDecl>;
      |                    ^~~
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:8:1: note: ‘std::map’ is defined in header ‘<map>’; did you forget to ‘#include <map>’?
    7 | #include "dg/tools/llvm-slicer-utils.h"
  +++ |+#include <map>
    8 | 
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:12:1: error: ‘MapTy’ does not name a type
   12 | MapTy allocasToVars(const llvm::Function &F) {
      | ^~~~~
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:40:1: error: ‘MapTy’ does not name a type
   40 | MapTy allocasToVars(const llvm::Module &M) {
      | ^~~~~
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:9:20: error: ‘map’ in namespace ‘std’ does not name a template type
    9 | using MapTy = std::map<const llvm::Value *, CVariableDecl>;
      |                    ^~~
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:8:1: note: ‘std::map’ is defined in header ‘<map>’; did you forget to ‘#include <map>’?
    7 | #include "dg/tools/llvm-slicer-utils.h"
  +++ |+#include <map>
    8 | 
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:12:1: error: ‘MapTy’ does not name a type
   12 | MapTy allocasToVars(const llvm::Function &F) {
      | ^~~~~
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:40:1: error: ‘MapTy’ does not name a type
   40 | MapTy allocasToVars(const llvm::Module &M) {
      | ^~~~~
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:9:20: error: ‘map’ in namespace ‘std’ does not name a template type
    9 | using MapTy = std::map<const llvm::Value *, CVariableDecl>;
      |                    ^~~
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:8:1: note: ‘std::map’ is defined in header ‘<map>’; did you forget to ‘#include <map>’?
    7 | #include "dg/tools/llvm-slicer-utils.h"
  +++ |+#include <map>
    8 | 
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:12:1: error: ‘MapTy’ does not name a type
   12 | MapTy allocasToVars(const llvm::Function &F) {
      | ^~~~~
/home/user/libs/dg/tools/llvm-slicer-metadata.cpp:40:1: error: ‘MapTy’ does not name a type
   40 | MapTy allocasToVars(const llvm::Module &M) {
      | ^~~~~
make[2]: *** [tools/CMakeFiles/llvm-pta-dump.dir/build.make:76: tools/CMakeFiles/llvm-pta-dump.dir/llvm-slicer-metadata.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1722: tools/CMakeFiles/llvm-pta-dump.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** [tools/CMakeFiles/llvm-cda-dump.dir/build.make:76: tools/CMakeFiles/llvm-cda-dump.dir/llvm-slicer-metadata.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1860: tools/CMakeFiles/llvm-cda-dump.dir/all] Error 2
make[2]: *** [tools/CMakeFiles/llvm-dda-dump.dir/build.make:76: tools/CMakeFiles/llvm-dda-dump.dir/llvm-slicer-metadata.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2047: tools/CMakeFiles/llvm-dda-dump.dir/all] Error 2
[ 95%] Linking CXX executable llvm-pta-ben
[ 95%] Built target llvm-pta-ben
make: *** [Makefile:141: all] Error 2
mchalupa commented 2 years ago

Have you tried to include <map> to llvm-slicer-metadata.cpp as the compiler suggest?

freexxxyyy commented 2 years ago

it can be compiled successfully! Thanks!

mchalupa commented 2 years ago

I take this issue is resolved. If not, feel free to re-open.

hrshy0629 commented 2 years ago

Nope, it doesn't seem LLVM-14 related. It looks that you compiled LLVM as a static library only? Try specifying -DLLVM_LINK_DYLIB=off when running cmake for DG (what is the output of cmake?) (or re-compile LLVM as a shared library too)

Good suggestion! it can be compiled successfully! Thanks! LLVM-12.01 and Ubuntu18.04.

Clingto commented 1 year ago

Nope, it doesn't seem LLVM-14 related. It looks that you compiled LLVM as a static library only? Try specifying -DLLVM_LINK_DYLIB=off when running cmake for DG (what is the output of cmake?) (or re-compile LLVM as a shared library too)

This works for me. LLVM-6.0.0 and Ubuntu16.04