From 5e295f5c627373c81802680f415c1664884b6aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 2 Sep 2018 23:59:53 +0300 Subject: [PATCH] Allow building llvm with asserts disabled Doing that speeds up the built clang by around 25% (which is rather significant) and reduces the size of the clang executable by almost 30%. But since the mingw target in clang/llvm is less mature and less widely tested than other llvm targets, running with assertions allows catching quite a few issues during build instead of ending up with potentially broken code. --- build-llvm.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/build-llvm.sh b/build-llvm.sh index 3981fa1..82092d5 100755 --- a/build-llvm.sh +++ b/build-llvm.sh @@ -2,11 +2,22 @@ set -e -if [ $# -lt 1 ]; then - echo $0 dest +ASSERTS=ON +BUILDDIR=build + +while [ $# -gt 0 ]; do + if [ "$1" = "--disable-asserts" ]; then + ASSERTS=OFF + BUILDDIR=build-noasserts + else + PREFIX="$1" + fi + shift +done +if [ -z "$PREFIX" ]; then + echo $0 [--disable-asserts] dest exit 1 fi -PREFIX="$1" : ${CORES:=4} @@ -53,13 +64,13 @@ if [ "$(which ninja)" != "" ]; then fi cd llvm -mkdir -p build -cd build +mkdir -p $BUILDDIR +cd $BUILDDIR cmake \ $CMAKE_GENERATOR \ -DCMAKE_INSTALL_PREFIX="$PREFIX" \ -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_ENABLE_ASSERTIONS=$ASSERTS \ -DLLVM_TARGETS_TO_BUILD="ARM;AArch64;X86" \ -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \ -DLLVM_TOOLCHAIN_TOOLS="llvm-ar;llvm-ranlib;llvm-objdump;llvm-rc;llvm-cvtres;llvm-nm;llvm-strings;llvm-readobj;llvm-dlltool;llvm-pdbutil" \