Git Product home page Git Product logo

Comments (12)

Andrix44 avatar Andrix44 commented on June 11, 2024 2

The last time I built it for Windows, I downloaded the source and all the dependencies (LLVM, Z3, Capstone...) then I opened the folder with cmake-gui. You have to manually enable features and enter the paths to your downloaded libraries. You should also enable PYTHON_BINDINGS_AUTOCOMPLETE. Click configure until there are no errors then click generate and make sure you only have warnings and no errors. Then you can open the solution in VS. Build python-triton and triton_autocomplete. Now you should have the .pyd and .pyi files that you can copy to your python site-packages directory. If you get any errors while building you probably didn't set up the dependecies correctly in CMAKE.

from triton.

PavelKotov1 avatar PavelKotov1 commented on June 11, 2024 1

Cher Andrix44!
Well, that sounds like a really good answer!
I shall definitely try it ASAP and then report back the results to the community!
Thanks a lot!

from triton.

trustednstaller avatar trustednstaller commented on June 11, 2024 1

Follow up for anyone as well, to build Release builds on Windows with pre-built LLVM support. Note: still running into issues when generating debug builds of my projects using Triton, but for Release builds it's fine.

option(ASAN                              "Enable the ASAN linking"                         OFF)
option(BITWUZLA_INTERFACE                "Use Bitwuzla as SMT solver"                      OFF)
option(BUILD_SHARED_LIBS                 "Build a shared library"                          ON)
option(GCOV                              "Enable code coverage"                            OFF)
option(LLVM_INTERFACE                    "Use LLVM for lifting"                            ON)
option(MSVC_STATIC                       "Use statically-linked runtime library"           OFF)
option(Z3_INTERFACE                      "Use Z3 as SMT solver"                            ON)
option(BOOST_INTERFACE                   "Use Boost as multiprecision library"             OFF)
option(PYTHON_BINDINGS_AUTOCOMPLETE      "Generate an autocomplete stub file"              ON)

I'm using PowerShell to set the dependencies as such, but you can readily adjust this to your build environment.

$BuildDir = "C:\code\triton\build"

# ---------------------------------------------------------------------------------
# z3 pre-built dependencies
#  > pre-build: https://github.com/Z3Prover/z3/releases/download/z3-4.8.9/z3-4.8.9-x64-win.zip
# ---------------------------------------------------------------------------------
$Z3_INCLUDE_DIRS   = "$BuildDir\z3\include"
$Z3_LIBRARIES_DIR  = "$BuildDir\z3\bin"
$Z3_LIBRARIES      = "$Z3_LIBRARIES_DIR\libz3.lib"

# ---------------------------------------------------------------------------------
# capstone 4.0.2 pre-built dependencies
#   > build first, straightforward
# ---------------------------------------------------------------------------------
$CAPSTONE_INCLUDE_DIRS = "$BuildDir\capstone-4.0.2\include" 
$CAPSTONE_LIBRARIES    = "$BuildDir\capstone-4.0.2\msvc\x64\Release\capstone.lib"

# ---------------------------------------------------------------------------------
#  LLVM15 pre-installed
#   > https://github.com/LLVMParty/REVIDE/releases/download/libraries/llvm-15.0.3-win64.7z
# ---------------------------------------------------------------------------------
$LLVM_PREFIX = "C:\code\llvm-15.0.3-win64"
$LLVM_DIR = "$LLVM_DIR\lib\cmake\llvm"             # needs to find LLVMConfig.cmake

NOTE: for LLVM, he has a hardcoded path for diaguids.pdb that could cause an issue when building. You can adjust to your build environment by modifying the LLVMExports.cmake file or the .csprojx file after running cmake.

> llvm-15.0.3-win64
kd > rg "diaguids"
lib/cmake\llvm\LLVMExports.cmake
406:  INTERFACE_LINK_LIBRARIES "c:/Program Files/Microsoft Visual Studio/2022/Community/DIA SDK/lib/amd64/diaguids.lib;LLVMBinaryFormat;LLVMObject;LLVMSupport;LLVMDebugInfoCodeView;LLVMDebugInfoMSF"

Then generate the build scripts as such (targeting Python11 here):

cmake -DLLVM_INTERFACE=ON -DCMAKE_PREFIX_PATH="$LLVM_PREFIX" -DLLVM_DIR="$LLVM_DIR" -DPYTHON_VERSION="3.11" -DCAPSTONE_INCLUDE_DIRS="$CAPSTONE_INCLUDE_DIRS" -DCAPSTONE_LIBRARIES="$CAPSTONE_LIBRARIES" -DZ3_INCLUDE_DIRS="$Z3_INCLUDE_DIRS" -DZ3_LIBRARIES_DIR="$Z3_LIBRARIES_DIR".. -A x64
msbuild C:\code\triton\build\triton.sln /property:Configuration=Release /property:Platform=x64 /t:triton /t:python-triton /m:3

For both builds, the native and Python, make sure libz3.dll is always accessible, since it's a direct dependency.

from triton.

JonathanSalwan avatar JonathanSalwan commented on June 11, 2024

Also check that all deps like z3 are into the same folder than triton.pyd

from triton.

SirWaffle avatar SirWaffle commented on June 11, 2024

I copied and pasted this set of files in a few places....
the capstone DLL
the lib Z3 dll
the triton DLL
i also duplicated all of them, and changed the extension to pyd

I get this error when trying to import triton from the vcpkg:
Python.Runtime.PythonException: 'ImportError : dynamic module does not define module export function (PyInit_triton)'

