JonathanSalwan / ttexplore

TTexplore is a library that performs path exploration on binary code using symbolic execution
72 stars 8 forks source link

CMake error #1

Closed vanhauser-thc closed 1 year ago

vanhauser-thc commented 1 year ago

Thank you for this! I want to experiment with it, however I already fail at cmake.

I built Triton:

/prg/Triton/build (master) # make
[ 87%] Built target triton
[ 87%] Built target python-triton
[ 89%] Built target taint_reg
[ 91%] Built target info_reg
[ 93%] Built target ir
[ 95%] Built target simplification
[ 97%] Built target constraint
[ 99%] Built target ctest_api
[100%] Built target block
/prg/Triton/build (master) # 

Now I try to configure ttexplore:

/prg/ttexplore/build (main) # cmake .. -Dtriton_DIR=/prg/Triton/build -DLIEF_DIR=/prg/LIEF/build

CMake Error at /prg/Triton/build/tritonConfig.cmake:10 (include):
  include could not find requested file:

    /prg/Triton/build/tritonTargets.cmake
Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package)

-- Found Triton: /prg/Triton/build/tritonConfig.cmake (found version 1.0)
-- Configuring incomplete, errors occurred!
See also "/prg/ttexplore/build/CMakeFiles/CMakeOutput.log".

and true there is no tritonConfig.cmake, but why wasnt it created?

JonathanSalwan commented 1 year ago

and true there is no tritonConfig.cmake, but why wasnt it created?

The tritonConfig is generated when calling make install. Use -DCMAKE_INSTALL_PREFIX if you want to install Triton in a specific directory. Then, you can use -DCMAKE_PREFIX_PATH for libraries that need Triton.

Maybe something like this?:

# Triton
$ cmake -DCMAKE_INSTALL_PREFIX=/my/path/where/installing/triton ..
$ make install

# ttexplore
$ cmake -DCMAKE_PREFIX_PATH=/my/path/where/installing/triton ..
vanhauser-thc commented 1 year ago

Ah that works :)

Now I get:

/prg/ttexplore/build (main) # make
[  6%] Building CXX object CMakeFiles/ttexplore.dir/lib/ttexplore.cpp.o
/prg/ttexplore/lib/ttexplore.cpp: In member function ‘void triton::engines::exploration::SymbolicExplorator::initWorklist()’:
/prg/ttexplore/lib/ttexplore.cpp:82:14: error: ‘std::filesystem’ has not been declared
   82 |         std::filesystem::create_directories(config.workspace + "/corpus");
      |              ^~~~~~~~~~
/prg/ttexplore/lib/ttexplore.cpp:83:14: error: ‘std::filesystem’ has not been declared
   83 |         std::filesystem::create_directories(config.workspace + "/crashes");
      |              ^~~~~~~~~~
/prg/ttexplore/lib/ttexplore.cpp:84:14: error: ‘std::filesystem’ has not been declared
   84 |         std::filesystem::create_directories(config.workspace + "/coverage");
      |              ^~~~~~~~~~
make[2]: *** [CMakeFiles/ttexplore.dir/build.make:76: CMakeFiles/ttexplore.dir/lib/ttexplore.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/ttexplore.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

this was with gcc-12

I can fix this with switching to clang++-14 and:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,10 +46,10 @@ target_link_libraries(harness4 ttexplore)
 target_link_libraries(harness5 ttexplore)
 target_link_libraries(harness6 ttexplore)

-target_compile_options(ttexplore PRIVATE -std=c++14)
-target_compile_options(harness1 PRIVATE -std=c++14)
-target_compile_options(harness2 PRIVATE -std=c++14)
-target_compile_options(harness3 PRIVATE -std=c++14)
-target_compile_options(harness4 PRIVATE -std=c++14)
-target_compile_options(harness5 PRIVATE -std=c++14)
-target_compile_options(harness6 PRIVATE -std=c++14)
+target_compile_options(ttexplore PRIVATE -std=c++17)
+target_compile_options(harness1 PRIVATE -std=c++17)
+target_compile_options(harness2 PRIVATE -std=c++17)
+target_compile_options(harness3 PRIVATE -std=c++17)
+target_compile_options(harness4 PRIVATE -std=c++17)
+target_compile_options(harness5 PRIVATE -std=c++17)
+target_compile_options(harness6 PRIVATE -std=c++17)

then I get stuck here:

Consolidate compiler generated dependencies of target harness5
[ 80%] Building CXX object CMakeFiles/harness5.dir/harness/5/harness.cpp.o
/prg/ttexplore/harness/5/harness.cpp:23:42: error: no member named 'SOLVER_BITWUZLA' in namespace 'triton::engines::solver'
  ctx.setSolver(triton::engines::solver::SOLVER_BITWUZLA);
                ~~~~~~~~~~~~~~~~~~~~~~~~~^
1 error generated.
make[2]: *** [CMakeFiles/harness5.dir/build.make:76: CMakeFiles/harness5.dir/harness/5/harness.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:225: CMakeFiles/harness5.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
JonathanSalwan commented 1 year ago

can fix this with switching to clang++-14 and:

woot :)

then I get stuck here:

Bitwuzla is a SMT solver (faster than z3 for BV logic) that is optional when compiling Triton. Two solutions:

Add bitwuzla to the Triton library

# Install of bitwuzla
$ git clone https://github.com/bitwuzla/bitwuzla
$ cd bitwuzla
$ ./contrib/setup-cadical.sh
$ ./contrib/setup-btor2tools.sh
$ ./contrib/setup-symfpu.sh
$ ./configure.sh --shared
$ sudo make -C build install

# Then, when compiling Triton:
$ cmake -DBITWUZLA_INTERFACE=ON ..

If Triton does not find the bitwuzla library and its include, you can define their paths:

# when compiling Triton
$ cmake -DBITWUZLA_INTERFACE=ON \
        -DBITWUZLA_INCLUDE_DIRS=/path/to/my/bitwuzla/include \
        -DBITWUZLA_LIBRARIES=/path/to/my/bitwuzla.so \
        ..
vanhauser-thc commented 1 year ago

This works, thanks :) I recommend to switch the CMakeLists.txt to c++-17 so it compiles with modern compilers + distros.