diff --git a/build-compiler-rt.sh b/build-compiler-rt.sh index 94b3bed..daa9d08 100755 --- a/build-compiler-rt.sh +++ b/build-compiler-rt.sh @@ -38,9 +38,6 @@ mkdir -p "$PREFIX" PREFIX="$(cd "$PREFIX" && pwd)" export PATH="$PREFIX/bin:$PATH" -: ${CORES:=$(nproc 2>/dev/null)} -: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)} -: ${CORES:=4} : ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}} ANY_ARCH=$(echo $ARCHS | awk '{print $1}') @@ -61,13 +58,24 @@ if [ ! -e "$PREFIX/i386-w64-mingw32" ]; then esac fi -case $(uname) in -MINGW*) - CMAKE_GENERATOR="MSYS Makefiles" - ;; -*) - ;; -esac +if [ -n "$(which ninja)" ]; then + CMAKE_GENERATOR="Ninja" + NINJA=1 + BUILDCMD=ninja +else + : ${CORES:=$(nproc 2>/dev/null)} + : ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)} + : ${CORES:=4} + + case $(uname) in + MINGW*) + CMAKE_GENERATOR="MSYS Makefiles" + ;; + *) + ;; + esac + BUILDCMD=make +fi cd llvm-project/compiler-rt @@ -111,7 +119,7 @@ for arch in $ARCHS; do -DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE \ -DCOMPILER_RT_USE_BUILTINS_LIBRARY=TRUE \ $SRC_DIR - make -j$CORES + $BUILDCMD ${CORES+-j$CORES} mkdir -p "$PREFIX/lib/clang/$CLANG_VERSION/lib/windows" mkdir -p "$PREFIX/$arch-w64-mingw32/bin" for i in lib/windows/libclang_rt.*-$buildarchname*.a; do @@ -123,7 +131,7 @@ for arch in $ARCHS; do fi done if [ -n "$SANITIZERS" ]; then - make install-compiler-rt-headers + $BUILDCMD install-compiler-rt-headers fi cd .. done diff --git a/build-libcxx.sh b/build-libcxx.sh index 9129fcf..9cb33f5 100755 --- a/build-libcxx.sh +++ b/build-libcxx.sh @@ -43,9 +43,6 @@ PREFIX="$(cd "$PREFIX" && pwd)" export PATH="$PREFIX/bin:$PATH" -: ${CORES:=$(nproc 2>/dev/null)} -: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)} -: ${CORES:=4} : ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}} if [ ! -d llvm-project/libunwind ] || [ -n "$SYNC" ]; then @@ -56,13 +53,24 @@ cd llvm-project LIBCXX=$(pwd)/libcxx -case $(uname) in -MINGW*) - CMAKE_GENERATOR="MSYS Makefiles" - ;; -*) - ;; -esac +if [ -n "$(which ninja)" ]; then + CMAKE_GENERATOR="Ninja" + NINJA=1 + BUILDCMD=ninja +else + : ${CORES:=$(nproc 2>/dev/null)} + : ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)} + : ${CORES:=4} + + case $(uname) in + MINGW*) + CMAKE_GENERATOR="MSYS Makefiles" + ;; + *) + ;; + esac + BUILDCMD=make +fi build_all() { type="$1" @@ -105,8 +113,8 @@ build_all() { -DCMAKE_CXX_FLAGS="-Wno-dll-attribute-on-redeclaration" \ -DCMAKE_C_FLAGS="-Wno-dll-attribute-on-redeclaration" \ .. - make -j$CORES - make install + $BUILDCMD ${CORES+-j$CORES} + $BUILDCMD install if [ "$type" = "shared" ]; then mkdir -p "$PREFIX/$arch-w64-mingw32/bin" cp lib/libunwind.dll "$PREFIX/$arch-w64-mingw32/bin" @@ -148,7 +156,7 @@ build_all() { -DCXX_SUPPORTS_CXX_STD=TRUE \ -DCMAKE_CXX_FLAGS="$LIBCXXABI_VISIBILITY_FLAGS -D_LIBCPP_HAS_THREAD_API_WIN32" \ .. - make -j$CORES + $BUILDCMD ${CORES+-j$CORES} cd .. done cd .. @@ -197,8 +205,8 @@ build_all() { -DCMAKE_SHARED_LINKER_FLAGS="-lunwind" \ -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE \ .. - make -j$CORES - make install + $BUILDCMD ${CORES+-j$CORES} + $BUILDCMD install if [ "$type" = "shared" ]; then llvm-ar qcsL \ "$PREFIX/$arch-w64-mingw32/lib/libc++.dll.a" \