using the artifacts for x64 from the build (from https://ci.appveyor.com/project/JonathanSalwan/triton/history) results in this error:
Python.Runtime.PythonException: 'ModuleNotFoundError : No module named 'triton.language'; 'triton' is not a package'

any ideas?

from triton.

JonathanSalwan avatar JonathanSalwan commented on June 11, 2024

PyInit_triton makes me think about an issue around Python version (compile vs runtime). Is the Python version used during the compile is the same than the one used at runtime?

from triton.

PavelKotov1 avatar PavelKotov1 commented on June 11, 2024

Hello, dear friends!
Pretty much the same situation installing triton and referencing it from python script.
Could somebody in the name of charity and goodwill explain how to handle this problem? Detailed instruction would be very much appreciated since i am out of options after trying all recommended steps...
Thanks in advance!

from triton.

JonathanSalwan avatar JonathanSalwan commented on June 11, 2024

Sorry guys, I can't help you on that side as i do not have a Windows on hand.

from triton.

JonathanSalwan avatar JonathanSalwan commented on June 11, 2024

Awesome, thanks a lot for this feedback!

from triton.

cctv130 avatar cctv130 commented on June 11, 2024

Follow up for anyone as well, to build Release builds on Windows with pre-built LLVM support. Note: still running into issues when generating debug builds of my projects using Triton, but for Release builds it's fine.

option(ASAN                              "Enable the ASAN linking"                         OFF)
option(BITWUZLA_INTERFACE                "Use Bitwuzla as SMT solver"                      OFF)
option(BUILD_SHARED_LIBS                 "Build a shared library"                          ON)
option(GCOV                              "Enable code coverage"                            OFF)
option(LLVM_INTERFACE                    "Use LLVM for lifting"                            ON)
option(MSVC_STATIC                       "Use statically-linked runtime library"           OFF)
option(Z3_INTERFACE                      "Use Z3 as SMT solver"                            ON)
option(BOOST_INTERFACE                   "Use Boost as multiprecision library"             OFF)
option(PYTHON_BINDINGS_AUTOCOMPLETE      "Generate an autocomplete stub file"              ON)

I'm using PowerShell to set the dependencies as such, but you can readily adjust this to your build environment.

$BuildDir = "C:\code\triton\build"

# ---------------------------------------------------------------------------------
# z3 pre-built dependencies
#  > pre-build: https://github.com/Z3Prover/z3/releases/download/z3-4.8.9/z3-4.8.9-x64-win.zip
# ---------------------------------------------------------------------------------
$Z3_INCLUDE_DIRS   = "$BuildDir\z3\include"
$Z3_LIBRARIES_DIR  = "$BuildDir\z3\bin"
$Z3_LIBRARIES      = "$Z3_LIBRARIES_DIR\libz3.lib"

# ---------------------------------------------------------------------------------
# capstone 4.0.2 pre-built dependencies
#   > build first, straightforward
# ---------------------------------------------------------------------------------
$CAPSTONE_INCLUDE_DIRS = "$BuildDir\capstone-4.0.2\include" 
$CAPSTONE_LIBRARIES    = "$BuildDir\capstone-4.0.2\msvc\x64\Release\capstone.lib"

# ---------------------------------------------------------------------------------
#  LLVM15 pre-installed
#   > https://github.com/LLVMParty/REVIDE/releases/download/libraries/llvm-15.0.3-win64.7z
# ---------------------------------------------------------------------------------
$LLVM_PREFIX = "C:\code\llvm-15.0.3-win64"
$LLVM_DIR = "$LLVM_DIR\lib\cmake\llvm"             # needs to find LLVMConfig.cmake

NOTE: for LLVM, he has a hardcoded path for diaguids.pdb that could cause an issue when building. You can adjust to your build environment by modifying the LLVMExports.cmake file or the .csprojx file after running cmake.

> llvm-15.0.3-win64
kd > rg "diaguids"
lib/cmake\llvm\LLVMExports.cmake
406:  INTERFACE_LINK_LIBRARIES "c:/Program Files/Microsoft Visual Studio/2022/Community/DIA SDK/lib/amd64/diaguids.lib;LLVMBinaryFormat;LLVMObject;LLVMSupport;LLVMDebugInfoCodeView;LLVMDebugInfoMSF"

Then generate the build scripts as such (targeting Python11 here):

cmake -DLLVM_INTERFACE=ON -DCMAKE_PREFIX_PATH="$LLVM_PREFIX" -DLLVM_DIR="$LLVM_DIR" -DPYTHON_VERSION="3.11" -DCAPSTONE_INCLUDE_DIRS="$CAPSTONE_INCLUDE_DIRS" -DCAPSTONE_LIBRARIES="$CAPSTONE_LIBRARIES" -DZ3_INCLUDE_DIRS="$Z3_INCLUDE_DIRS" -DZ3_LIBRARIES_DIR="$Z3_LIBRARIES_DIR".. -A x64
msbuild C:\code\triton\build\triton.sln /property:Configuration=Release /property:Platform=x64 /t:triton /t:python-triton /m:3

For both builds, the native and Python, make sure libz3.dll is always accessible, since it's a direct dependency.

How do you compile the latest llvm,The official installer does not have a complete list of cmake files

from triton.

PavelKotov1 avatar PavelKotov1 commented on June 11, 2024

How do you compile the latest llvm,The official installer does not have a complete list of cmake files

Hello! I asked a very similar question here:
Their response was priceless!

from triton.

cctv130 avatar cctv130 commented on June 11, 2024

How do you compile the latest llvm,The official installer does not have a complete list of cmake files

Hello! I asked a very similar question here: Their response was priceless! Check it out!

After searching through the files you mentioned, I guess you can compile using lazel.

from triton.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.