From ec4e0c393480b1b508874d5106ecb0db547962af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Wed, 19 Aug 2020 21:15:24 -0700 Subject: [openmpi/vcpkg_build_make] Disable parallel build (#12975) --- scripts/cmake/vcpkg_build_make.cmake | 20 ++++++++++++++++++-- scripts/cmake/vcpkg_execute_build_process.cmake | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'scripts/cmake') diff --git a/scripts/cmake/vcpkg_build_make.cmake b/scripts/cmake/vcpkg_build_make.cmake index 545e6d765..c957fc628 100644 --- a/scripts/cmake/vcpkg_build_make.cmake +++ b/scripts/cmake/vcpkg_build_make.cmake @@ -24,6 +24,9 @@ ## The target passed to the make build command (`./make `). If not specified, the 'all' target will ## be passed. ## +## ### DISABLE_PARALLEL +## The underlying buildsystem will be instructed to not parallelize +## ## ## Notes: ## This command should be preceeded by a call to [`vcpkg_configure_make()`](vcpkg_configure_make.md). ## You can use the alias [`vcpkg_install_make()`](vcpkg_configure_make.md) function if your CMake script supports the @@ -36,7 +39,7 @@ ## * [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake) ## * [libosip2](https://github.com/Microsoft/vcpkg/blob/master/ports/libosip2/portfile.cmake) function(vcpkg_build_make) - cmake_parse_arguments(_bc "ADD_BIN_TO_PATH;ENABLE_INSTALL" "LOGFILE_ROOT;BUILD_TARGET" "" ${ARGN}) + cmake_parse_arguments(_bc "ADD_BIN_TO_PATH;ENABLE_INSTALL;DISABLE_PARALLEL" "LOGFILE_ROOT;BUILD_TARGET" "" ${ARGN}) if(NOT _bc_LOGFILE_ROOT) set(_bc_LOGFILE_ROOT "build") @@ -64,6 +67,7 @@ function(vcpkg_build_make) find_program(MAKE make REQUIRED) set(MAKE_COMMAND "${MAKE}") set(MAKE_OPTS ${_bc_MAKE_OPTIONS} -j ${VCPKG_CONCURRENCY} --trace -f Makefile ${_bc_BUILD_TARGET}) + set(NO_PARALLEL_MAKE_OPTS ${_bc_MAKE_OPTIONS} -j 1 --trace -f Makefile ${_bc_BUILD_TARGET}) string(REPLACE " " "\\\ " _VCPKG_PACKAGE_PREFIX ${CURRENT_PACKAGES_DIR}) string(REGEX REPLACE "([a-zA-Z]):/" "/\\1/" _VCPKG_PACKAGE_PREFIX "${_VCPKG_PACKAGE_PREFIX}") @@ -75,6 +79,7 @@ function(vcpkg_build_make) set(MAKE_COMMAND "${MAKE}") # Set make command and install command set(MAKE_OPTS ${_bc_MAKE_OPTIONS} V=1 -j ${VCPKG_CONCURRENCY} -f Makefile ${_bc_BUILD_TARGET}) + set(NO_PARALLEL_MAKE_OPTS ${_bc_MAKE_OPTIONS} V=1 -j 1 -f Makefile ${_bc_BUILD_TARGET}) set(INSTALL_OPTS -j ${VCPKG_CONCURRENCY} install DESTDIR=${CURRENT_PACKAGES_DIR}) endif() @@ -118,14 +123,25 @@ function(vcpkg_build_make) if(MAKE_BASH) set(MAKE_CMD_LINE "${MAKE_COMMAND} ${MAKE_OPTS}") + set(NO_PARALLEL_MAKE_CMD_LINE "${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS}") else() set(MAKE_CMD_LINE ${MAKE_COMMAND} ${MAKE_OPTS}) + set(NO_PARALLEL_MAKE_CMD_LINE ${MAKE_COMMAND} ${NO_PARALLEL_MAKE_OPTS}) endif() + if (_bc_DISABLE_PARALLEL) + vcpkg_execute_build_process( + COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE} + WORKING_DIRECTORY "${WORKING_DIRECTORY}" + LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}" + ) + else() vcpkg_execute_build_process( COMMAND ${MAKE_BASH} ${MAKE_CMD_LINE} + NO_PARALLEL_COMMAND ${MAKE_BASH} ${NO_PARALLEL_MAKE_CMD_LINE} WORKING_DIRECTORY "${WORKING_DIRECTORY}" LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}${SHORT_BUILDTYPE}" - ) + ) + endif() if(_bc_ADD_BIN_TO_PATH) set(ENV{PATH} "${_BACKUP_ENV_PATH}") diff --git a/scripts/cmake/vcpkg_execute_build_process.cmake b/scripts/cmake/vcpkg_execute_build_process.cmake index 7097fbf1b..98e3648d5 100644 --- a/scripts/cmake/vcpkg_execute_build_process.cmake +++ b/scripts/cmake/vcpkg_execute_build_process.cmake @@ -65,6 +65,8 @@ function(vcpkg_execute_build_process) # The linker ran out of memory during execution. We will try continuing once more, with parallelism disabled. OR err_contents MATCHES "Cannot create parent directory" OR err_contents MATCHES "Cannot write file" # Multiple threads using the same directory at the same time cause conflicts, will try again. + OR err_contents MATCHES "Can't open" + # Multiple threads caused the wrong order of creating folders and creating files in folders ) message(STATUS "Restarting Build without parallelism because memory exceeded") set(LOG_OUT "${CURRENT_BUILDTREES_DIR}/${_ebp_LOGNAME}-out-1.log") -- cgit v1.2.3