Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Compile & Install

Zhang edited this page May 3, 2020 · 7 revisions

Apple Developers

If you are targeting Apple platforms on macOS, it's strongly advised to use Hanabi which injects into Apple Clang instead of compiling the full toolchain. This methods takes way shorter time to build (~5 Minutes) and introduces way less compatibility issues

Pre-built binaries

Occasionally, I would create Releases from the master branch. You could use those if you are using macOS.Just download the latest release and extract Hikari.xctoolchain to ~/Library/Developer/Toolchains/

Building

Prerequisites

Prerequisites are exactly the same as LLVM Upstream. You need a fairly new version of the following packages to compile LLVM.

  • SWIG
  • Python
  • CMake
  • GCC/Clang
  • zlib
Additionally, your compilation host is expected to have the usual plethora of Unix utilities. Specifically:

ar — archive library builder
bzip2 — bzip2 command for distribution generation
bunzip2 — bunzip2 command for distribution checking
chmod — change permissions on a file
cat — output concatenation utility
cp — copy files
date — print the current date/time
echo — print to standard output
egrep — extended regular expression search utility
find — find files/dirs in a file system
grep — regular expression search utility
gzip — gzip command for distribution generation
gunzip — gunzip command for distribution checking
install — install directories/files
mkdir — create a directory
mv — move (rename) files
ranlib — symbol table builder for archive libraries
rm — remove (delete) files and directories
sed — stream editor for transforming output
sh — Bourne shell for make build scripts
tar — tape archive for distribution generation
test — test things in file system
unzip — unzip command for distribution checking
zip — zip command for distribution generation

macOS Quick Install

This script assumes current working directory is not the user's home directory(aka ~/). cd to somewhere else if this is the case. This script also assumes you have cmake and ninja installed, if not, use Homebrew and similar package managers to install them

git clone --recursive -b release_80 https://github.com/HikariObfuscator/Hikari.git Hikari && cd Hikari && git submodule update --remote --recursive && cd ../ && mkdir Build && cd Build && cmake -G "Ninja" -DLLDB_CODESIGN_IDENTITY='' -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_APPEND_VC_REV=on -DLLDB_USE_SYSTEM_DEBUGSERVER=YES -DLLVM_CREATE_XCODE_TOOLCHAIN=on -DCMAKE_INSTALL_PREFIX=~/Library/Developer/ ../Hikari && ninja &&ninja install-xcode-toolchain && git clone https://github.com/HikariObfuscator/Resources.git ~/Hikari && rsync -a --ignore-existing /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ ~/Library/Developer/Toolchains/Hikari.xctoolchain/ && rm ~/Library/Developer/Toolchains/Hikari.xctoolchain/ToolchainInfo.plist

macOS Compile Issues:

  • CMake Error at tools/xcode-toolchain/CMakeLists.txt:80 (message): Could not identify toolchain dir Make sure you have Xcode installed and xcode-select -p points to /Applications/Xcode.app/Contents/Developer instead of the standalone macOS Toolchain
  • Error messages related to debugserver or lldb: Remove tools/lldb and re-run cmake and remaining steps

Building on Unix

Most parts are the same, you just remove all the commands related to Xcode

git clone --recursive -b release_80 https://github.com/HikariObfuscator/Hikari.git Hikari && cd Hikari && git submodule update --remote --recursive && cd ../ && mkdir Build && cd Build && cmake -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_APPEND_VC_REV=on ../Hikari && ninja && ninja install && git clone https://github.com/HikariObfuscator/Resources.git ~/Hikari

Building on Windows

You can either use a UNIX-Like environment like MinGW / Cygwin (Based upon community feedback. I personally have zero success building LLVM on Windows, even with official LLVM release tarballs.), or just edit lib/Transforms/Obfuscation/FunctionCallObfuscate.cpp , remove #include <dlfcn.h> and then clean up all function bodies in this file, add return false if required. Since that thing isn't supported on Windows anyway and I have no plan to adding support for Windows to that Obfuscation Pass.

Plus, even if you managed to get things working, there is a chance that the LLVM Frontend Clang won't accept your code (Google MSVC nonstandard behaviour ), so if you are using some non-standard compatible code, you might as well fall back to alternative solutions on Windows