diff options
author | R. Elliott Childre <elliottchildre329@gmail.com> | 2021-02-20 19:24:28 -0500 |
---|---|---|
committer | R. Elliott Childre <elliottchildre329@gmail.com> | 2021-02-20 19:24:28 -0500 |
commit | 871c3c91ec7c462cf3024e48a5ae0d35770fc153 (patch) | |
tree | 9786f866e3c4c59db4cb0ee6af05bc7b5e8a0c60 | |
parent | 100aac4dd39012750036b2fd71eed5b21959f693 (diff) | |
download | afl++-871c3c91ec7c462cf3024e48a5ae0d35770fc153.tar.gz |
Improve LLVM build instructions
* Enable shell highlighting on code block * Shallow clone of source due to extensive history * Line break and sort the CMake options for visibility * Disable most extraneous options (e.g. docs, tests, benchmarks, clang-tools-extra, OpenCL interface) * Only build for the host architecture by default * Support other sub-make interfaces, like the recommended Ninja Build System * Harden against paths with spaces * Prefer linking against the newly built LLVM libraries by prepending to LD_LIBRARY_PATH
-rw-r--r-- | instrumentation/README.lto.md | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/instrumentation/README.lto.md b/instrumentation/README.lto.md index a2814173..81c82c4b 100644 --- a/instrumentation/README.lto.md +++ b/instrumentation/README.lto.md @@ -88,16 +88,35 @@ apt-get install -y clang-12 clang-tools-12 libc++1-12 libc++-12-dev \ ### Building llvm yourself (version 12) Building llvm from github takes quite some long time and is not painless: -``` +```sh sudo apt install binutils-dev # this is *essential*! -git clone https://github.com/llvm/llvm-project +git clone --depth=1 https://github.com/llvm/llvm-project cd llvm-project mkdir build cd build -cmake -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;compiler-rt;libclc;libcxx;libcxxabi;libunwind;lld' -DCMAKE_BUILD_TYPE=Release -DLLVM_BINUTILS_INCDIR=/usr/include/ ../llvm/ -make -j $(nproc) -export PATH=`pwd`/bin:$PATH -export LLVM_CONFIG=`pwd`/bin/llvm-config + +# Add -G Ninja if ninja-build installed +# "Building with ninja significantly improves your build time, especially with +# incremental builds, and improves your memory usage." +cmake \ + -DCLANG_INCLUDE_DOCS="OFF" \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_BINUTILS_INCDIR=/usr/include/ \ + -DLLVM_BUILD_LLVM_DYLIB="ON" \ + -DLLVM_ENABLE_BINDINGS="OFF" \ + -DLLVM_ENABLE_PROJECTS='clang;compiler-rt;libcxx;libcxxabi;libunwind;lld' \ + -DLLVM_ENABLE_WARNINGS="OFF" \ + -DLLVM_INCLUDE_BENCHMARKS="OFF" \ + -DLLVM_INCLUDE_DOCS="OFF" \ + -DLLVM_INCLUDE_EXAMPLES="OFF" \ + -DLLVM_INCLUDE_TESTS="OFF" \ + -DLLVM_LINK_LLVM_DYLIB="ON" \ + -DLLVM_TARGETS_TO_BUILD="host" \ + ../llvm/ +cmake --build . --parallel +export PATH="$(pwd)/bin:$PATH" +export LLVM_CONFIG="$(pwd)/bin/llvm-config" +export LD_LIBRARY_PATH="$(llvm-config --libdir)${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" cd /path/to/AFLplusplus/ make sudo make install |