[llvm] Update to version 10.0.0 and add new features (#10295)

* [llvm] Update to version 10.0.0 and new features

* switch to llvmorg-10.0.0-rc3, allow to use bin directory for tools

* Fix CMake targets after vcpkg_fixup_cmake_targets call.

* [halide] Update to master version to support LLVM 10

* [halide] fix x64-osx build

* [llvm] add enable-assertions feature

* [llvm] fix comment

* [llvm] enable ci for x64-linux and x64-osx

* [llvm] update to v10.0.0-rc5
[llvm] disable assertions and ABI breaking checks by default
[llvm] limit the maximum number of concurrent link jobs to 1
[llvm] add postfix `d` and debug shared libraries in the `/bin` directory

* [llvm] revert debug postfix `d`
[llvm] don't remove debug version of tools and shared libs

* [llvm] fix debug tools path

* [llvm] update to release tag llvmorg-10.0.0
[llvm] build with CMAKE_DEBUG_POSTFIX=d
[llvm] remove debug binaries

* remove new CMake argument FOLLOW_SYMLINK_CHAIN

* [llvm] force TableGen to be built with optimization

* [llvm] add future disable-clang-static-analyzer

* [llvm] add futures for main targets
[llvm] remove utils and clang-tools-extra from default features list
[llvm] exclude tests

* [llvm] add features for main targets
[llvm] remove utils and clang-tools-extra from default features list
[llvm] exclude tests

* [llvm] update features description

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
This commit is contained in:
yurybura 2020-05-04 06:30:17 +03:00 committed by GitHub
parent 0ab1a9e1c6
commit cfc05991f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 335 additions and 192 deletions

View File

@ -1,5 +1,5 @@
Source: halide Source: halide
Version: release_2019_08_27-2 Version: master_2020_03_07
Homepage: https://github.com/halide/Halide Homepage: https://github.com/halide/Halide
Description: Halide is a programming language designed to make it easier to write high-performance image processing code on modern machines. Description: Halide is a programming language designed to make it easier to write high-performance image processing code on modern machines.
Build-Depends: llvm[tools], openblas Build-Depends: llvm[tools], openblas

View File

@ -1,8 +1,8 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ba3843..6697118 100644 index 577b61ed2..7c6dd8ac4 100644
--- a/CMakeLists.txt --- a/CMakeLists.txt
+++ b/CMakeLists.txt +++ b/CMakeLists.txt
@@ -450,7 +450,7 @@ install(FILES @@ -432,7 +432,7 @@ install(FILES
DESTINATION include) DESTINATION include)
install(DIRECTORY tutorial install(DIRECTORY tutorial
@ -11,22 +11,20 @@ index 4ba3843..6697118 100644
FILES_MATCHING FILES_MATCHING
PATTERN "*.cpp" PATTERN "*.cpp"
PATTERN "*.h" PATTERN "*.h"
@@ -478,12 +478,12 @@ endforeach() @@ -463,10 +463,10 @@ install(FILES
# ---- README README.md
file(GLOB FILES "${HALIDE_BASE_DIR}/*.md") README_rungen.md
install(FILES ${FILES} README_webassembly.md
- DESTINATION .) - DESTINATION .)
+ DESTINATION share/halide) + DESTINATION share/halide)
# ---- halide.cmake # ---- halide.cmake
file(GLOB FILES "${HALIDE_BASE_DIR}/*.cmake") -install(FILES halide.cmake DESTINATION .)
install(FILES ${FILES} +install(FILES halide.cmake DESTINATION share/halide)
- DESTINATION .)
+ DESTINATION share/halide)
# ---- halide_config # ---- halide_config
file(GLOB FILES "${HALIDE_BASE_DIR}/tools/halide_config.*.tpl") file(GLOB FILES "${Halide_SOURCE_DIR}/tools/halide_config.*.tpl")
@@ -492,7 +492,7 @@ foreach(F ${FILES}) @@ -475,7 +475,7 @@ foreach(F ${FILES})
string(REGEX REPLACE "\\.tpl$" "" FNAME "${FNAME}") # Strip .tpl extension string(REGEX REPLACE "\\.tpl$" "" FNAME "${FNAME}") # Strip .tpl extension
configure_file("${F}" "${CMAKE_BINARY_DIR}/${FNAME}" @ONLY) configure_file("${F}" "${CMAKE_BINARY_DIR}/${FNAME}" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/${FNAME}" install(FILES "${CMAKE_BINARY_DIR}/${FNAME}"

View File

@ -1,8 +1,8 @@
vcpkg_from_github( vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH OUT_SOURCE_PATH SOURCE_PATH
REPO halide/Halide REPO halide/Halide
REF 65c26cba6a3eca2d08a0bccf113ca28746012cc3 #release_2019_08_27 REF f43293be3725bb959941e38c1b1fa9ae925f7389
SHA512 f95b31ec08a6c4e618a5c03b6ae9e0b41888035a268e82ee73abde8ea34dff325db270f1ff10387ef03de27e274ad27c7ccbc873c0b75bb6c1a8112cf3765c5d SHA512 f223185e208acf6c5b73353a6b5be815db5f2598f568596e800c35ea40b0babe4630da44229e14a5607e9d5e78298d07e7b36a9cbc7b71bf3e665bc12caff68e
HEAD_REF master HEAD_REF master
PATCHES PATCHES
fix-install-path.patch fix-install-path.patch

View File

@ -0,0 +1,30 @@
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index a02c2a5a23f..bdbf0b1303c 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -70,6 +70,12 @@ if( LLVM_ENABLE_PROJECTS STREQUAL "all" )
set( LLVM_ENABLE_PROJECTS ${LLVM_ALL_PROJECTS})
endif()
+# Allow to use commas in LLVM_ENABLE_PROJECTS ("llvm,clang,...")
+string(REPLACE "," ";" fixed_LLVM_ENABLE_PROJECTS "${LLVM_ENABLE_PROJECTS}")
+if(NOT fixed_LLVM_ENABLE_PROJECTS STREQUAL LLVM_ENABLE_PROJECTS)
+ set(LLVM_ENABLE_PROJECTS "${fixed_LLVM_ENABLE_PROJECTS}" CACHE STRING "" FORCE)
+endif()
+
# LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the
# `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for
# several reasons:
@@ -383,6 +389,12 @@ set(LLVM_TARGETS_TO_BUILD
${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD})
list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
+# Allow to use commas in the LLVM_TARGETS_TO_BUILD ("X86,AArch64,...")
+string(REPLACE "," ";" fixed_LLVM_TARGETS_TO_BUILD "${LLVM_TARGETS_TO_BUILD}")
+if(NOT fixed_LLVM_TARGETS_TO_BUILD STREQUAL LLVM_TARGETS_TO_BUILD)
+ set(LLVM_TARGETS_TO_BUILD "${fixed_LLVM_TARGETS_TO_BUILD}" CACHE STRING "" FORCE)
+endif()
+
option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF)

View File

@ -0,0 +1,42 @@
diff --git a/clang/cmake/modules/CMakeLists.txt b/clang/cmake/modules/CMakeLists.txt
index d233f552f01..26f502ad2d2 100644
--- a/clang/cmake/modules/CMakeLists.txt
+++ b/clang/cmake/modules/CMakeLists.txt
@@ -1,11 +1,11 @@
# Generate a list of CMake library targets so that other CMake projects can
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
# the usual CMake convention seems to be ${Project}Targets.cmake.
-set(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang)
+set(CLANG_INSTALL_PACKAGE_DIR share/clang)
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
# Keep this in sync with llvm/cmake/CMakeLists.txt!
-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(LLVM_INSTALL_PACKAGE_DIR share/llvm)
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt
index 9cf22b436fa..8eeb27d1794 100644
--- a/llvm/cmake/modules/CMakeLists.txt
+++ b/llvm/cmake/modules/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(LLVM_INSTALL_PACKAGE_DIR share/llvm)
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
# First for users who use an installed LLVM, create the LLVMExports.cmake file.
diff --git a/polly/cmake/CMakeLists.txt b/polly/cmake/CMakeLists.txt
index 211f9551271..2abe3803f91 100644
--- a/polly/cmake/CMakeLists.txt
+++ b/polly/cmake/CMakeLists.txt
@@ -1,7 +1,7 @@
# Keep this in sync with llvm/cmake/CMakeLists.txt!
-set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
-set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
+set(LLVM_INSTALL_PACKAGE_DIR share/llvm)
+set(POLLY_INSTALL_PACKAGE_DIR share/polly)
if (CMAKE_CONFIGURATION_TYPES)
set(POLLY_EXPORTS_FILE_NAME "PollyExports-$<LOWER_CASE:$<CONFIG>>.cmake")
else()

View File

@ -1,19 +1,75 @@
Source: llvm Source: llvm
Version: 8.0.0-5 Version: 10.0.0
Homepage: https://llvm.org/ Homepage: https://llvm.org/
Description: The LLVM Compiler Infrastructure Description: The LLVM Compiler Infrastructure
Build-Depends: atlmfc (windows)
Supports: !uwp Supports: !uwp
Default-Features: utils Default-Features: tools, enable-rtti, disable-assertions, disable-abi-breaking-checks, clang, disable-clang-static-analyzer, lld
Feature: tools Feature: tools
Description: Generate build targets for the LLVM tools. Description: Build LLVM tools.
Feature: utils Feature: utils
Description: Generate build targets for the LLVM utils. Description: Build LLVM utils.
Feature: example Feature: target-all
Description: Generate build targets for the LLVM examples Description: Build with all backends.
Feature: test Feature: target-aarch64
Description: Generate build targets for the LLVM unit tests. Description: Build with AArch64 backend.
Feature: target-arm
Description: Build with ARM backend.
Feature: target-mips
Description: Build with Mips backend.
Feature: target-powerpc
Description: Build with PowerPC backend.
Feature: target-systemz
Description: Build with SystemZ backend.
Feature: target-webassembly
Description: Build with WebAssembly backend.
Feature: target-x86
Description: Build with X86 backend.
Feature: enable-rtti
Description: Build LLVM with run-time type information.
Feature: enable-assertions
Description: Build LLVM with assertions.
Feature: disable-assertions
Description: Build LLVM without assertions.
Feature: enable-abi-breaking-checks
Description: Build LLVM with LLVM_ABI_BREAKING_CHECKS=FORCE_ON.
Feature: disable-abi-breaking-checks
Description: Build LLVM with LLVM_ABI_BREAKING_CHECKS=FORCE_OFF.
Feature: clang
Description: Build C Language Family Front-end.
Feature: disable-clang-static-analyzer
Description: Build without static analyzer.
Feature: clang-tools-extra
Description: Build Clang tools.
Feature: compiler-rt
Description: Build compiler's runtime libraries.
Feature: lld
Description: Build LLVM linker.
Feature: openmp
Description: Build LLVM OpenMP libraries.
Feature: lldb
Description: Build LLDB debugger.
Feature: polly
Description: Build polyhedral optimizations for LLVM.

View File

@ -1,14 +0,0 @@
--- a/tools/libclang/CMakeLists.txt
+++ b/tools/libclang/CMakeLists.txt
@@ -56,10 +56,7 @@ if (TARGET clangTidyPlugin)
endif()
endif ()
-find_library(DL_LIBRARY_PATH dl)
-if (DL_LIBRARY_PATH)
- list(APPEND LIBS dl)
-endif()
+list(APPEND LIBS "${DL_LIBRARY_PATH}")
option(LIBCLANG_BUILD_STATIC
"Build libclang as a static library (in addition to a shared one)" OFF)

View File

@ -1,13 +0,0 @@
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index 900c35e..78fd3cd 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -154,7 +154,7 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
else()
include_directories(${LIBXML2_INCLUDE_DIR})
endif()
- set(LIBXML2_LIBS "xml2")
+ set(LIBXML2_LIBS ${LIBXML2_LIBRARIES})
endif()
endif()
endif()

View File

@ -1,18 +0,0 @@
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
index be6d1d72..4749f64b 100644
--- a/cmake/modules/CMakeLists.txt
+++ b/cmake/modules/CMakeLists.txt
@@ -1,11 +1,11 @@
# Generate a list of CMake library targets so that other CMake projects can
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
# the usual CMake convention seems to be ${Project}Targets.cmake.
-set(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang)
+set(CLANG_INSTALL_PACKAGE_DIR share/clang)
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
# Keep this in sync with llvm/cmake/CMakeLists.txt!
-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(LLVM_INSTALL_PACKAGE_DIR share/llvm)
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)

