[llvm] update to 11.0.0 (#13998)

* [vcpkg] allow to use semicolons in COMMAND argument

* [llvm] update to 11.0.0

* [vcpkg] use latest version

* [vcpkg] allow to use semicolons in OPTIONS

* fix vcpkg_fixup_cmake_targets

* [llvm] fix more install paths, add /bigobj option, fix up CMake targets

* Apply suggestions from code review

* [llvm] fix clang, flang, lld, mlir and polly CMake targets

* [llvm] remove empty include directory /include/flang/Config

* [llvm] Flang requires C++17

* [llvm] add /Zc:__cplusplus

* [llvm] remove empty include directory include/clang-tidy/plugin

* [llvm] try to fix ClangConfig.cmake, LLVMConfig.cmake, LLDConfig.cmake etc. with patch

* [llvm] set tools install dir to tools/llvm

* [aws-sdk-cpp] fix build after changes in vcpkg_configure_cmake.cmake

* [llvm] disable Flang and OpenMP on Windows

Co-authored-by: Nicole Mazzuca <mazzucan@outlook.com>
This commit is contained in:
yurybura 2020-11-30 20:56:22 +03:00 committed by GitHub
parent 7c08030982
commit e95a7a8dc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 309 additions and 120 deletions

View File

@ -1,6 +1,6 @@
Source: aws-sdk-cpp
Version: 1.8.83
Port-Version: 1
Port-Version: 2
Homepage: https://github.com/aws/aws-sdk-cpp
Description: AWS SDK for C++
Build-Depends: openssl (!uwp&!windows), curl (!uwp&!windows), aws-c-event-stream

View File

@ -15,8 +15,6 @@ set(BUILD_ONLY core)
include(${CMAKE_CURRENT_LIST_DIR}/compute_build_only.cmake)
string(REPLACE ";" "\\\\\\\\\\;" BUILD_ONLY "${BUILD_ONLY}")
if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS)
set(rpath "@loader_path")
else()
@ -31,7 +29,7 @@ vcpkg_configure_cmake(
-DENABLE_TESTING=OFF
-DFORCE_SHARED_CRT=${FORCE_SHARED_CRT}
-DCMAKE_DISABLE_FIND_PACKAGE_Git=TRUE
-DBUILD_ONLY=${BUILD_ONLY}
"-DBUILD_ONLY=${BUILD_ONLY}"
-DBUILD_DEPS=OFF
-DCMAKE_INSTALL_RPATH=${rpath}
)

View File

