Quantcast
Channel: Essence Sharing | 干货分享 - iOSRE
Viewing all articles
Browse latest Browse all 301

配置Hikari中文文档

$
0
0

@xuanInitial wrote:

太长不看版

git clone -b release_50 --recursive https://github.com/HikariObfuscator/MonolithicRepo.git Hikari && mkdir Build && cd Build && cmake -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_APPEND_VC_REV=on -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 -ua /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ ~/Library/Developer/Toolchains/Hikari.xctoolchain/ 

第一步:配置源码

基于向前移植的不再维护的源码

git clone -b release_50 --recursive https://github.com/HikariObfuscator/MonolithicRepo.git Hikari

基于最新的开发分支配置源码

git clone https://github.com/HikariObfuscator/Mirai.git Hikari 到本地

按照目录结构添加其他组件

Checkout Clang:

cd Hikari/tools

svn co http://llvm.org/svn/llvm-project/cfe/trunk clang -r 321064

Checkout LLD链接器

svn co http://llvm.org/svn/llvm-project/lld/trunk lld -r 321064

Checkout Compiler-RT

cd ../projects

svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt -r 321064

Checkout libcxx和libcxxabi

svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx -r 321064

svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi -r 321064

第二步:编译

在Hikari同级目录下新建一个文件夹(笔者这边建的是Hikari_llvm),然后执行

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_APPEND_VC_REV=on -DLLVM_CREATE_XCODE_TOOLCHAIN=on -DCMAKE_INSTALL_PREFIX=~/Library/Developer/ ../Hikari

../Hikari 是你第一次clone的主目录

执行到这步就算是上一步的成功

第三步:生成Hikari.xctoolchain

ninja install-xcode-toolchain

大概需要半个小时~1个小时,以及大概2.6gb的磁盘空间,等待结束。

第四步:Xcode集成

第一步中clone到本地的项目中resources/Hikari.xcplugin 复制到/Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/

TARGETS—>Build Settings—>All 搜索Enable Index-While-Building Functionality 设置为NO
**只有Xcode9以上需要

然后配置CFLAGS eg:-enable-allobf -mllvm -bcf_prob=100

然后在Xcode->Toolchains ,选择Hikari

第五步:Pass配置

clone配置

把Resources内的全部文件全部复制到~/Hikari/ (没有就 mkdir ~/Hikari)里面

错误及解决方式

1、报错锁定

解释

cleanup: Recursively clean up the working copy, removing write locks, resuming
unfinished operations, etc.
usage: cleanup [WCPATH...]

  By default, finish any unfinished business in the working copy at WCPATH,
  and remove write locks (shown as 'L' by the 'svn status' command) from
  the working copy. Usually, this is only necessary if a Subversion client
  has crashed while using the working copy, leaving it in an unusable state.

  WARNING: There is no mechanism that will protect write locks still
           being used by other Subversion clients. Running this command
           while another client is using the working copy can corrupt
           the working copy beyond repair!

  If the --remove-unversioned option or the --remove-ignored option
  is given, remove any unversioned or ignored items within WCPATH.
  To prevent accidental working copy corruption, unversioned or ignored
  items can only be removed if the working copy is not already locked
  for writing by another Subversion client.
  Note that the 'svn status' command shows unversioned items as '?',
  and ignored items as 'I' if the --no-ignore option is given to it.

Valid options:
  --diff3-cmd ARG          : use ARG as merge command
  --remove-unversioned     : remove unversioned items
  --remove-ignored         : remove ignored items
  --include-externals      : also operate on externals defined by
                             svn:externals properties
  -q [--quiet]             : print nothing, or only summary information

Global options:
  --username ARG           : specify a username ARG
  --password ARG           : specify a password ARG (caution: on many operating
                             systems, other users will be able to see this)
  --no-auth-cache          : do not cache authentication tokens
  --non-interactive        : do no interactive prompting (default is to prompt
                             only if standard input is a terminal device)
  --force-interactive      : do interactive prompting even if standard input
                             is not a terminal device
  --trust-server-cert      : deprecated; same as
                             --trust-server-cert-failures=unknown-ca
  --trust-server-cert-failures ARG : with --non-interactive, accept SSL server
                             certificates with failures; ARG is comma-separated
                             list of 'unknown-ca' (Unknown Authority),
                             'cn-mismatch' (Hostname mismatch), 'expired'
                             (Expired certificate), 'not-yet-valid' (Not yet
                             valid certificate) and 'other' (all other not
                             separately classified certificate errors).
  --config-dir ARG         : read user configuration files from directory ARG
  --config-option ARG      : set user configuration option in the format:
                                 FILE:SECTION:OPTION=[VALUE]
                             For example:
                                 servers:global:http-library=serf

解决办法: 删除tools/clang

重新执行

svn co http://llvm.org/svn/llvm-project/cfe/trunk clang -r 321064

2、报错

解决办法:删除CMakeCache.txt 和CMakeFiles文件夹

再次执行第二步

3、报错ld: file not found: /Library/Developer/Toolchains/Hikari.xctoolchain/***

解决方式:

  • 打开~/Library/Developer/Toolchains/Hikari.xctoolchain显示包内容
  • 打开

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain 显示包内容

  • 对比Hikari.xctoolchainXcodeDefault.xctoolchain下有哪些文件夹缺失,然后复制

注意放到对应的文件目录下

4、报错找不到Ninja

CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.

解决方式:Ninja没装 需要安装

执行(在安装Homebrew的前提下)

brew install ninja

如果没有安装Homebrew,执行下面代码

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

参考:

LLVM系统入门

Hikari wiki

Ninja

Homebrew

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 301

Trending Articles