0xlane/ollvm-rust

How to compile the plugin?

chutuananh2k opened this issue · 3 comments

Thank you for doing great work!
I'm new to LLVM and don't know how to setup an environment to build the plugin. Please put an step-by-step of how to compile the plugin.
Thank you very much!

Hi,chutuananh2k.Thank you for your kind words!

I understand that setting up an environment for LLVM can be challenging for newcomers.I have already provided detailed compilation commands in the README. However, to assist you further, here's a more detailed step-by-step guide (with additional explanations compared to the instructions in the readme, particularly in the LLVM installation section):

Firstly, prepare the following compilation environment:

  • Windows: Ensure you are running Windows 10+.
  • Visual Studio 2022: Install Visual Studio 2022 (latest version). During the installation, select the "Desktop development with C++" workload.
  • LLVM 18.1.5:Before this project, I had manually compiled the LLVM project following the official documentation, so I didn't install it separately.This compilation process can be quite time-consuming, I recommend installing it directly via the chocolatey package manager: choco install llvm --version=18.1.5 (from here). Additionally, you need to know the location of the LLVM installation directory after installation, which should be displayed in the command output.

Secondly, start compiling plugin.This step can be compiled as instructed in the readme.

  • Open x64 Native Tools Command Prompt for VS 2022 window from start menu.And all subsequent commands are executed in this window.
  • Clone my repository: git clone --branch ollvm-pass https://github.com/0xlane/ollvm-rust.git.
  • And navigate to project root dir: cd ollvm-rust.
  • Run cmake to configure the project and generate a native build system: cmake -G "Ninja" -S .\ollvm-pass -B .\build -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLT_LLVM_INSTALL_DIR=D:\dev\rust_ollvm\llvm-build\llvm_x64. Note: You need to modify LT_LLVM_INSTALL_DIR to the previously obtained LLVM installation directory.
  • Then call that build system to actually compile/link the project: cmake --build .\build\

Eventually, all generated files should be within the 'build' folder.

If you're just looking to try out the plugin without delving into its inner workings, you can use the precompiled plugin files provided in the repository's release.Simply call it directly on a system that has already installed VC runtime.

The command to install LLVM using choco, I haven't personally tested as I already had an LLVM environment set up and didn't need to reinstall. If choco doesn't work, you might need to look up alternative approach on google.