@ -0,0 +1,31 @@
llvm/cmake/modules/HandleLLVMOptions.cmake | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ef22eb493ba..3e2f372e80c9 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -426,6 +426,12 @@ if( MSVC )
append("/Zc:inline" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ # Some projects use the __cplusplus preprocessor macro to check support for
+ # a particular version of the C++ standard. When this option is not specified
+ # explicitly, macro's value is "199711L" that implies C++98 Standard.
+ # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+ append("/Zc:__cplusplus" CMAKE_CXX_FLAGS)
+
# Allow users to request PDBs in release mode. CMake offeres the
# RelWithDebInfo configuration, but it uses different optimization settings
# (/Ob1 vs /Ob2 or -O2 vs -O3). LLVM provides this flag so that users can get
@@ -478,6 +484,10 @@ if( MSVC )
endif()
endif()
endif()
+ # By default MSVC has a 2^16 limit on the number of sections in an object file,
+ # but in many objects files need more than that. This flag is to increase the
+ # number of sections.
+ append("/bigobj" CMAKE_CXX_FLAGS)
endif( MSVC )
# Warnings-as-errors handling for GCC-compatible compilers:

View File

@ -1,30 +0,0 @@
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

@ -16,6 +16,58 @@ index d233f552f01..26f502ad2d2 100644
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
diff --git a/flang/cmake/modules/CMakeLists.txt b/flang/cmake/modules/CMakeLists.txt
index d233f552f01..26f502ad2d2 100644
--- a/flang/cmake/modules/CMakeLists.txt
+++ b/flang/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(FLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/flang)
+set(FLANG_INSTALL_PACKAGE_DIR share/flang)
set(flang_cmake_builddir "${CMAKE_BINARY_DIR}/${FLANG_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(FLANG_EXPORTS GLOBAL PROPERTY FLANG_EXPORTS)
diff --git a/lld/cmake/modules/CMakeLists.txt b/lld/cmake/modules/CMakeLists.txt
index d233f552f01..26f502ad2d2 100644
--- a/lld/cmake/modules/CMakeLists.txt
+++ b/lld/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(LLD_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/lld)
+set(LLD_INSTALL_PACKAGE_DIR share/lld)
set(lld_cmake_builddir "${CMAKE_BINARY_DIR}/${LLD_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(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 211f9551271..2abe3803f91 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -973,10 +973,10 @@
if(ARG_GEN_CONFIG)
## Part 1: Extension header to be included whenever we need extension
# processing.
- 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}")
file(WRITE
"${llvm_cmake_builddir}/LLVMConfigExtensions.cmake"
"set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")
install(FILES
diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt
index 9cf22b436fa..8eeb27d1794 100644
--- a/llvm/cmake/modules/CMakeLists.txt
@ -26,6 +78,24 @@ index 9cf22b436fa..8eeb27d1794 100644
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/mlir/cmake/modules/CMakeLists.txt b/mlir/cmake/modules/CMakeLists.txt
index d233f552f01..26f502ad2d2 100644
--- a/mlir/cmake/modules/CMakeLists.txt
+++ b/mlir/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(MLIR_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir)
+set(MLIR_INSTALL_PACKAGE_DIR share/mlir)
set(mlir_cmake_builddir "${CMAKE_BINARY_DIR}/${MLIR_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(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS)
diff --git a/polly/cmake/CMakeLists.txt b/polly/cmake/CMakeLists.txt
index 211f9551271..2abe3803f91 100644
--- a/polly/cmake/CMakeLists.txt

View File

@ -0,0 +1,22 @@
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 81275c0483d..61468e048ec 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -136,7 +136,7 @@ libomp_get_ldflags(LIBOMP_CONFIGURED_LDFLAGS)
add_library(omp ${LIBOMP_LIBRARY_KIND} ${LIBOMP_SOURCE_FILES})
set_target_properties(omp PROPERTIES
- PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}"
+ PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}" DEBUG_POSTFIX ""
LINK_FLAGS "${LIBOMP_CONFIGURED_LDFLAGS}"
LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
)
@@ -215,7 +215,7 @@ if(WIN32)
# Create new import library that is just the previously created one + kmp_import.cpp
add_library(ompimp STATIC ${LIBOMP_GENERATED_IMP_LIB} kmp_import.cpp)
set_target_properties(ompimp PROPERTIES
- PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}"
+ PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}" DEBUG_POSTFIX ""
LINKER_LANGUAGE C
)
add_dependencies(ompimp omp) # ensure generated import library is created first

View File

@ -1,15 +0,0 @@
diff --git a/llvm/include/llvm/Support/ManagedStatic.h b/llvm/include/llvm/Support/ManagedStatic.h
index bbd0d04ed..f2b41422f 100644
--- a/llvm/include/llvm/Support/ManagedStatic.h
+++ b/llvm/include/llvm/Support/ManagedStatic.h
@@ -40,8 +40,8 @@ template <typename T, size_t N> struct object_deleter<T[N]> {
// constexpr, a dynamic initializer may be emitted depending on optimization
// settings. For the affected versions of MSVC, use the old linker
// initialization pattern of not providing a constructor and leaving the fields
-// uninitialized.
-#if !defined(_MSC_VER) || defined(__clang__)
+// uninitialized. See http://llvm.org/PR41367 for details.
+#if !defined(_MSC_VER) || (_MSC_VER >= 1925) || defined(__clang__)
#define LLVM_USE_CONSTEXPR_CTOR
#endif

View File

@ -0,0 +1,39 @@
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp b/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
--- a/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalityPredicates.cpp
@@ -10,6 +10,17 @@
//
//===----------------------------------------------------------------------===//
+// Disable optimizations to work around MSVC debug mode bug in 32-bit:
+// https://developercommunity.visualstudio.com/content/problem/1179643/msvc-copies-overaligned-non-trivially-copyable-par.html
+// FIXME: Remove this when the issue is closed.
+#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_IX86)
+// We have to disable runtime checks in order to enable optimizations. This is
+// done for the entire file because the problem is actually observed in STL
+// template functions.
+#pragma runtime_checks("", off)
+#pragma optimize("gs", on)
+#endif
+
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
using namespace llvm;
diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
@@ -406,3 +406,13 @@
32, 8, AtomicOrdering::NotAtomic }));
}
}
+
+// This code sequence doesn't do anything, but it covers a previously uncovered
+// codepath that used to crash in MSVC x86_32 debug mode.
+TEST(LegalizerInfoTest, MSVCDebugMiscompile) {
+ const LLT S1 = LLT::scalar(1);
+ const LLT P0 = LLT::pointer(0, 32);
+ LegalizerInfo LI;
+ auto Builder = LI.getActionDefinitionsBuilder(TargetOpcode::G_PTRTOINT);
+ (void)Builder.legalForCartesianProduct({S1}, {P0});
+}