View File

@ -1,10 +0,0 @@
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
index f5cc0006..1d9c52ac 100644
--- a/cmake/modules/CMakeLists.txt
+++ b/cmake/modules/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(LLVM_INSTALL_PACKAGE_DIR share/llvm)
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
# First for users who use an installed LLVM, create the LLVMExports.cmake file.

View File

@ -1,139 +1,214 @@
include(vcpkg_common_functions) include(vcpkg_common_functions)
# LLVM documentation recommends always using static library linkage when set(VERSION "10.0.0")
# building with Microsoft toolchain; it's also the default on other platforms
vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") vcpkg_from_github(
message(FATAL_ERROR "llvm cannot currently be built for UWP")
endif()
vcpkg_download_distfile(ARCHIVE
URLS "http://releases.llvm.org/8.0.0/llvm-8.0.0.src.tar.xz"
FILENAME "llvm-8.0.0.src.tar.xz"
SHA512 1602343b451b964f5d8c2d6b0654d89384c80d45883498c5f0e2f4196168dd4a1ed2a4dadb752076020243df42ffe46cb31d82ffc145d8e5874163cbb9686a1f
)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE} REPO llvm/llvm-project
REF llvmorg-10.0.0
SHA512 baa182d62fef1851836013ae8a1a00861ea89769778d67fb97b407a9de664e6c85da2af9c5b3f75d2bf34ff6b00004e531ca7e4b3115a26c0e61c575cf2303a0
HEAD_REF master
PATCHES PATCHES
install-llvm-modules-to-share.patch 0001-allow-to-use-commas.patch
fix-linux-build.patch 0002-fix-install-paths.patch
) )
vcpkg_download_distfile(CLANG_ARCHIVE
URLS "http://releases.llvm.org/8.0.0/cfe-8.0.0.src.tar.xz"
FILENAME "cfe-8.0.0.src.tar.xz"
SHA512 98e540222719716985e5d8439116e47469cb01201ea91d1da7e46cb6633da099688d9352c3b65e5c5f660cbbae353b3d79bb803fc66b3be663f2b04b1feed1c3
)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH CLANG_SOURCE_PATH
ARCHIVE ${CLANG_ARCHIVE}
PATCHES
fix-build-error.patch
install-clang-modules-to-share.patch
)
if(NOT EXISTS ${SOURCE_PATH}/tools/clang)
file(RENAME ${CLANG_SOURCE_PATH} ${SOURCE_PATH}/tools/clang)
endif()
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
set(ENV{PATH} "$ENV{PATH};${PYTHON3_DIR}")
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
tools LLVM_BUILD_TOOLS
tools LLVM_INCLUDE_TOOLS tools LLVM_INCLUDE_TOOLS
utils LLVM_BUILD_UTILS
utils LLVM_INCLUDE_UTILS utils LLVM_INCLUDE_UTILS
example LLVM_INCLUDE_EXAMPLES enable-rtti LLVM_ENABLE_RTTI
test LLVM_INCLUDE_TESTS
) )
vcpkg_configure_cmake( # By default assertions are enabled for Debug configuration only.
SOURCE_PATH ${SOURCE_PATH} if("enable-assertions" IN_LIST FEATURES)
PREFER_NINJA # Force enable assertions for all configurations.
OPTIONS ${FEATURE_OPTIONS} list(APPEND FEATURE_OPTIONS
-DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_ASSERTIONS=ON
)
elseif("disable-assertions" IN_LIST FEATURES)
# Force disable assertions for all configurations.
list(APPEND FEATURE_OPTIONS
-DLLVM_ENABLE_ASSERTIONS=OFF
)
endif()
# LLVM_ABI_BREAKING_CHECKS can be WITH_ASSERTS (default), FORCE_ON or FORCE_OFF.
# By default abi-breaking checks are enabled if assertions are enabled.
if("enable-abi-breaking-checks" IN_LIST FEATURES)
# Force enable abi-breaking checks.
list(APPEND FEATURE_OPTIONS
-DLLVM_ABI_BREAKING_CHECKS=FORCE_ON
)
elseif("disable-abi-breaking-checks" IN_LIST FEATURES)
# Force disable abi-breaking checks.
list(APPEND FEATURE_OPTIONS
-DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF -DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF
-DLLVM_TOOLS_INSTALL_DIR=tools/llvm )
endif()
set(LLVM_ENABLE_PROJECTS)
if("clang" IN_LIST FEATURES OR "clang-tools-extra" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "clang")
if("disable-clang-static-analyzer" IN_LIST FEATURES)
list(APPEND FEATURE_OPTIONS
# Disable ARCMT
-DCLANG_ENABLE_ARCMT=OFF
# Disable static analyzer
-DCLANG_ENABLE_STATIC_ANALYZER=OFF
)
endif()
endif()
if("clang-tools-extra" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "clang-tools-extra")
endif()
if("compiler-rt" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "compiler-rt")
endif()
if("lld" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "lld")
endif()
if("openmp" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "openmp")
# Perl is required for the OpenMP run-time
vcpkg_find_acquire_program(PERL)
list(APPEND FEATURE_OPTIONS
-DPERL_EXECUTABLE=${PERL}
)
endif()
if("lldb" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "lldb")
endif()
if("polly" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "polly")
endif()
set(LLVM_TARGETS_TO_BUILD)
if("target-all" IN_LIST FEATURES)
set(LLVM_TARGETS_TO_BUILD "all")
else()
if("target-aarch64" IN_LIST FEATURES)
list(APPEND LLVM_TARGETS_TO_BUILD "AArch64")
endif()
if("target-arm" IN_LIST FEATURES)
list(APPEND LLVM_TARGETS_TO_BUILD "ARM")
endif()
if("target-mips" IN_LIST FEATURES)
list(APPEND LLVM_TARGETS_TO_BUILD "Mips")
endif()
if("target-powerpc" IN_LIST FEATURES)
list(APPEND LLVM_TARGETS_TO_BUILD "PowerPC")
endif()
if("target-systemz" IN_LIST FEATURES)
list(APPEND LLVM_TARGETS_TO_BUILD "SystemZ")
endif()
if("target-webassembly" IN_LIST FEATURES)
list(APPEND LLVM_TARGETS_TO_BUILD "WebAssembly")
endif()
if("target-x86" IN_LIST FEATURES)
list(APPEND LLVM_TARGETS_TO_BUILD "X86")
endif()
endif()
# Detect target to build if not specified
if("${LLVM_TARGETS_TO_BUILD}" STREQUAL "")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(LLVM_TARGETS_TO_BUILD "X86")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set(LLVM_TARGETS_TO_BUILD "ARM")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(LLVM_TARGETS_TO_BUILD "AArch64")
else()
set(LLVM_TARGETS_TO_BUILD "all")
endif()
endif()
# Use comma-separated string for enabled projects instead of semicolon-separated string.
# See https://github.com/microsoft/vcpkg/issues/4320
string(REPLACE ";" "," LLVM_ENABLE_PROJECTS "${LLVM_ENABLE_PROJECTS}")
string(REPLACE ";" "," LLVM_TARGETS_TO_BUILD "${LLVM_TARGETS_TO_BUILD}")
vcpkg_find_acquire_program(PYTHON3)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}/llvm
PREFER_NINJA
OPTIONS
${FEATURE_OPTIONS}
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_BUILD_EXAMPLES=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_BUILD_TESTS=OFF
# Force TableGen to be built with optimization. This will significantly improve build time.
-DLLVM_OPTIMIZED_TABLEGEN=ON
# LLVM generates CMake error due to Visual Studio version 16.4 is known to miscompile part of LLVM.
# LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON disables this error.
# See https://developercommunity.visualstudio.com/content/problem/845933/miscompile-boolean-condition-deduced-to-be-always.html
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON
-DLLVM_ENABLE_PROJECTS=${LLVM_ENABLE_PROJECTS}
-DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}
-DPACKAGE_VERSION=${VERSION}
-DPYTHON_EXECUTABLE=${PYTHON3}
# Limit the maximum number of concurrent link jobs to 1. This should fix low amount of memory issue for link.
-DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_PARALLEL_LINK_JOBS=1
# Disable build LLVM-C.dll (Windows only) due to doesn't compile with CMAKE_DEBUG_POSTFIX
-DLLVM_BUILD_LLVM_C_DYLIB=OFF
-DCMAKE_DEBUG_POSTFIX=d
) )
vcpkg_install_cmake() vcpkg_install_cmake()
if((NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") AND "tools" IN_LIST FEATURES)
file(GLOB EXE ${CURRENT_PACKAGES_DIR}/bin/*)
file(COPY ${EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/llvm)
file(REMOVE ${EXE})
endif()
if((NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") AND "tools" IN_LIST FEATURES)
file(GLOB DEBUG_EXE ${CURRENT_PACKAGES_DIR}/debug/bin/*)
file(COPY ${DEBUG_EXE} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/tools/llvm)
file(REMOVE ${DEBUG_EXE})
endif()
if ("tools" IN_LIST FEATURES)
vcpkg_fixup_cmake_targets(CONFIG_PATH share/clang TARGET_PATH share/clang)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
file(READ ${CURRENT_PACKAGES_DIR}/share/clang/ClangTargets-release.cmake RELEASE_MODULE)
string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/tools/llvm" RELEASE_MODULE "${RELEASE_MODULE}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/clang/ClangTargets-release.cmake "${RELEASE_MODULE}")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(READ ${CURRENT_PACKAGES_DIR}/share/clang/ClangTargets-debug.cmake DEBUG_MODULE)
string(REPLACE "\${_IMPORT_PREFIX}/debug/bin" "\${_IMPORT_PREFIX}/tools/llvm" DEBUG_MODULE "${DEBUG_MODULE}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/clang/ClangTargets-debug.cmake "${DEBUG_MODULE}")
endif()
endif()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/llvm) vcpkg_fixup_cmake_targets(CONFIG_PATH share/llvm)
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/llvm) vcpkg_fixup_cmake_targets(CONFIG_PATH share/clang TARGET_PATH share/clang)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
file(READ ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMExports-release.cmake RELEASE_MODULE) file(GLOB_RECURSE _release_targets
string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/tools/llvm" RELEASE_MODULE "${RELEASE_MODULE}") "${CURRENT_PACKAGES_DIR}/share/llvm/*-release.cmake"
file(WRITE ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMExports-release.cmake "${RELEASE_MODULE}") "${CURRENT_PACKAGES_DIR}/share/clang/*-release.cmake"
)
foreach(_target IN LISTS _release_targets)
file(READ ${_target} _contents)
# LLVM tools should be located in the bin folder because llvm-config expects to be inside a bin dir.
# Rename `/tools/${PORT}` to `/bin` back because there is no way to avoid this in vcpkg_fixup_cmake_targets.
string(REPLACE "{_IMPORT_PREFIX}/tools/${PORT}" "{_IMPORT_PREFIX}/bin" _contents "${_contents}")
file(WRITE ${_target} "${_contents}")
endforeach()
endif() endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(READ ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMExports-debug.cmake DEBUG_MODULE) file(GLOB_RECURSE _debug_targets
string(REPLACE "\${_IMPORT_PREFIX}/debug/bin" "\${_IMPORT_PREFIX}/tools/llvm" DEBUG_MODULE "${DEBUG_MODULE}") "${CURRENT_PACKAGES_DIR}/share/llvm/*-debug.cmake"
file(WRITE ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMExports-debug.cmake "${DEBUG_MODULE}") "${CURRENT_PACKAGES_DIR}/share/clang/*-debug.cmake"
endif() )
foreach(_target IN LISTS _debug_targets)
file(READ ${_target} _contents)
# LLVM tools should be located in the bin folder because llvm-config expects to be inside a bin dir.
# Rename `/tools/${PORT}` to `/bin` back because there is no way to avoid this in vcpkg_fixup_cmake_targets.
string(REPLACE "{_IMPORT_PREFIX}/tools/${PORT}" "{_IMPORT_PREFIX}/bin" _contents "${_contents}")
# Debug shared libraries should have `d` suffix and should be installed in the `/bin` directory.
# Rename `/debug/bin/` to `/bin`
string(REPLACE "{_IMPORT_PREFIX}/debug/bin/" "{_IMPORT_PREFIX}/bin/" _contents "${_contents}")
file(WRITE ${_target} "${_contents}")
endforeach()
if (EXISTS ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMConfig.cmake) # Install debug shared libraries in the `/bin` directory
file(READ ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMConfig.cmake LLVM_TOOLS_MODULE) file(GLOB _debug_shared_libs ${CURRENT_PACKAGES_DIR}/debug/bin/*${CMAKE_SHARED_LIBRARY_SUFFIX})
string(REPLACE "\${LLVM_INSTALL_PREFIX}/bin" "\${LLVM_INSTALL_PREFIX}/tools/llvm" LLVM_TOOLS_MODULE "${LLVM_TOOLS_MODULE}") file(INSTALL ${_debug_shared_libs} DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
file(WRITE ${CURRENT_PACKAGES_DIR}/share/llvm/LLVMConfig.cmake "${LLVM_TOOLS_MODULE}")
endif()
file(REMOVE_RECURSE file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/debug/bin
${CURRENT_PACKAGES_DIR}/debug/tools ${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/share ${CURRENT_PACKAGES_DIR}/debug/share
${CURRENT_PACKAGES_DIR}/debug/bin )
${CURRENT_PACKAGES_DIR}/debug/msbuild-bin
${CURRENT_PACKAGES_DIR}/bin
${CURRENT_PACKAGES_DIR}/msbuild-bin
${CURRENT_PACKAGES_DIR}/tools/msbuild-bin
${CURRENT_PACKAGES_DIR}/include/llvm/BinaryFormat/WasmRelocs
)
# Remove two empty include subdirectorys if they are indeed empty
file(GLOB MCANALYSISFILES ${CURRENT_PACKAGES_DIR}/include/llvm/MC/MCAnalysis/*)
if(NOT MCANALYSISFILES)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/llvm/MC/MCAnalysis)
endif()
file(GLOB MACHOFILES ${CURRENT_PACKAGES_DIR}/include/llvm/TextAPI/MachO/*)
if(NOT MACHOFILES)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/llvm/TextAPI/MachO)
endif() endif()
# Handle copyright # Handle copyright
file(INSTALL ${SOURCE_PATH}/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) file(INSTALL ${SOURCE_PATH}/llvm/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/llvm RENAME copyright)
if("clang" IN_LIST FEATURES)
file(INSTALL ${SOURCE_PATH}/clang/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/clang RENAME copyright)
endif()
# Don't fail if the bin folder exists.
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

View File

@ -998,9 +998,6 @@ llgl:x64-uwp=fail
llvm:arm64-windows=fail llvm:arm64-windows=fail
llvm:arm-uwp=fail llvm:arm-uwp=fail
llvm:x64-uwp=fail llvm:x64-uwp=fail
llvm:x64-linux=ignore
# installing iconv makes building llvm fail; needs to be fixed
llvm:x64-osx=ignore
lmdb:arm64-windows=fail lmdb:arm64-windows=fail
lmdb:arm-uwp=fail lmdb:arm-uwp=fail
lmdb:x64-uwp=fail lmdb:x64-uwp=fail