From 5236fa3cc7635ea3f828b792ec38191299338d0a Mon Sep 17 00:00:00 2001 From: jasjuang Date: Thu, 16 Nov 2017 22:34:25 -0800 Subject: [PATCH 1/4] add in clang and enable tools --- ports/llvm/CONTROL | 2 +- ports/llvm/portfile.cmake | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ports/llvm/CONTROL b/ports/llvm/CONTROL index 2ea653a123d8af..fb8b1b3daf5afc 100644 --- a/ports/llvm/CONTROL +++ b/ports/llvm/CONTROL @@ -1,3 +1,3 @@ Source: llvm -Version: 5.0.0-2 +Version: 5.0.0-3 Description: The LLVM Compiler Infrastructure diff --git a/ports/llvm/portfile.cmake b/ports/llvm/portfile.cmake index a2f32abe97d253..c4233af37b8da1 100644 --- a/ports/llvm/portfile.cmake +++ b/ports/llvm/portfile.cmake @@ -11,6 +11,17 @@ vcpkg_download_distfile(ARCHIVE ) vcpkg_extract_source_archive(${ARCHIVE}) +vcpkg_download_distfile(CLANG_ARCHIVE + URLS "http://releases.llvm.org/5.0.0/cfe-5.0.0.src.tar.xz" + FILENAME "cfe-5.0.0.src.tar.xz" + SHA512 14acdd622310122b544c952ee5b932b7006d9d8424319f0e3974f2503d40a0cec4200fdd3d813a32ce0d877bcfbb9a5bd5c36f6142b4330e6c814f113ca2efe8 +) +vcpkg_extract_source_archive(${CLANG_ARCHIVE} ${SOURCE_PATH}/tools) + +if(NOT EXISTS ${SOURCE_PATH}/tools/clang) + file(RENAME ${SOURCE_PATH}/tools/cfe-5.0.0.src ${SOURCE_PATH}/tools/clang) +endif() + vcpkg_apply_patches( SOURCE_PATH ${SOURCE_PATH} PATCHES ${CMAKE_CURRENT_LIST_DIR}/install-cmake-modules-to-share.patch @@ -25,7 +36,7 @@ vcpkg_configure_cmake( PREFER_NINJA OPTIONS -DLLVM_TARGETS_TO_BUILD=X86 - -DLLVM_INCLUDE_TOOLS=OFF + -DLLVM_INCLUDE_TOOLS=ON -DLLVM_INCLUDE_UTILS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF @@ -35,6 +46,18 @@ vcpkg_configure_cmake( vcpkg_install_cmake() +file(GLOB EXE ${CURRENT_PACKAGES_DIR}/bin/*) +file(GLOB DEBUG_EXE ${CURRENT_PACKAGES_DIR}/debug/bin/*) +file(COPY ${EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/tools) +file(COPY ${DEBUG_EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/tools) +file(REMOVE ${EXE}) +file(REMOVE ${DEBUG_EXE}) + +file(GLOB CMAKECONFIG_DEBUG ${CURRENT_PACKAGES_DIR}/debug/lib/cmake/clang/*) +file(GLOB CMAKECONFIG ${CURRENT_PACKAGES_DIR}/lib/cmake/clang/*) +file(COPY ${CMAKECONFIG_DEBUG} DESTINATION ${CURRENT_PACKAGES_DIR}/share/clang) +file(COPY ${CMAKECONFIG} DESTINATION ${CURRENT_PACKAGES_DIR}/share/clang) + vcpkg_fixup_cmake_targets(CONFIG_PATH share/llvm) vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/llvm) @@ -42,6 +65,13 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/debug/tools ${CURRENT_PACKAGES_DIR}/debug/share + ${CURRENT_PACKAGES_DIR}/debug/bin + ${CURRENT_PACKAGES_DIR}/debug/lib/cmake + ${CURRENT_PACKAGES_DIR}/debug/msbuild-bin + ${CURRENT_PACKAGES_DIR}/bin + ${CURRENT_PACKAGES_DIR}/lib/cmake + ${CURRENT_PACKAGES_DIR}/msbuild-bin + ${CURRENT_PACKAGES_DIR}/tools/msbuild-bin ) # Remove one empty include subdirectory if it is indeed empty From a24ccdfc01aba83b833af528b8f1a6ec6db020a4 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Thu, 19 Oct 2017 17:19:11 -0700 Subject: [PATCH 2/4] [vcpkg-build-cmake] Build at IDLE priority. Try to detect out-of-memory issues in the linker, and restart the build once. --- scripts/cmake/vcpkg_build_cmake.cmake | 99 +++++++++++++++---- .../vcpkg_execute_required_process.cmake | 28 ++++-- toolsrc/src/vcpkg/base/system.cpp | 2 +- 3 files changed, 100 insertions(+), 29 deletions(-) diff --git a/scripts/cmake/vcpkg_build_cmake.cmake b/scripts/cmake/vcpkg_build_cmake.cmake index 0b4bbd2116513c..548e6cf4604647 100644 --- a/scripts/cmake/vcpkg_build_cmake.cmake +++ b/scripts/cmake/vcpkg_build_cmake.cmake @@ -33,10 +33,13 @@ function(vcpkg_build_cmake) set(_bc_LOGFILE_ROOT "build") endif() + set(PARALLEL_ARG) + set(NO_PARALLEL_ARG) + if(_VCPKG_CMAKE_GENERATOR MATCHES "Ninja") set(BUILD_ARGS "-v") # verbose output if (_bc_DISABLE_PARALLEL) - list(APPEND BUILD_ARGS "-j1") + set(NO_PARALLEL_ARG "-j1") endif() elseif(_VCPKG_CMAKE_GENERATOR MATCHES "Visual Studio") set(BUILD_ARGS @@ -44,7 +47,7 @@ function(vcpkg_build_cmake) "/p:UseIntelMKL=No" ) if (NOT _bc_DISABLE_PARALLEL) - list(APPEND BUILD_ARGS "/m") + set(PARALLEL_ARG "/m") endif() elseif(_VCPKG_CMAKE_GENERATOR MATCHES "NMake") # No options are currently added for nmake builds @@ -58,23 +61,79 @@ function(vcpkg_build_cmake) set(TARGET_PARAM) endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - message(STATUS "Build ${TARGET_TRIPLET}-rel") - vcpkg_execute_required_process( - COMMAND ${CMAKE_COMMAND} --build . --config Release ${TARGET_PARAM} -- ${BUILD_ARGS} - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel - LOGNAME ${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-rel - ) - message(STATUS "Build ${TARGET_TRIPLET}-rel done") - endif() + foreach(BUILDTYPE "release" "debug") + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL BUILDTYPE) + if(BUILDTYPE STREQUAL "debug") + set(SHORT_BUILDTYPE "dbg") + else() + set(SHORT_BUILDTYPE "rel") + endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - message(STATUS "Build ${TARGET_TRIPLET}-dbg") - vcpkg_execute_required_process( - COMMAND ${CMAKE_COMMAND} --build . --config Debug ${TARGET_PARAM} -- ${BUILD_ARGS} - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg - LOGNAME ${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-dbg - ) - message(STATUS "Build ${TARGET_TRIPLET}-dbg done") - endif() + message(STATUS "Build ${TARGET_TRIPLET}-${SHORT_BUILDTYPE}") + set(LOGPREFIX "${CURRENT_BUILDTREES_DIR}/${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-${SHORT_BUILDTYPE}") + set(LOGS) + + if(BUILDTYPE STREQUAL "release") + set(CONFIG "Release") + else() + set(CONFIG "Debug") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --config Release ${TARGET_PARAM} -- ${BUILD_ARGS} ${PARALLEL_ARG} + OUTPUT_FILE "${LOGPREFIX}-out.log" + ERROR_FILE "${LOGPREFIX}-err.log" + RESULT_VARIABLE error_code + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}) + if(error_code) + file(READ "${LOGPREFIX}-out.log" out_contents) + file(READ "${LOGPREFIX}-err.log" err_contents) + + if(out_contents) + list(APPEND LOGS "${LOGPREFIX}-out.log") + endif() + if(err_contents) + list(APPEND LOGS "${LOGPREFIX}-err.log") + endif() + + if(out_contents MATCHES "LINK : fatal error LNK1102:" OR out_contents MATCHES " fatal error C1060: ") + # The linker ran out of memory during execution. We will try continuing once more, with parallelism disabled. + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --config Release ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG} + OUTPUT_FILE "${LOGPREFIX}-out-1.log" + ERROR_FILE "${LOGPREFIX}-err-1.log" + RESULT_VARIABLE error_code + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}) + + if(error_code) + file(READ "${LOGPREFIX}-out-1.log" out_contents) + file(READ "${LOGPREFIX}-err-1.log" err_contents) + + if(out_contents) + list(APPEND LOGS "${LOGPREFIX}-out-1.log") + endif() + if(err_contents) + list(APPEND LOGS "${LOGPREFIX}-err-1.log") + endif() + endif() + endif() + + if(error_code) + set(STRINGIFIED_LOGS) + foreach(LOG ${LOGS}) + file(TO_NATIVE_PATH "${LOG}" NATIVE_LOG) + list(APPEND STRINGIFIED_LOGS " ${NATIVE_LOG}\n") + endforeach() + set(_eb_COMMAND ${CMAKE_COMMAND} --build . --config Release ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}) + set(_eb_WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}) + message(FATAL_ERROR + " Command failed: ${_eb_COMMAND}\n" + " Working Directory: ${_eb_WORKING_DIRECTORY}\n" + " See logs for more information:\n" + ${STRINGIFIED_LOGS}) + endif() + endif() + message(STATUS "Build ${TARGET_TRIPLET}-${SHORT_BUILDTYPE} done") + endif() + endforeach() endfunction() diff --git a/scripts/cmake/vcpkg_execute_required_process.cmake b/scripts/cmake/vcpkg_execute_required_process.cmake index 7c4907016b16dc..5b8922c146eaf3 100644 --- a/scripts/cmake/vcpkg_execute_required_process.cmake +++ b/scripts/cmake/vcpkg_execute_required_process.cmake @@ -30,22 +30,34 @@ ## * [qt5](https://github.com/Microsoft/vcpkg/blob/master/ports/qt5/portfile.cmake) function(vcpkg_execute_required_process) cmake_parse_arguments(vcpkg_execute_required_process "" "WORKING_DIRECTORY;LOGNAME" "COMMAND" ${ARGN}) - #debug_message("vcpkg_execute_required_process(${vcpkg_execute_required_process_COMMAND})") + set(LOG_OUT "${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-out.log") + set(LOG_ERR "${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-err.log") execute_process( COMMAND ${vcpkg_execute_required_process_COMMAND} - OUTPUT_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-out.log - ERROR_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-err.log + OUTPUT_FILE ${LOG_OUT} + ERROR_FILE ${LOG_ERR} RESULT_VARIABLE error_code WORKING_DIRECTORY ${vcpkg_execute_required_process_WORKING_DIRECTORY}) - #debug_message("error_code=${error_code}") if(error_code) - file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-out.log" NATIVE_LOG_OUT) - file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-err.log" NATIVE_LOG_ERR) + set(LOGS) + file(READ "${LOG_OUT}" out_contents) + file(READ "${LOG_ERR}" err_contents) + if(out_contents) + list(APPEND LOGS "${LOG_OUT}") + endif() + if(err_contents) + list(APPEND LOGS "${LOG_ERR}") + endif() + set(STRINGIFIED_LOGS) + foreach(LOG ${LOGS}) + file(TO_NATIVE_PATH "${LOG}" NATIVE_LOG) + list(APPEND STRINGIFIED_LOGS " ${NATIVE_LOG}\n") + endforeach() message(FATAL_ERROR " Command failed: ${vcpkg_execute_required_process_COMMAND}\n" " Working Directory: ${vcpkg_execute_required_process_WORKING_DIRECTORY}\n" " See logs for more information:\n" - " ${NATIVE_LOG_OUT}\n" - " ${NATIVE_LOG_ERR}\n") + ${STRINGIFIED_LOGS} + ) endif() endfunction() diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp index 625ee6ce0df126..84721bf6eafe9a 100644 --- a/toolsrc/src/vcpkg/base/system.cpp +++ b/toolsrc/src/vcpkg/base/system.cpp @@ -220,7 +220,7 @@ namespace vcpkg::System nullptr, nullptr, FALSE, - BELOW_NORMAL_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT, + IDLE_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT, env_cstr.data(), nullptr, &startup_info, From 0cf5bd657ef401319fa3ef60846189546a5c7a87 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Wed, 3 Jan 2018 20:11:35 -0800 Subject: [PATCH 3/4] [vcpkg-fixup-cmake-targets] Add TARGET_PATH option --- scripts/cmake/vcpkg_build_cmake.cmake | 12 ++++++------ scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 14 +++++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/cmake/vcpkg_build_cmake.cmake b/scripts/cmake/vcpkg_build_cmake.cmake index 548e6cf4604647..66503f4b8e697f 100644 --- a/scripts/cmake/vcpkg_build_cmake.cmake +++ b/scripts/cmake/vcpkg_build_cmake.cmake @@ -38,17 +38,13 @@ function(vcpkg_build_cmake) if(_VCPKG_CMAKE_GENERATOR MATCHES "Ninja") set(BUILD_ARGS "-v") # verbose output - if (_bc_DISABLE_PARALLEL) - set(NO_PARALLEL_ARG "-j1") - endif() + set(NO_PARALLEL_ARG "-j1") elseif(_VCPKG_CMAKE_GENERATOR MATCHES "Visual Studio") set(BUILD_ARGS "/p:VCPkgLocalAppDataDisabled=true" "/p:UseIntelMKL=No" ) - if (NOT _bc_DISABLE_PARALLEL) - set(PARALLEL_ARG "/m") - endif() + set(PARALLEL_ARG "/m") elseif(_VCPKG_CMAKE_GENERATOR MATCHES "NMake") # No options are currently added for nmake builds else() @@ -61,6 +57,10 @@ function(vcpkg_build_cmake) set(TARGET_PARAM) endif() + if(_bc_DISABLE_PARALLEL) + set(PARALLEL_ARG ${NO_PARALLEL_ARG}) + endif() + foreach(BUILDTYPE "release" "debug") if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL BUILDTYPE) if(BUILDTYPE STREQUAL "debug") diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index f86ad0661bbc7b..fead64d1544525 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -14,14 +14,18 @@ # function(vcpkg_fixup_cmake_targets) - cmake_parse_arguments(_vfct "" "CONFIG_PATH" "" ${ARGN}) + cmake_parse_arguments(_vfct "" "CONFIG_PATH;TARGET_PATH" "" ${ARGN}) if(_vfct_UNPARSED_ARGUMENTS) message(FATAL_ERROR "vcpkg_fixup_cmake_targets was passed extra arguments: ${_vfct_UNPARSED_ARGUMENTS}") endif() - set(DEBUG_SHARE ${CURRENT_PACKAGES_DIR}/debug/share/${PORT}) - set(RELEASE_SHARE ${CURRENT_PACKAGES_DIR}/share/${PORT}) + if(NOT _vfct_TARGET_PATH) + set(_vfct_TARGET_PATH share/${PORT}) + endif() + + set(DEBUG_SHARE ${CURRENT_PACKAGES_DIR}/debug/${_vfct_TARGET_PATH}) + set(RELEASE_SHARE ${CURRENT_PACKAGES_DIR}/${_vfct_TARGET_PATH}) if(_vfct_CONFIG_PATH AND NOT RELEASE_SHARE STREQUAL "${CURRENT_PACKAGES_DIR}/${_vfct_CONFIG_PATH}") set(DEBUG_CONFIG ${CURRENT_PACKAGES_DIR}/debug/${_vfct_CONFIG_PATH}) @@ -114,7 +118,7 @@ function(vcpkg_fixup_cmake_targets) string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+\\.exe)" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}") string(REPLACE "\${_IMPORT_PREFIX}/lib" "\${_IMPORT_PREFIX}/debug/lib" _contents "${_contents}") string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/debug/bin" _contents "${_contents}") - file(WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/${DEBUG_TARGET_NAME} "${_contents}") + file(WRITE ${CURRENT_PACKAGES_DIR}/${_vfct_TARGET_PATH}/${DEBUG_TARGET_NAME} "${_contents}") file(REMOVE ${DEBUG_TARGET}) endforeach() @@ -148,7 +152,7 @@ function(vcpkg_fixup_cmake_targets) file(WRITE ${MAIN_CONFIG} "${_contents}") endforeach() - # Remove /debug/share// if it's empty. + # Remove /debug// if it's empty. file(GLOB_RECURSE REMAINING_FILES "${DEBUG_SHARE}/*") if(NOT REMAINING_FILES) file(REMOVE_RECURSE ${DEBUG_SHARE}) From de98ec658f552c2f98f45683ad2d157015165c4f Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Wed, 3 Jan 2018 20:12:49 -0800 Subject: [PATCH 4/4] [llvm] Fix installation of clang cmake targets --- ports/llvm/CONTROL | 2 +- ports/llvm/portfile.cmake | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ports/llvm/CONTROL b/ports/llvm/CONTROL index f043598a9ae594..7df5565c259ba0 100644 --- a/ports/llvm/CONTROL +++ b/ports/llvm/CONTROL @@ -1,4 +1,4 @@ Source: llvm -Version: 5.0.0-3 +Version: 5.0.0-4 Description: The LLVM Compiler Infrastructure Build-Depends: atlmfc diff --git a/ports/llvm/portfile.cmake b/ports/llvm/portfile.cmake index f9ddef26e04289..55490a1b126b25 100644 --- a/ports/llvm/portfile.cmake +++ b/ports/llvm/portfile.cmake @@ -52,16 +52,12 @@ vcpkg_install_cmake() file(GLOB EXE ${CURRENT_PACKAGES_DIR}/bin/*) file(GLOB DEBUG_EXE ${CURRENT_PACKAGES_DIR}/debug/bin/*) -file(COPY ${EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/tools) -file(COPY ${DEBUG_EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/tools) +file(COPY ${EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/llvm) +file(COPY ${DEBUG_EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/tools/llvm) file(REMOVE ${EXE}) file(REMOVE ${DEBUG_EXE}) -file(GLOB CMAKECONFIG_DEBUG ${CURRENT_PACKAGES_DIR}/debug/lib/cmake/clang/*) -file(GLOB CMAKECONFIG ${CURRENT_PACKAGES_DIR}/lib/cmake/clang/*) -file(COPY ${CMAKECONFIG_DEBUG} DESTINATION ${CURRENT_PACKAGES_DIR}/share/clang) -file(COPY ${CMAKECONFIG} DESTINATION ${CURRENT_PACKAGES_DIR}/share/clang) - +vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/clang TARGET_PATH share/clang) vcpkg_fixup_cmake_targets(CONFIG_PATH share/llvm) vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/llvm) @@ -70,10 +66,8 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/tools ${CURRENT_PACKAGES_DIR}/debug/share ${CURRENT_PACKAGES_DIR}/debug/bin - ${CURRENT_PACKAGES_DIR}/debug/lib/cmake ${CURRENT_PACKAGES_DIR}/debug/msbuild-bin ${CURRENT_PACKAGES_DIR}/bin - ${CURRENT_PACKAGES_DIR}/lib/cmake ${CURRENT_PACKAGES_DIR}/msbuild-bin ${CURRENT_PACKAGES_DIR}/tools/msbuild-bin )