View File

@ -1,6 +1,5 @@
Source: llvm
Version: 10.0.0
Port-Version: 7
Version: 11.0.0
Homepage: https://llvm.org/
Description: The LLVM Compiler Infrastructure
Supports: !uwp
@ -18,7 +17,7 @@ Build-Depends: llvm[core,target-x86] (x86|x64), llvm[core,target-arm] (arm&!arm6
Feature: target-all
Description: Build with all backends.
Build-Depends: llvm[core,target-aarch64,target-amdgpu,target-arm,target-bpf,target-hexagon,target-lanai,target-mips,target-msp430,target-nvptx,target-powerpc,target-riscv,target-sparc,target-systemz,target-webassembly,target-x86,target-xcore]
Build-Depends: llvm[core,target-aarch64,target-amdgpu,target-arm,target-avr,target-bpf,target-hexagon,target-lanai,target-mips,target-msp430,target-nvptx,target-powerpc,target-riscv,target-sparc,target-systemz,target-webassembly,target-x86,target-xcore]
Feature: target-aarch64
Description: Build with AArch64 backend.
@ -29,6 +28,9 @@ Description: Build with AMDGPU backend.
Feature: target-arm
Description: Build with ARM backend.
Feature: target-avr
Description: Build with AVR backend.
Feature: target-bpf
Description: Build with BPF backend.
@ -95,14 +97,23 @@ Description: Build Clang tools.
Feature: compiler-rt
Description: Build compiler's runtime libraries.
Feature: flang
Description: Build Fortran front end.
Build-Depends: llvm[core,mlir]
Feature: lld
Description: Build LLVM linker.
Feature: openmp
Description: Build LLVM OpenMP libraries.
Feature: lldb
Description: Build LLDB debugger.
Feature: mlir
Description: Build Multi-Level IR Compiler Framework.
Feature: openmp
Description: Build LLVM OpenMP libraries.
Build-Depends: llvm[core,utils]
Feature: polly
Description: Build polyhedral optimizations for LLVM.
Build-Depends: llvm[core,utils]

View File

@ -1,19 +1,20 @@
set(VERSION "10.0.0")
set(LLVM_VERSION "11.0.0")
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO llvm/llvm-project
REF llvmorg-10.0.0
SHA512 baa182d62fef1851836013ae8a1a00861ea89769778d67fb97b407a9de664e6c85da2af9c5b3f75d2bf34ff6b00004e531ca7e4b3115a26c0e61c575cf2303a0
REF llvmorg-${LLVM_VERSION}
SHA512 b6d38871ccce0e086e27d35e42887618d68e57d8274735c59e3eabc42dee352412489296293f8d5169fe0044936345915ee7da61ebdc64ec10f7737f6ecd90f2
HEAD_REF master
PATCHES
0001-allow-to-use-commas.patch
0002-fix-install-paths.patch
0003-fix-vs2019-v16.6.patch
0001-add-msvc-options.patch # Fixed in LLVM 12.0.0
0002-fix-install-paths.patch # This patch fixes paths in ClangConfig.cmake, LLVMConfig.cmake, LLDConfig.cmake etc.
0003-fix-openmp-debug.patch
0004-fix-dr-1734.patch
0005-fix-tools-path.patch
0006-workaround-msvc-bug.patch # Fixed in LLVM 12.0.0
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
@ -24,6 +25,14 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
enable-rtti LLVM_ENABLE_RTTI
)
# 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
# and thread "[llvm-dev] Longstanding failing tests - clang-tidy, MachO, Polly" on llvm-dev Jan 21-23 2020.
list(APPEND FEATURE_OPTIONS
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON
)
# By default assertions are enabled for Debug configuration only.
if("enable-assertions" IN_LIST FEATURES)
# Force enable assertions for all configurations.
@ -62,12 +71,6 @@ if("clang" IN_LIST FEATURES OR "clang-tools-extra" IN_LIST FEATURES)
-DCLANG_ENABLE_STATIC_ANALYZER=OFF
)
endif()
if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND FEATURE_OPTIONS
# Disable dl library on Windows
-DDL_LIBRARY_PATH:FILEPATH=
)
endif()
endif()
if("clang-tools-extra" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "clang-tools-extra")
@ -75,28 +78,66 @@ endif()
if("compiler-rt" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "compiler-rt")
endif()
if("flang" IN_LIST FEATURES)
# Disable Flang on Windows (see http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html).
if(VCPKG_TARGET_IS_WINDOWS)
message(FATAL_ERROR "Building Flang with MSVC is not supported.")
endif()
list(APPEND LLVM_ENABLE_PROJECTS "flang")
list(APPEND FEATURE_OPTIONS
# Flang requires C++17
-DCMAKE_CXX_STANDARD=17
)
endif()
if("lld" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "lld")
endif()
if("lldb" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "lldb")
endif()
if("mlir" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "mlir")
endif()
if("openmp" IN_LIST FEATURES)
# Disable OpenMP on Windows (see https://bugs.llvm.org/show_bug.cgi?id=45074).
if(VCPKG_TARGET_IS_WINDOWS)
message(FATAL_ERROR "Building OpenMP with MSVC is not supported.")
endif()
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}
"-DPERL_EXECUTABLE=${PERL}"
)
endif()
if("lldb" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "lldb")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
list(APPEND FEATURE_OPTIONS
-DLIBOMP_DEFAULT_LIB_NAME=libompd
)
endif()
endif()
if("polly" IN_LIST FEATURES)
list(APPEND LLVM_ENABLE_PROJECTS "polly")
endif()
set(known_llvm_targets
AArch64 AMDGPU ARM BPF Hexagon Lanai Mips
MSP430 NVPTX PowerPC RISCV Sparc SystemZ
WebAssembly X86 XCore)
AArch64
AMDGPU
ARM
AVR
BPF
Hexagon
Lanai
Mips
MSP430
NVPTX
PowerPC
RISCV
Sparc
SystemZ
WebAssembly
X86
XCore
)
set(LLVM_TARGETS_TO_BUILD "")
foreach(llvm_target IN LISTS known_llvm_targets)
@ -106,12 +147,9 @@ foreach(llvm_target IN LISTS known_llvm_targets)
endif()
endforeach()
# Use comma-separated string 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)
get_filename_component(PYTHON3_DIR ${PYTHON3} DIRECTORY)
vcpkg_add_to_path(${PYTHON3_DIR})
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}/llvm
@ -122,60 +160,88 @@ vcpkg_configure_cmake(
-DLLVM_BUILD_EXAMPLES=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_BUILD_TESTS=OFF
# Disable optional dependencies to libxml2 and zlib
# Disable optional dependencies to libxml2 and zlib.
-DLLVM_ENABLE_LIBXML2=OFF
-DLLVM_ENABLE_ZLIB=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}
"-DLLVM_ENABLE_PROJECTS=${LLVM_ENABLE_PROJECTS}"
"-DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}"
-DPACKAGE_VERSION=${LLVM_VERSION}
# 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
# Disable build LLVM-C.dll (Windows only) due to doesn't compile with CMAKE_DEBUG_POSTFIX
-DLLVM_BUILD_LLVM_C_DYLIB=OFF
# Path for binary subdirectory (defaults to 'bin')
-DLLVM_TOOLS_INSTALL_DIR=tools/llvm
OPTIONS_DEBUG
-DCMAKE_DEBUG_POSTFIX=d
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/${PORT})
if("clang" IN_LIST FEATURES)
vcpkg_fixup_cmake_targets(CONFIG_PATH share/clang TARGET_PATH share/clang)
if(VCPKG_TARGET_IS_WINDOWS)
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)\.exe$]])
else()
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)$]])
endif()
file(GLOB LLVM_TOOL_FILES "${CURRENT_PACKAGES_DIR}/bin/*")
set(LLVM_TOOLS)
foreach(tool_file IN LISTS LLVM_TOOL_FILES)
get_filename_component(tool_file "${tool_file}" NAME)
if(tool_file MATCHES "${LLVM_EXECUTABLE_REGEX}")
list(APPEND LLVM_TOOLS "${CMAKE_MATCH_1}")
endif()
endforeach()
vcpkg_copy_tools(
TOOL_NAMES ${LLVM_TOOLS}
AUTO_CLEAN)
vcpkg_fixup_cmake_targets(CONFIG_PATH "share/clang" TARGET_PATH "share/clang" DO_NOT_DELETE_PARENT_CONFIG_PATH)
file(INSTALL ${SOURCE_PATH}/clang/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/clang RENAME copyright)
endif()
if("clang-tools-extra" IN_LIST FEATURES)
# Remove empty include directory include/clang-tidy/plugin
file(GLOB_RECURSE INCLUDE_CLANG_TIDY_PLUGIN_FILES "${CURRENT_PACKAGES_DIR}/include/clang-tidy/plugin/*")
if(NOT INCLUDE_CLANG_TIDY_PLUGIN_FILES)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/clang-tidy/plugin")
endif()
endif()
if("flang" IN_LIST FEATURES)
vcpkg_fixup_cmake_targets(CONFIG_PATH "share/flang" TARGET_PATH "share/flang" DO_NOT_DELETE_PARENT_CONFIG_PATH)
file(INSTALL ${SOURCE_PATH}/flang/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/flang RENAME copyright)
# Remove empty include directory /include/flang/Config
file(GLOB_RECURSE INCLUDE_FLANG_CONFIG_FILES "${CURRENT_PACKAGES_DIR}/include/flang/Config/*")
if(NOT INCLUDE_FLANG_CONFIG_FILES)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/flang/Config")
endif()
endif()
if("lld" IN_LIST FEATURES)
vcpkg_fixup_cmake_targets(CONFIG_PATH "share/lld" TARGET_PATH "share/lld" DO_NOT_DELETE_PARENT_CONFIG_PATH)
file(INSTALL ${SOURCE_PATH}/lld/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/lld RENAME copyright)
endif()
if("mlir" IN_LIST FEATURES)
vcpkg_fixup_cmake_targets(CONFIG_PATH "share/mlir" TARGET_PATH "share/mlir" DO_NOT_DELETE_PARENT_CONFIG_PATH)
file(INSTALL ${SOURCE_PATH}/mlir/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/mlir RENAME copyright)
endif()
if("polly" IN_LIST FEATURES)
vcpkg_fixup_cmake_targets(CONFIG_PATH "share/polly" TARGET_PATH "share/polly" DO_NOT_DELETE_PARENT_CONFIG_PATH)
file(INSTALL ${SOURCE_PATH}/polly/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/polly RENAME copyright)
endif()
vcpkg_fixup_cmake_targets(CONFIG_PATH "share/llvm" TARGET_PATH "share/llvm")
file(INSTALL ${SOURCE_PATH}/llvm/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/llvm RENAME copyright)
if(VCPKG_TARGET_IS_WINDOWS)
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)\.exe$]])
else()
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)$]])
endif()
file(GLOB LLVM_TOOL_FILES "${CURRENT_PACKAGES_DIR}/bin/*")
set(LLVM_TOOLS)
foreach(tool_file IN LISTS LLVM_TOOL_FILES)
get_filename_component(tool_file "${tool_file}" NAME)
if(tool_file MATCHES "${LLVM_EXECUTABLE_REGEX}")
list(APPEND LLVM_TOOLS "${CMAKE_MATCH_1}")
endif()
endforeach()
vcpkg_copy_tools(TOOL_NAMES ${LLVM_TOOLS} AUTO_CLEAN)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
endif()
# Handle copyright
file(INSTALL ${SOURCE_PATH}/llvm/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
if("clang" IN_LIST FEATURES)
file(INSTALL ${SOURCE_PATH}/clang/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/clang RENAME copyright)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/tools)
endif()
# LLVM still generates a few DLLs in the static build:

View File

@ -431,9 +431,6 @@ h3:arm64-windows=fail
h3:arm-uwp=fail
h3:x64-uwp=fail
halide:x64-windows-static=fail
# Halide depends on LLVM, which is mis-compiled by MSVC in x86-windows-dbg.
# See https://developercommunity.visualstudio.com/content/problem/1179643/msvc-copies-overaligned-non-trivially-copyable-par.html
halide:x86-windows=skip
hdf5:arm64-windows=fail
hdf5:arm-uwp=fail
hdf5:x64-uwp=fail

View File

@ -270,12 +270,12 @@ function(vcpkg_configure_cmake)
endforeach()
set(rel_command
${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_RELEASE}
${CMAKE_COMMAND} ${_csc_SOURCE_PATH} "${_csc_OPTIONS}" "${_csc_OPTIONS_RELEASE}"
-G ${GENERATOR}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR})
set(dbg_command
${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_DEBUG}
${CMAKE_COMMAND} ${_csc_SOURCE_PATH} "${_csc_OPTIONS}" "${_csc_OPTIONS_DEBUG}"
-G ${GENERATOR}
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug)