From 1c6074be25da008b6a5756868011b784b425de47 Mon Sep 17 00:00:00 2001 From: Giordano Salvador <73959795+e3m3@users.noreply.github.com> Date: Wed, 2 Aug 2023 17:30:06 -0500 Subject: [PATCH] superbuild: Add jobs switch for sub-builds (#2568) * Set parallel level for sub-builds (ninja). Useful for thinly provisioned machines. Adds BUILD_TYPE switch for each component built. | `superbuild/CMakeLists.txt` --- superbuild/CMakeLists.txt | 44 +++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt index 6db5d496520..b2649d80fd5 100644 --- a/superbuild/CMakeLists.txt +++ b/superbuild/CMakeLists.txt @@ -37,6 +37,11 @@ set(CCACHE_DIR "default" CACHE STRING "ccache cache directory") set(PREBUILT_STAGE2 "NO" CACHE STRING "Provide pre-built stage2 archive to skip pre ispc-stage2 jobs") set(PREBUILT_STAGE2_PATH "NO" CACHE STRING "Provide pre-built stage2 toolchain path") set(STAGE2_TOOLCHAIN_INSTALL_PREFIX "NO" CACHE STRING "Path to install stage2 Clang/LLVM to") +set(BUILD_TYPE_ISPC "Release" CACHE STRING "Set the build type for ISPC build") +set(BUILD_TYPE_LLVM "Release" CACHE STRING "Set the build type for LLVM build") +set(BUILD_TYPE_SPIRV_TRANSLATOR "Release" CACHE STRING "Set the build type for SPIR-V Translator build") +set(BUILD_TYPE_VC_INTRINSICS "Release" CACHE STRING "Set the build type for VC Intrinsics build") +set(BUILD_TYPE_L0 "Release" CACHE STRING "Set the build type for L0 build") option(LLVM_DISABLE_ASSERTIONS "Enable LLVM build without assertions" ON) option(EXTERNAL_VERBOSE "Enable verbose for external project build and install commands" OFF) option(CCACHE "Enable ccache to speed up repetitive builds" OFF) @@ -124,6 +129,20 @@ if (EXTERNAL_VERBOSE) set(EXTERNAL_VERBOSE_FLAG "-v") endif() +if (CMAKE_BUILD_PARALLEL_LEVEL) + list(APPEND NINJA_JOBS -j ${CMAKE_BUILD_PARALLEL_LEVEL}) +else() + list(APPEND NINJA_JOBS "") +endif() + +if (CMAKE_BUILD_TYPE) + set(BUILD_TYPE_ISPC ${CMAKE_BUILD_TYPE}) + set(BUILD_TYPE_LLVM ${CMAKE_BUILD_TYPE}) + set(BUILD_TYPE_SPIRV_TRANSLATOR ${CMAKE_BUILD_TYPE}) + set(BUILD_TYPE_VC_INTRINSICS ${CMAKE_BUILD_TYPE}) + set(BUILD_TYPE_L0 ${CMAKE_BUILD_TYPE}) +endif() + message(STATUS "LLVM_VERSION is ${LLVM_VERSION}") message(STATUS "LLVM_URL is ${LLVM_URL}") message(STATUS "VC_INTRINSICS_URL is ${VC_INTRINSICS_URL}") @@ -146,6 +165,13 @@ message(STATUS "STAGE2_TOOLCHAIN_INSTALL_PREFIX is ${STAGE2_TOOLCHAIN_INSTALL_PR message(STATUS "LLVM_DISABLE_ASSERTIONS is ${LLVM_DISABLE_ASSERTIONS}") message(STATUS "LTO is ${LTO}") message(STATUS "PGO is ${PGO}") +message(STATUS "CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}") +message(STATUS "CMAKE_BUILD_PARALLEL_LEVEL is ${CMAKE_BUILD_PARALLEL_LEVEL}") +message(STATUS "BUILD_TYPE_ISPC is ${BUILD_TYPE_ISPC}") +message(STATUS "BUILD_TYPE_LLVM is ${BUILD_TYPE_LLVM}") +message(STATUS "BUILD_TYPE_SPIRV_TRANSLATOR is ${BUILD_TYPE_SPIRV_TRANSLATOR}") +message(STATUS "BUILD_TYPE_VC_INTRINSICS is ${BUILD_TYPE_VC_INTRINSICS}") +message(STATUS "BUILD_TYPE_L0 is ${BUILD_TYPE_L0}") message(STATUS "BUILD_STAGE2_TOOLCHAIN_ONLY is ${BUILD_STAGE2_TOOLCHAIN_ONLY}") message(STATUS "BUILD_SPIRV_TRANSLATOR_ONLY is ${BUILD_SPIRV_TRANSLATOR_ONLY}") message(STATUS "BUILD_VC_INTRINSICS_ONLY is ${BUILD_VC_INTRINSICS_ONLY}") @@ -285,7 +311,7 @@ endif() # common LLVM cmake configuration flags. list(APPEND LLVM_COMMON_CMAKE_ARGS - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=${BUILD_TYPE_LLVM} -DLLVM_ENABLE_DUMP=OFF -DLLVM_INSTALL_UTILS=ON -DLLVM_ENABLE_ZLIB=OFF @@ -449,7 +475,7 @@ message(STATUS "LLVM stage2 cmake arguments ${LLVM_STAGE2_CMAKE_ARGS}") # ISPC cmake arguments. list(APPEND ISPC_COMMON_CMAKE_ARGS - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=${BUILD_TYPE_ISPC} -DISPC_CROSS=ON -DXE_ENABLED=ON -DISPC_PREPARE_PACKAGE=ON @@ -775,6 +801,7 @@ list(APPEND NINJA_COMMAND_WITH_ENV_STAGE1 "CCACHE_CONFIGPATH=${CCACHE_DEFAULT_CONF}" ${NINJA_EXE} ${EXTERNAL_VERBOSE_FLAG} + ${NINJA_JOBS} ) list(APPEND NINJA_COMMAND_WITH_ENV_STAGE2 ${CMAKE_COMMAND} @@ -784,6 +811,7 @@ list(APPEND NINJA_COMMAND_WITH_ENV_STAGE2 "PATH=${ENV_PATH_STAGE2_ESC_SEM}" ${NINJA_EXE} ${EXTERNAL_VERBOSE_FLAG} + ${NINJA_JOBS} ) list(APPEND NINJA_COMMAND_WITH_ENV_STAGE3 ${CMAKE_COMMAND} @@ -793,7 +821,11 @@ list(APPEND NINJA_COMMAND_WITH_ENV_STAGE3 "PATH=${ENV_PATH_STAGE3_ESC_SEM}" ${NINJA_EXE} ${EXTERNAL_VERBOSE_FLAG} + ${NINJA_JOBS} ) +message(STATUS "NINJA_COMMAND_WITH_ENV_STAGE1 is ${NINJA_COMMAND_WITH_ENV_STAGE1}") +message(STATUS "NINJA_COMMAND_WITH_ENV_STAGE2 is ${NINJA_COMMAND_WITH_ENV_STAGE2}") +message(STATUS "NINJA_COMMAND_WITH_ENV_STAGE3 is ${NINJA_COMMAND_WITH_ENV_STAGE3}") if (BUILD_SPIRV_TRANSLATOR_ONLY) message(STATUS "BUILD SPIRV-LLVM-Translator only") @@ -809,7 +841,7 @@ if (BUILD_SPIRV_TRANSLATOR_ONLY) CMAKE_GENERATOR Ninja CMAKE_ARGS -DLLVM_DIR=${PREBUILT_STAGE2_PATH}/lib/cmake/llvm - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=${BUILD_TYPE_SPIRV_TRANSLATOR} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/stage2-toolchain.cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} BUILD_IN_SOURCE OFF @@ -833,7 +865,7 @@ if (BUILD_VC_INTRINSICS_ONLY) CMAKE_GENERATOR Ninja CMAKE_ARGS -DLLVM_DIR=${PREBUILT_STAGE2_PATH}/lib/cmake/llvm - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=${BUILD_TYPE_VC_INTRINSICS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/stage2-toolchain.cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} BUILD_IN_SOURCE OFF @@ -858,7 +890,7 @@ if (BUILD_L0_LOADER_ONLY) CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/stage2-l0-toolchain.cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=${BUILD_TYPE_L0} BUILD_COMMAND ${NINJA_COMMAND_WITH_ENV_STAGE2} INSTALL_COMMAND ${NINJA_COMMAND_WITH_ENV_STAGE2} install ) @@ -899,7 +931,7 @@ if (PGO OR NOT SKIP_STAGE2_DEPS) CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/stage2-l0-toolchain.cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/stage2 - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=${BUILD_TYPE_L0} SOURCE_DIR l0-source BUILD_IN_SOURCE OFF PREFIX bl0