From 6c6d87b81e8ae60d4f45126de569150767fa8845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sun, 1 Nov 2020 12:42:27 +0100 Subject: [PATCH 01/37] Added recipe for the LLVM core libraries --- recipes/llvm-core/all/CMakeLists.txt | 8 + recipes/llvm-core/all/conandata.yml | 41 +++ recipes/llvm-core/all/conanfile.py | 267 ++++++++++++++++++ recipes/llvm-core/all/patches/10x-cmake.patch | 19 ++ .../llvm-core/all/patches/10x-vs2019.patch | 11 + recipes/llvm-core/all/patches/11x-cmake.patch | 19 ++ .../llvm-core/all/patches/11x-vs2019.patch | 11 + recipes/llvm-core/all/patches/9x-cmake.patch | 20 ++ recipes/llvm-core/all/patches/9x-vs2019.patch | 11 + recipes/llvm-core/all/readme.md | 9 + .../llvm-core/all/test_package/CMakeLists.txt | 20 ++ .../llvm-core/all/test_package/conanfile.py | 38 +++ .../all/test_package/test_function.ll | 6 + .../all/test_package/test_package.cpp | 38 +++ recipes/llvm-core/config.yml | 12 + 15 files changed, 530 insertions(+) create mode 100644 recipes/llvm-core/all/CMakeLists.txt create mode 100644 recipes/llvm-core/all/conandata.yml create mode 100644 recipes/llvm-core/all/conanfile.py create mode 100644 recipes/llvm-core/all/patches/10x-cmake.patch create mode 100644 recipes/llvm-core/all/patches/10x-vs2019.patch create mode 100644 recipes/llvm-core/all/patches/11x-cmake.patch create mode 100644 recipes/llvm-core/all/patches/11x-vs2019.patch create mode 100644 recipes/llvm-core/all/patches/9x-cmake.patch create mode 100644 recipes/llvm-core/all/patches/9x-vs2019.patch create mode 100644 recipes/llvm-core/all/readme.md create mode 100644 recipes/llvm-core/all/test_package/CMakeLists.txt create mode 100644 recipes/llvm-core/all/test_package/conanfile.py create mode 100644 recipes/llvm-core/all/test_package/test_function.ll create mode 100644 recipes/llvm-core/all/test_package/test_package.cpp create mode 100644 recipes/llvm-core/config.yml diff --git a/recipes/llvm-core/all/CMakeLists.txt b/recipes/llvm-core/all/CMakeLists.txt new file mode 100644 index 0000000000000..71ba86b5911da --- /dev/null +++ b/recipes/llvm-core/all/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.14) +project(conanllvm) + +message(STATUS "Conan CMake Wrapper") +include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source") diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml new file mode 100644 index 0000000000000..1a40e960cf167 --- /dev/null +++ b/recipes/llvm-core/all/conandata.yml @@ -0,0 +1,41 @@ +sources: + "11.0.0": + url: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/llvm-11.0.0.src.tar.xz + sha256: 913f68c898dfb4a03b397c5e11c6a2f39d0f22ed7665c9cefa87a34423a72469 + + "10.0.1": + url: https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/llvm-10.0.1.src.tar.xz + sha256: c5d8e30b57cbded7128d78e5e8dad811bff97a8d471896812f57fa99ee82cdf3 + + "10.0.0": + url: https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/llvm-10.0.0.src.tar.xz + sha256: df83a44b3a9a71029049ec101fb0077ecbbdf5fe41e395215025779099a98fdf + + "9.0.1": + url: https://github.com/llvm/llvm-project/releases/download/llvmorg-9.0.1/llvm-9.0.1.src.tar.xz + sha256: 00a1ee1f389f81e9979f3a640a01c431b3021de0d42278f6508391a2f0b81c9a + +patches: + "11.0.0": + - base_path: "source" + patch_file: "patches/11x-vs2019.patch" + - base_path: "source" + patch_file: "patches/11x-cmake.patch" + + "10.0.1": + - base_path: "source" + patch_file: "patches/10x-vs2019.patch" + - base_path: "source" + patch_file: "patches/10x-cmake.patch" + + "10.0.0": + - base_path: "source" + patch_file: "patches/10x-vs2019.patch" + - base_path: "source" + patch_file: "patches/10x-cmake.patch" + + "9.0.1": + - base_path: "source" + patch_file: "patches/9x-vs2019.patch" + - base_path: "source" + patch_file: "patches/9x-cmake.patch" diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py new file mode 100644 index 0000000000000..948ca2885473c --- /dev/null +++ b/recipes/llvm-core/all/conanfile.py @@ -0,0 +1,267 @@ +from conans.errors import ConanInvalidConfiguration +from conans import ConanFile, CMake, tools + +from pathlib import Path +import json +import re +import os + + +class LLVMCoreConan(ConanFile): + name = 'llvm-core' + description = ( + 'A toolkit for the construction of highly optimized compilers,' + 'optimizers, and runtime environments.' + ) + license = 'Apache-2.0 WITH LLVM-exception' + topics = ('conan', 'llvm') + homepage = 'https://github.com/llvm/llvm-project/tree/master/llvm' + url = 'https://github.com/conan-io/conan-center-index' + + settings = ('os', 'arch', 'compiler', 'build_type') + options = { + 'shared': [True, False], + 'fPIC': [True, False], + 'components': 'ANY', + 'targets': 'ANY', + 'exceptions': [True, False], + 'rtti': [True, False], + 'threads': [True, False], + 'lto': ['On', 'Off', 'Full', 'Thin'], + 'static_stdlib': [True, False], + 'unwind_tables': [True, False], + 'expensive_checks': [True, False], + 'use_perf': [True, False], + 'with_zlib': [True, False], + 'with_xml2': [True, False], + 'with_ffi': [True, False] + } + default_options = { + 'shared': False, + 'fPIC': True, + 'components': 'all', + 'targets': 'all', + 'exceptions': True, + 'rtti': True, + 'threads': True, + 'lto': 'Off', + 'static_stdlib': False, + 'unwind_tables': True, + 'expensive_checks': False, + 'use_perf': False, + 'with_zlib': True, + 'with_xml2': True, + 'with_ffi': False + } + + exports_sources = ['CMakeLists.txt', 'patches/*'] + generators = 'cmake' + no_copy_source = True + + _source_subfolder = 'source' + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + del self.options.components + del self.options.with_zlib + del self.options.with_xml2 + del self.options.with_ffi + + def requirements(self): + if self.options.get_safe('with_zlib', False): + self.requires('zlib/1.2.11') + if self.options.get_safe('with_xml2', False): + self.requires('libxml2/2.9.10') + if self.options.get_safe('with_ffi', False): + self.requires('libffi/3.3') + + def configure(self): + if self.settings.os == 'Windows' and self.options.shared: + raise ConanInvalidConfiguration('shared lib not supported') + if self.options.exceptions and not self.options.rtti: + raise ConanInvalidConfiguration('exceptions require rtti support') + + def source(self): + tools.get(**self.conan_data['sources'][self.version]) + source_path = Path(f'llvm-{self.version}.src') + source_path.rename(self._source_subfolder) + + if self.version in self.conan_data['patches']: + for patch in self.conan_data['patches'][self.version]: + tools.patch(**patch) + + def build(self): + if self.settings.compiler == 'Visual Studio': + generator = os.getenv('CONAN_CMAKE_GENERATOR', 'NMake Makefiles') + cmake = CMake(self, generator=generator) + else: + cmake = CMake(self) + + cmake.definitions['BUILD_SHARED_LIBS'] = False + cmake.definitions['CMAKE_SKIP_RPATH'] = True + + cmake.definitions['LLVM_TARGETS_TO_BUILD'] = self.options.targets + cmake.definitions['LLVM_TARGET_ARCH'] = 'host' + cmake.definitions['LLVM_BUILD_LLVM_DYLIB'] = self.options.shared + cmake.definitions['LLVM_ENABLE_PIC'] = \ + self.options.get_safe('fPIC', default=False) + cmake.definitions['LLVM_DYLIB_COMPONENTS'] = \ + self.options.get_safe('components', default='all') + + cmake.definitions['LLVM_ABI_BREAKING_CHECKS'] = 'WITH_ASSERTS' + cmake.definitions['LLVM_ENABLE_WARNINGS'] = True + cmake.definitions['LLVM_ENABLE_PEDANTIC'] = True + cmake.definitions['LLVM_ENABLE_WERROR'] = False + cmake.definitions['LLVM_ENABLE_LIBCXX'] = \ + 'clang' in str(self.settings.compiler) + + cmake.definitions['LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO'] = True + cmake.definitions['LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN'] = False + cmake.definitions['LLVM_BUILD_INSTRUMENTED_COVERAGE'] = False + cmake.definitions['LLVM_OPTIMIZED_TABLEGEN'] = True + cmake.definitions['LLVM_REVERSE_ITERATION'] = False + cmake.definitions['LLVM_ENABLE_BINDINGS'] = False + cmake.definitions['LLVM_CCACHE_BUILD'] = False + + cmake.definitions['LLVM_INCLUDE_TOOLS'] = self.options.shared + cmake.definitions['LLVM_INCLUDE_EXAMPLES'] = False + cmake.definitions['LLVM_INCLUDE_TESTS'] = False + cmake.definitions['LLVM_INCLUDE_BENCHMARKS'] = False + cmake.definitions['LLVM_APPEND_VC_REV'] = False + cmake.definitions['LLVM_BUILD_DOCS'] = False + cmake.definitions['LLVM_ENABLE_IDE'] = False + + cmake.definitions['LLVM_ENABLE_EH'] = self.options.exceptions + cmake.definitions['LLVM_ENABLE_RTTI'] = self.options.rtti + cmake.definitions['LLVM_ENABLE_THREADS'] = self.options.threads + cmake.definitions['LLVM_ENABLE_LTO'] = self.options.lto + cmake.definitions['LLVM_STATIC_LINK_CXX_STDLIB'] = \ + self.options.static_stdlib + cmake.definitions['LLVM_ENABLE_UNWIND_TABLES'] = \ + self.options.unwind_tables + cmake.definitions['LLVM_ENABLE_EXPENSIVE_CHECKS'] = \ + self.options.expensive_checks + cmake.definitions['LLVM_ENABLE_ASSERTIONS'] = \ + self.settings.build_type == 'Debug' + + cmake.definitions['LLVM_USE_NEWPM'] = False + cmake.definitions['LLVM_USE_OPROFILE'] = False + cmake.definitions['LLVM_USE_PERF'] = self.options.use_perf + + cmake.definitions['LLVM_ENABLE_Z3_SOLVER'] = False + cmake.definitions['LLVM_ENABLE_LIBPFM'] = False + cmake.definitions['LLVM_ENABLE_LIBEDIT'] = False + + cmake.definitions['LLVM_ENABLE_ZLIB'] = \ + self.options.get_safe('with_zlib', False) + cmake.definitions['LLVM_ENABLE_LIBXML2'] = \ + self.options.get_safe('with_xml2', False) + cmake.definitions['LLVM_ENABLE_FFI'] = \ + self.options.get_safe('with_ffi', False) + if self.options.get_safe('with_ffi', False): + cmake.definitions['FFI_INCLUDE_DIR'] = \ + self.deps_cpp_info['libffi'].include_paths[0] + cmake.definitions['FFI_LIBRARY_DIR'] = \ + self.deps_cpp_info['libffi'].lib_paths[0] + + cmake.configure() + cmake.build() + + def package(self): + self.copy('LICENSE.TXT', dst='licenses', src=self._source_subfolder) + package_path = Path(self.package_folder) + + if self.settings.compiler == 'Visual Studio': + generator = os.getenv('CONAN_CMAKE_GENERATOR', 'NMake Makefiles') + cmake = CMake(self, generator=generator) + else: + cmake = CMake(self) + cmake.install() + + if not self.options.shared: + lib_regex = re.compile( + r'add_library\((\w+?)\s.*?\)' + r'(?:(?:#|\w|\s|\()+?' + r'INTERFACE_LINK_LIBRARIES\s\"((?:;|:|/|\.|\w|\s|-|\(|\))+?)\"' + r'(?:.|\n)*?\))?' + ) + exports_file = 'LLVMExports.cmake' + exports_path = package_path.joinpath('lib', 'cmake', 'llvm') + exports_path = exports_path.joinpath(exports_file) + + exports = tools.load(str(exports_path.resolve())) + exports = exports.replace(r'\$', '') + + components = {} + for match in re.finditer(lib_regex, exports): + lib, deps = match.groups() + if not lib.startswith('LLVM'): + continue + + components[lib] = [] + for dep in deps.split(';') if deps is not None else []: + if Path(dep).exists(): + dep = Path(dep).stem.replace('lib', '') + elif dep.startswith('-delayload:'): + continue + components[lib].append(dep.replace('-l', '')) + + tools.rmdir(str(package_path.joinpath('bin').resolve())) + tools.rmdir(str(package_path.joinpath('lib', 'cmake').resolve())) + tools.rmdir(str(package_path.joinpath('share').resolve())) + + for file in package_path.joinpath('lib').iterdir(): + if 'LLVM' not in file.stem: + file.unlink() + + if not self.options.shared: + components_path = package_path.joinpath('lib', 'components.json') + with components_path.open(mode='w') as file: + json.dump(components, file, indent=4) + else: + for file in package_path.joinpath('lib').iterdir(): + for suffix in ['.dylib', '.so']: + if suffix not in file.suffixes: + file.unlink() + + def package_info(self): + if self.options.shared: + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.os == 'Linux': + self.cpp_info.system_libs = ['tinfo', 'pthread'] + self.cpp_info.system_libs.extend(['rt', 'dl', 'm']) + elif self.settings.os == 'Macos': + self.cpp_info.system_libs = ['curses', 'm'] + return + + package_path = Path(self.package_folder) + components_path = package_path.joinpath('lib', 'components.json') + with components_path.open(mode='r') as file: + components = json.load(file) + + dependencies = ['z', 'iconv', 'xml2', 'ffi'] + targets = { + 'z': 'zlib::zlib', + 'xml2': 'libxml2::libxml2', + 'ffi': 'libffi::libffi' + } + + for lib, deps in components.items(): + component = lib[4:].replace('LLVM', '').lower() + + self.cpp_info.components[component].libs = [lib] + + self.cpp_info.components[component].requires = [ + dep[4:].replace('LLVM', '').lower() + for dep in deps if dep.startswith('LLVM') + ] + for lib, target in targets.items(): + if lib in deps: + self.cpp_info.components[component].requires.append(target) + + self.cpp_info.components[component].system_libs = [ + dep for dep in deps + if not dep.startswith('LLVM') and dep not in dependencies + ] diff --git a/recipes/llvm-core/all/patches/10x-cmake.patch b/recipes/llvm-core/all/patches/10x-cmake.patch new file mode 100644 index 0000000000000..443c36f427761 --- /dev/null +++ b/recipes/llvm-core/all/patches/10x-cmake.patch @@ -0,0 +1,19 @@ +--- cmake/config-ix.cmake ++++ cmake/config-ix.cmake +@@ -166,6 +166,7 @@ + else() + include_directories(${LIBXML2_INCLUDE_DIR}) + endif() ++ set(LIBXML2_LIBS "xml2;iconv;z") + endif() + endif() + endif() +@@ -319,7 +319,7 @@ + message(FATAL_ERROR "libffi includes are not found.") + endif() + +- find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR}) ++ find_library(FFI_LIBRARY_PATH NAMES ffi libffi PATHS ${FFI_LIBRARY_DIR}) + if( NOT FFI_LIBRARY_PATH ) + message(FATAL_ERROR "libffi is not found.") + endif() diff --git a/recipes/llvm-core/all/patches/10x-vs2019.patch b/recipes/llvm-core/all/patches/10x-vs2019.patch new file mode 100644 index 0000000000000..e02e6bf853b21 --- /dev/null +++ b/recipes/llvm-core/all/patches/10x-vs2019.patch @@ -0,0 +1,11 @@ +--- include/llvm/Support/type_traits.h ++++ include/llvm/Support/type_traits.h +@@ -177,7 +177,7 @@ + (has_deleted_copy_assign || has_trivial_copy_assign) && + (has_deleted_copy_constructor || has_trivial_copy_constructor); + +-#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE ++#if 0 + static_assert(value == std::is_trivially_copyable::value, + "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); + #endif diff --git a/recipes/llvm-core/all/patches/11x-cmake.patch b/recipes/llvm-core/all/patches/11x-cmake.patch new file mode 100644 index 0000000000000..386ca6ac3eeba --- /dev/null +++ b/recipes/llvm-core/all/patches/11x-cmake.patch @@ -0,0 +1,19 @@ +--- cmake/config-ix.cmake ++++ cmake/config-ix.cmake +@@ -166,6 +166,7 @@ + else() + include_directories(${LIBXML2_INCLUDE_DIR}) + endif() ++ set(LIBXML2_LIBS "xml2;iconv;z") + endif() + endif() + endif() +@@ -321,7 +321,7 @@ + message(FATAL_ERROR "libffi includes are not found.") + endif() + +- find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR}) ++ find_library(FFI_LIBRARY_PATH NAMES ffi libffi PATHS ${FFI_LIBRARY_DIR}) + if( NOT FFI_LIBRARY_PATH ) + message(FATAL_ERROR "libffi is not found.") + endif() diff --git a/recipes/llvm-core/all/patches/11x-vs2019.patch b/recipes/llvm-core/all/patches/11x-vs2019.patch new file mode 100644 index 0000000000000..509261ff3794d --- /dev/null +++ b/recipes/llvm-core/all/patches/11x-vs2019.patch @@ -0,0 +1,11 @@ +--- include/llvm/Support/type_traits.h ++++ include/llvm/Support/type_traits.h +@@ -176,7 +176,7 @@ + (has_deleted_copy_assign || has_trivial_copy_assign) && + (has_deleted_copy_constructor || has_trivial_copy_constructor); + +-#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE ++#if 0 + static_assert(value == std::is_trivially_copyable::value, + "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); + #endif diff --git a/recipes/llvm-core/all/patches/9x-cmake.patch b/recipes/llvm-core/all/patches/9x-cmake.patch new file mode 100644 index 0000000000000..925c4d4096c6e --- /dev/null +++ b/recipes/llvm-core/all/patches/9x-cmake.patch @@ -0,0 +1,20 @@ +--- cmake/config-ix.cmake ++++ cmake/config-ix.cmake +@@ -166,7 +166,7 @@ + else() + include_directories(${LIBXML2_INCLUDE_DIR}) + endif() +- set(LIBXML2_LIBS "xml2") ++ set(LIBXML2_LIBS "xml2;iconv;z") + endif() + endif() + endif() +@@ -320,7 +320,7 @@ + message(FATAL_ERROR "libffi includes are not found.") + endif() + +- find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR}) ++ find_library(FFI_LIBRARY_PATH NAMES ffi libffi PATHS ${FFI_LIBRARY_DIR}) + if( NOT FFI_LIBRARY_PATH ) + message(FATAL_ERROR "libffi is not found.") + endif() diff --git a/recipes/llvm-core/all/patches/9x-vs2019.patch b/recipes/llvm-core/all/patches/9x-vs2019.patch new file mode 100644 index 0000000000000..a74a4f792ccdd --- /dev/null +++ b/recipes/llvm-core/all/patches/9x-vs2019.patch @@ -0,0 +1,11 @@ +--- include/llvm/Support/type_traits.h ++++ include/llvm/Support/type_traits.h +@@ -182,7 +182,7 @@ + (has_deleted_copy_assign || has_trivial_copy_assign) && + (has_deleted_copy_constructor || has_trivial_copy_constructor); + +-#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE ++#if 0 + static_assert(value == std::is_trivially_copyable::value, + "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); + #endif diff --git a/recipes/llvm-core/all/readme.md b/recipes/llvm-core/all/readme.md new file mode 100644 index 0000000000000..85f1becb48342 --- /dev/null +++ b/recipes/llvm-core/all/readme.md @@ -0,0 +1,9 @@ +## Conan package for [LLVM](https://github.com/llvm/llvm-project) + +This is a package for just the core libraries, not the compiler nor any of the **clang**-based tools. + +🚧 Currently under development... 🚧 + +**Copyright (c):** 2020 Alberto Lorenzo Márquez. + +**License:** MIT (see `../license.txt`). diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3bb3833284c71 --- /dev/null +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.14) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(llvm-core) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) + +if(TARGET llvm-core::interpreter) # static libraries + target_link_libraries(${PROJECT_NAME} PRIVATE + llvm-core::interpreter + llvm-core::irreader + llvm-core::x86codegen + ) +else() # shared library + target_link_libraries(${PROJECT_NAME} llvm-core::llvm-core) +endif() diff --git a/recipes/llvm-core/all/test_package/conanfile.py b/recipes/llvm-core/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e77a1f748071a --- /dev/null +++ b/recipes/llvm-core/all/test_package/conanfile.py @@ -0,0 +1,38 @@ +from conans import ConanFile, CMake, tools + +from pathlib import Path + + +class LLVMTestPackageConan(ConanFile): + settings = ('os', 'arch', 'compiler', 'build_type') + generators = ('cmake', 'cmake_find_package') + + def build(self): + build_system = CMake(self) + build_system.configure() + build_system.build() + + def test(self): + test_package = not tools.cross_building(self.settings) + if 'x86' not in str(self.settings.arch).lower(): + test_package = False + elif str(self.options['llvm-core'].targets) not in ['all', 'X86']: + test_package = False + elif self.options['llvm-core'].shared: + if self.options['llvm-core'].components != 'all': + requirements = ['interpreter', 'irreader', 'x86codegen'] + targets = str(self.options['llvm-core'].components) + if self.settings.os == 'Windows': + requirements.append('demangle') + if not all([target in components for target in requirements]): + test_package = False + + if test_package: + executable = Path('bin').joinpath('test_package') + input = Path(__file__).parent.joinpath('test_function.ll') + command = [str(file.resolve()) for file in (executable, input)] + self.run(command, run_environment=True) + + llvm_path = Path(self.deps_cpp_info['llvm-core'].rootpath) + license_file = llvm_path.joinpath('licenses', 'LICENSE.TXT') + assert license_file.exists() diff --git a/recipes/llvm-core/all/test_package/test_function.ll b/recipes/llvm-core/all/test_package/test_function.ll new file mode 100644 index 0000000000000..6e62088cd308d --- /dev/null +++ b/recipes/llvm-core/all/test_package/test_function.ll @@ -0,0 +1,6 @@ +@.str = private unnamed_addr constant [25 x i8] c"LLVM IR interpreter ok!\0A\00", align 1 +define i32 @test() #0 { + call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0)) + ret i32 0 +} +declare i32 @printf(i8*, ...) #1 diff --git a/recipes/llvm-core/all/test_package/test_package.cpp b/recipes/llvm-core/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..e5de3a64aa80d --- /dev/null +++ b/recipes/llvm-core/all/test_package/test_package.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include +#include +#include + +#include + + +int main(int argc, char const* argv[]) { + if (argc < 2) + return 0; + + llvm::InitializeNativeTarget(); + llvm::SMDiagnostic smd; + llvm::LLVMContext context; + std::string error; + + llvm::EngineBuilder engine_builder{ + llvm::parseIRFile(argv[1], smd, context) + }; + engine_builder.setEngineKind(llvm::EngineKind::Interpreter); + engine_builder.setErrorStr(&error); + + auto execution_engine = std::unique_ptr( + engine_builder.create() + ); + execution_engine->runStaticConstructorsDestructors(false); + + auto test_function = execution_engine->FindFunctionNamed("test"); + auto result = execution_engine->runFunction( + test_function, + llvm::ArrayRef() + ); + return result.IntVal.getSExtValue(); +} diff --git a/recipes/llvm-core/config.yml b/recipes/llvm-core/config.yml new file mode 100644 index 0000000000000..d1127a6c7c2dd --- /dev/null +++ b/recipes/llvm-core/config.yml @@ -0,0 +1,12 @@ +versions: + "11.0.0": + folder: all + + "10.0.1": + folder: all + + "10.0.0": + folder: all + + "9.0.1": + folder: all From 8e4e4d0fd0c6d5f9139e8c89844dd5fce1a83174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sun, 1 Nov 2020 16:23:50 +0100 Subject: [PATCH 02/37] Reuse cmake configuration --- recipes/llvm-core/all/conanfile.py | 73 +++++++++++++++--------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 948ca2885473c..8b7f0bf82387d 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -60,38 +60,7 @@ class LLVMCoreConan(ConanFile): _source_subfolder = 'source' - def config_options(self): - if self.settings.os == 'Windows': - del self.options.fPIC - del self.options.components - del self.options.with_zlib - del self.options.with_xml2 - del self.options.with_ffi - - def requirements(self): - if self.options.get_safe('with_zlib', False): - self.requires('zlib/1.2.11') - if self.options.get_safe('with_xml2', False): - self.requires('libxml2/2.9.10') - if self.options.get_safe('with_ffi', False): - self.requires('libffi/3.3') - - def configure(self): - if self.settings.os == 'Windows' and self.options.shared: - raise ConanInvalidConfiguration('shared lib not supported') - if self.options.exceptions and not self.options.rtti: - raise ConanInvalidConfiguration('exceptions require rtti support') - - def source(self): - tools.get(**self.conan_data['sources'][self.version]) - source_path = Path(f'llvm-{self.version}.src') - source_path.rename(self._source_subfolder) - - if self.version in self.conan_data['patches']: - for patch in self.conan_data['patches'][self.version]: - tools.patch(**patch) - - def build(self): + def _configure_cmake(self): if self.settings.compiler == 'Visual Studio': generator = os.getenv('CONAN_CMAKE_GENERATOR', 'NMake Makefiles') cmake = CMake(self, generator=generator) @@ -164,7 +133,41 @@ def build(self): self.deps_cpp_info['libffi'].include_paths[0] cmake.definitions['FFI_LIBRARY_DIR'] = \ self.deps_cpp_info['libffi'].lib_paths[0] + return cmake + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + del self.options.components + del self.options.with_zlib + del self.options.with_xml2 + del self.options.with_ffi + + def requirements(self): + if self.options.get_safe('with_zlib', False): + self.requires('zlib/1.2.11') + if self.options.get_safe('with_xml2', False): + self.requires('libxml2/2.9.10') + if self.options.get_safe('with_ffi', False): + self.requires('libffi/3.3') + + def configure(self): + if self.settings.os == 'Windows' and self.options.shared: + raise ConanInvalidConfiguration('shared lib not supported') + if self.options.exceptions and not self.options.rtti: + raise ConanInvalidConfiguration('exceptions require rtti support') + + def source(self): + tools.get(**self.conan_data['sources'][self.version]) + source_path = Path(f'llvm-{self.version}.src') + source_path.rename(self._source_subfolder) + + if self.version in self.conan_data['patches']: + for patch in self.conan_data['patches'][self.version]: + tools.patch(**patch) + + def build(self): + cmake = self._configure_cmake() cmake.configure() cmake.build() @@ -172,11 +175,7 @@ def package(self): self.copy('LICENSE.TXT', dst='licenses', src=self._source_subfolder) package_path = Path(self.package_folder) - if self.settings.compiler == 'Visual Studio': - generator = os.getenv('CONAN_CMAKE_GENERATOR', 'NMake Makefiles') - cmake = CMake(self, generator=generator) - else: - cmake = CMake(self) + cmake = self._configure_cmake() cmake.install() if not self.options.shared: From daa072ba50ac0f2d8b1db9e3741d77e939dc1e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sun, 1 Nov 2020 23:33:10 +0100 Subject: [PATCH 03/37] Fix shared builds for 10x and 11x --- recipes/llvm-core/all/conanfile.py | 6 ++--- recipes/llvm-core/all/patches/10x-cmake.patch | 22 ++++++++++++++++++- recipes/llvm-core/all/patches/11x-cmake.patch | 22 ++++++++++++++++++- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 8b7f0bf82387d..adc49b368d21a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -220,10 +220,10 @@ def package(self): with components_path.open(mode='w') as file: json.dump(components, file, indent=4) else: + suffixes = ['.dylib', '.so'] for file in package_path.joinpath('lib').iterdir(): - for suffix in ['.dylib', '.so']: - if suffix not in file.suffixes: - file.unlink() + if not any(suffix in file.suffixes for suffix in suffixes): + file.unlink() def package_info(self): if self.options.shared: diff --git a/recipes/llvm-core/all/patches/10x-cmake.patch b/recipes/llvm-core/all/patches/10x-cmake.patch index 443c36f427761..aa860c8a07440 100644 --- a/recipes/llvm-core/all/patches/10x-cmake.patch +++ b/recipes/llvm-core/all/patches/10x-cmake.patch @@ -4,7 +4,7 @@ else() include_directories(${LIBXML2_INCLUDE_DIR}) endif() -+ set(LIBXML2_LIBS "xml2;iconv;z") ++ set(LIBXML2_LIBRARIES "xml2;iconv;z") endif() endif() endif() @@ -17,3 +17,23 @@ if( NOT FFI_LIBRARY_PATH ) message(FATAL_ERROR "libffi is not found.") endif() +--- lib/WindowsManifest/CMakeLists.txt ++++ lib/WindowsManifest/CMakeLists.txt +@@ -8,16 +8,6 @@ + if(LIBXML2_LIBRARIES) + target_link_libraries(LLVMWindowsManifest PUBLIC ${LIBXML2_LIBRARIES}) + +- get_filename_component(xml2_library ${LIBXML2_LIBRARIES} NAME) +- if (CMAKE_STATIC_LIBRARY_PREFIX AND +- xml2_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*${CMAKE_STATIC_LIBRARY_SUFFIX}$") +- string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" xml2_library ${xml2_library}) +- string(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library}) +- elseif (CMAKE_SHARED_LIBRARY_PREFIX AND +- xml2_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$") +- string(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" xml2_library ${xml2_library}) +- string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library}) +- endif() + set_property(TARGET LLVMWindowsManifest PROPERTY +- LLVM_SYSTEM_LIBS ${xml2_library}) ++ LLVM_SYSTEM_LIBS ${LIBXML2_LIBRARIES}) + endif() diff --git a/recipes/llvm-core/all/patches/11x-cmake.patch b/recipes/llvm-core/all/patches/11x-cmake.patch index 386ca6ac3eeba..7c6a045c97abd 100644 --- a/recipes/llvm-core/all/patches/11x-cmake.patch +++ b/recipes/llvm-core/all/patches/11x-cmake.patch @@ -4,7 +4,7 @@ else() include_directories(${LIBXML2_INCLUDE_DIR}) endif() -+ set(LIBXML2_LIBS "xml2;iconv;z") ++ set(LIBXML2_LIBRARIES "xml2;iconv;z") endif() endif() endif() @@ -17,3 +17,23 @@ if( NOT FFI_LIBRARY_PATH ) message(FATAL_ERROR "libffi is not found.") endif() +--- lib/WindowsManifest/CMakeLists.txt ++++ lib/WindowsManifest/CMakeLists.txt +@@ -8,16 +8,6 @@ + if(LIBXML2_LIBRARIES) + target_link_libraries(LLVMWindowsManifest PUBLIC ${LIBXML2_LIBRARIES}) + +- get_filename_component(xml2_library ${LIBXML2_LIBRARIES} NAME) +- if (CMAKE_STATIC_LIBRARY_PREFIX AND +- xml2_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*${CMAKE_STATIC_LIBRARY_SUFFIX}$") +- string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" xml2_library ${xml2_library}) +- string(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library}) +- elseif (CMAKE_SHARED_LIBRARY_PREFIX AND +- xml2_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$") +- string(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" xml2_library ${xml2_library}) +- string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library}) +- endif() + set_property(TARGET LLVMWindowsManifest PROPERTY +- LLVM_SYSTEM_LIBS ${xml2_library}) ++ LLVM_SYSTEM_LIBS ${LIBXML2_LIBRARIES}) + endif() From b7359989d599067effe5a00aa1f607d27e76e0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Mon, 2 Nov 2020 12:41:29 +0100 Subject: [PATCH 04/37] Parse dependencies from graphviz output --- recipes/llvm-core/all/conanfile.py | 42 ++++++++++++------------------ 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index adc49b368d21a..f1a819bbdd3da 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -2,6 +2,7 @@ from conans import ConanFile, CMake, tools from pathlib import Path +from collections import defaultdict import json import re import os @@ -179,33 +180,24 @@ def package(self): cmake.install() if not self.options.shared: - lib_regex = re.compile( - r'add_library\((\w+?)\s.*?\)' - r'(?:(?:#|\w|\s|\()+?' - r'INTERFACE_LINK_LIBRARIES\s\"((?:;|:|/|\.|\w|\s|-|\(|\))+?)\"' - r'(?:.|\n)*?\))?' - ) - exports_file = 'LLVMExports.cmake' - exports_path = package_path.joinpath('lib', 'cmake', 'llvm') - exports_path = exports_path.joinpath(exports_file) - - exports = tools.load(str(exports_path.resolve())) - exports = exports.replace(r'\$', '') - - components = {} - for match in re.finditer(lib_regex, exports): - lib, deps = match.groups() + self.run('cmake --graphviz=graph/llvm.dot .') + with tools.chdir('graph'): + dot_text = tools.load('llvm.dot').replace(' ', '') + + dep_regex = re.compile(r'//(.+)->(.+)$', re.MULTILINE) + deps = re.findall(dep_regex, dot_text) + + components = defaultdict(list) + for lib, dep in deps: if not lib.startswith('LLVM'): continue - - components[lib] = [] - for dep in deps.split(';') if deps is not None else []: - if Path(dep).exists(): - dep = Path(dep).stem.replace('lib', '') - elif dep.startswith('-delayload:'): - continue - components[lib].append(dep.replace('-l', '')) + elif dep.startswith('llvm-') or dep.startswith('-delayload:'): + continue + elif dep.startswith('LLVM'): + components[dep] + elif Path(dep).exists(): + dep = Path(dep).stem.replace('lib', '') + components[lib].append(dep.replace('-l', '')) tools.rmdir(str(package_path.joinpath('bin').resolve())) tools.rmdir(str(package_path.joinpath('lib', 'cmake').resolve())) From edf9abc90db8dfa5ca1a626d7ed5a8a9e4f0b479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Mon, 2 Nov 2020 20:22:18 +0100 Subject: [PATCH 05/37] Beware of dummy targets --- recipes/llvm-core/all/conanfile.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index f1a819bbdd3da..efd0d83e2221c 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -182,22 +182,33 @@ def package(self): if not self.options.shared: self.run('cmake --graphviz=graph/llvm.dot .') with tools.chdir('graph'): - dot_text = tools.load('llvm.dot').replace(' ', '') + dot_text = tools.load('llvm.dot') - dep_regex = re.compile(r'//(.+)->(.+)$', re.MULTILINE) + dep_regex = re.compile(r'//\s(.+)\s->\s(.+)$', re.MULTILINE) deps = re.findall(dep_regex, dot_text) + dummy_targets = defaultdict(list) + for target, dep in deps: + if not target.startswith('LLVM') and not dep.startswith('obj'): + dummy_targets[target].append(dep) + components = defaultdict(list) for lib, dep in deps: if not lib.startswith('LLVM'): continue - elif dep.startswith('llvm-') or dep.startswith('-delayload:'): + elif dep.startswith('-delayload:'): continue elif dep.startswith('LLVM'): components[dep] elif Path(dep).exists(): dep = Path(dep).stem.replace('lib', '') - components[lib].append(dep.replace('-l', '')) + dep = dep.replace('-l', '') + + if dep in dummy_targets.keys(): + components[lib].extend(dummy_targets[dep]) + components[lib] = list(set(components[lib])) + else: + components[lib].append(dep) tools.rmdir(str(package_path.joinpath('bin').resolve())) tools.rmdir(str(package_path.joinpath('lib', 'cmake').resolve())) From aebb740c66bfa41e6b19ae382904d35f70ad69ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Mon, 2 Nov 2020 20:38:23 +0100 Subject: [PATCH 06/37] Keep only latest version for the moment --- recipes/llvm-core/all/conandata.yml | 29 -------------- recipes/llvm-core/all/patches/10x-cmake.patch | 39 ------------------- .../llvm-core/all/patches/10x-vs2019.patch | 11 ------ recipes/llvm-core/all/patches/9x-cmake.patch | 20 ---------- recipes/llvm-core/all/patches/9x-vs2019.patch | 11 ------ recipes/llvm-core/config.yml | 9 ----- 6 files changed, 119 deletions(-) delete mode 100644 recipes/llvm-core/all/patches/10x-cmake.patch delete mode 100644 recipes/llvm-core/all/patches/10x-vs2019.patch delete mode 100644 recipes/llvm-core/all/patches/9x-cmake.patch delete mode 100644 recipes/llvm-core/all/patches/9x-vs2019.patch diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 1a40e960cf167..0a38045341f20 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -3,18 +3,6 @@ sources: url: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/llvm-11.0.0.src.tar.xz sha256: 913f68c898dfb4a03b397c5e11c6a2f39d0f22ed7665c9cefa87a34423a72469 - "10.0.1": - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/llvm-10.0.1.src.tar.xz - sha256: c5d8e30b57cbded7128d78e5e8dad811bff97a8d471896812f57fa99ee82cdf3 - - "10.0.0": - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/llvm-10.0.0.src.tar.xz - sha256: df83a44b3a9a71029049ec101fb0077ecbbdf5fe41e395215025779099a98fdf - - "9.0.1": - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-9.0.1/llvm-9.0.1.src.tar.xz - sha256: 00a1ee1f389f81e9979f3a640a01c431b3021de0d42278f6508391a2f0b81c9a - patches: "11.0.0": - base_path: "source" @@ -22,20 +10,3 @@ patches: - base_path: "source" patch_file: "patches/11x-cmake.patch" - "10.0.1": - - base_path: "source" - patch_file: "patches/10x-vs2019.patch" - - base_path: "source" - patch_file: "patches/10x-cmake.patch" - - "10.0.0": - - base_path: "source" - patch_file: "patches/10x-vs2019.patch" - - base_path: "source" - patch_file: "patches/10x-cmake.patch" - - "9.0.1": - - base_path: "source" - patch_file: "patches/9x-vs2019.patch" - - base_path: "source" - patch_file: "patches/9x-cmake.patch" diff --git a/recipes/llvm-core/all/patches/10x-cmake.patch b/recipes/llvm-core/all/patches/10x-cmake.patch deleted file mode 100644 index aa860c8a07440..0000000000000 --- a/recipes/llvm-core/all/patches/10x-cmake.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- cmake/config-ix.cmake -+++ cmake/config-ix.cmake -@@ -166,6 +166,7 @@ - else() - include_directories(${LIBXML2_INCLUDE_DIR}) - endif() -+ set(LIBXML2_LIBRARIES "xml2;iconv;z") - endif() - endif() - endif() -@@ -319,7 +319,7 @@ - message(FATAL_ERROR "libffi includes are not found.") - endif() - -- find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR}) -+ find_library(FFI_LIBRARY_PATH NAMES ffi libffi PATHS ${FFI_LIBRARY_DIR}) - if( NOT FFI_LIBRARY_PATH ) - message(FATAL_ERROR "libffi is not found.") - endif() ---- lib/WindowsManifest/CMakeLists.txt -+++ lib/WindowsManifest/CMakeLists.txt -@@ -8,16 +8,6 @@ - if(LIBXML2_LIBRARIES) - target_link_libraries(LLVMWindowsManifest PUBLIC ${LIBXML2_LIBRARIES}) - -- get_filename_component(xml2_library ${LIBXML2_LIBRARIES} NAME) -- if (CMAKE_STATIC_LIBRARY_PREFIX AND -- xml2_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*${CMAKE_STATIC_LIBRARY_SUFFIX}$") -- string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" xml2_library ${xml2_library}) -- string(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library}) -- elseif (CMAKE_SHARED_LIBRARY_PREFIX AND -- xml2_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$") -- string(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" xml2_library ${xml2_library}) -- string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "" xml2_library ${xml2_library}) -- endif() - set_property(TARGET LLVMWindowsManifest PROPERTY -- LLVM_SYSTEM_LIBS ${xml2_library}) -+ LLVM_SYSTEM_LIBS ${LIBXML2_LIBRARIES}) - endif() diff --git a/recipes/llvm-core/all/patches/10x-vs2019.patch b/recipes/llvm-core/all/patches/10x-vs2019.patch deleted file mode 100644 index e02e6bf853b21..0000000000000 --- a/recipes/llvm-core/all/patches/10x-vs2019.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- include/llvm/Support/type_traits.h -+++ include/llvm/Support/type_traits.h -@@ -177,7 +177,7 @@ - (has_deleted_copy_assign || has_trivial_copy_assign) && - (has_deleted_copy_constructor || has_trivial_copy_constructor); - --#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE -+#if 0 - static_assert(value == std::is_trivially_copyable::value, - "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); - #endif diff --git a/recipes/llvm-core/all/patches/9x-cmake.patch b/recipes/llvm-core/all/patches/9x-cmake.patch deleted file mode 100644 index 925c4d4096c6e..0000000000000 --- a/recipes/llvm-core/all/patches/9x-cmake.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- cmake/config-ix.cmake -+++ cmake/config-ix.cmake -@@ -166,7 +166,7 @@ - else() - include_directories(${LIBXML2_INCLUDE_DIR}) - endif() -- set(LIBXML2_LIBS "xml2") -+ set(LIBXML2_LIBS "xml2;iconv;z") - endif() - endif() - endif() -@@ -320,7 +320,7 @@ - message(FATAL_ERROR "libffi includes are not found.") - endif() - -- find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR}) -+ find_library(FFI_LIBRARY_PATH NAMES ffi libffi PATHS ${FFI_LIBRARY_DIR}) - if( NOT FFI_LIBRARY_PATH ) - message(FATAL_ERROR "libffi is not found.") - endif() diff --git a/recipes/llvm-core/all/patches/9x-vs2019.patch b/recipes/llvm-core/all/patches/9x-vs2019.patch deleted file mode 100644 index a74a4f792ccdd..0000000000000 --- a/recipes/llvm-core/all/patches/9x-vs2019.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- include/llvm/Support/type_traits.h -+++ include/llvm/Support/type_traits.h -@@ -182,7 +182,7 @@ - (has_deleted_copy_assign || has_trivial_copy_assign) && - (has_deleted_copy_constructor || has_trivial_copy_constructor); - --#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE -+#if 0 - static_assert(value == std::is_trivially_copyable::value, - "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); - #endif diff --git a/recipes/llvm-core/config.yml b/recipes/llvm-core/config.yml index d1127a6c7c2dd..17553290ebe68 100644 --- a/recipes/llvm-core/config.yml +++ b/recipes/llvm-core/config.yml @@ -1,12 +1,3 @@ versions: "11.0.0": folder: all - - "10.0.1": - folder: all - - "10.0.0": - folder: all - - "9.0.1": - folder: all From 6fdd6a6419471f2925c89ce7d62fa77d46293e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Tue, 3 Nov 2020 13:30:22 +0100 Subject: [PATCH 07/37] Beware of Windows line endings --- recipes/llvm-core/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index efd0d83e2221c..d1cbf1d70c1a2 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -182,7 +182,7 @@ def package(self): if not self.options.shared: self.run('cmake --graphviz=graph/llvm.dot .') with tools.chdir('graph'): - dot_text = tools.load('llvm.dot') + dot_text = tools.load('llvm.dot').replace('\r\n', '\n') dep_regex = re.compile(r'//\s(.+)\s->\s(.+)$', re.MULTILINE) deps = re.findall(dep_regex, dot_text) From 00c52c8cdb03e2c610b81246bbb423b77d9e5cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Tue, 3 Nov 2020 15:11:55 +0100 Subject: [PATCH 08/37] Relax cmake version requirement --- recipes/llvm-core/all/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/CMakeLists.txt b/recipes/llvm-core/all/CMakeLists.txt index 71ba86b5911da..ea021e07508d8 100644 --- a/recipes/llvm-core/all/CMakeLists.txt +++ b/recipes/llvm-core/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.4.3) project(conanllvm) message(STATUS "Conan CMake Wrapper") From 41562aa12833ac622813743158cf350318be5c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Tue, 3 Nov 2020 16:02:12 +0100 Subject: [PATCH 09/37] Add list of unsupported compiler configurations --- recipes/llvm-core/all/conanfile.py | 40 +++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index d1cbf1d70c1a2..cd29a5e3135fd 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -61,6 +61,40 @@ class LLVMCoreConan(ConanFile): _source_subfolder = 'source' + def _supports_compiler(self): + compiler_version = tools.Version(self.settings.compiler.version) + compiler = self.settings.compiler.value + unsupported_combinations = [ + [ + compiler == 'gcc', + compiler_version.major == '5', + compiler_version.minor < '1' + ], + [ + compiler == 'gcc', + compiler_version.major < '5' + ], + [ + compiler == 'Visual Studio', + compiler_version.major == '16', + compiler_version.minor < '5' + ], + [ + compiler == 'Visual Studio', + compiler_version.major < '15' + ] + ] + if any(all(combination) for combination in unsupported_combinations): + raise ConanInvalidConfiguration( + 'unsupported compiler: "{}", version "{}"' + .format(compiler, compiler_version) + ) + + def _patch_sources(self): + if self.version in self.conan_data['patches']: + for patch in self.conan_data['patches'][self.version]: + tools.patch(**patch) + def _configure_cmake(self): if self.settings.compiler == 'Visual Studio': generator = os.getenv('CONAN_CMAKE_GENERATOR', 'NMake Makefiles') @@ -157,15 +191,13 @@ def configure(self): raise ConanInvalidConfiguration('shared lib not supported') if self.options.exceptions and not self.options.rtti: raise ConanInvalidConfiguration('exceptions require rtti support') + self._supports_compiler() def source(self): tools.get(**self.conan_data['sources'][self.version]) source_path = Path(f'llvm-{self.version}.src') source_path.rename(self._source_subfolder) - - if self.version in self.conan_data['patches']: - for patch in self.conan_data['patches'][self.version]: - tools.patch(**patch) + self._patch_sources() def build(self): cmake = self._configure_cmake() From d87652120562732d94fb663d027c6bfac1e4c0f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Tue, 3 Nov 2020 20:44:57 +0100 Subject: [PATCH 10/37] Commit suggestion Co-authored-by: Yoann Potinet --- recipes/llvm-core/all/conanfile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index cd29a5e3135fd..5ce931d390507 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -91,9 +91,8 @@ def _supports_compiler(self): ) def _patch_sources(self): - if self.version in self.conan_data['patches']: - for patch in self.conan_data['patches'][self.version]: - tools.patch(**patch) + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) def _configure_cmake(self): if self.settings.compiler == 'Visual Studio': From 9cb727415e7e4405d12d2755a7894368c7a0c085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Wed, 4 Nov 2020 09:39:53 +0100 Subject: [PATCH 11/37] Cannot discriminate Visual Studio by its minor version Visual Studio version 16.4, which is known by miscompiling LLVM, is currently being used by conan-center-index's CCI. Let's use LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN to make that compilation pass until Visual Studio is upgraded. --- recipes/llvm-core/all/conanfile.py | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 5ce931d390507..32c57fe1f41ff 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -62,42 +62,29 @@ class LLVMCoreConan(ConanFile): _source_subfolder = 'source' def _supports_compiler(self): - compiler_version = tools.Version(self.settings.compiler.version) compiler = self.settings.compiler.value + version = tools.Version(self.settings.compiler.version) unsupported_combinations = [ - [ - compiler == 'gcc', - compiler_version.major == '5', - compiler_version.minor < '1' - ], - [ - compiler == 'gcc', - compiler_version.major < '5' - ], - [ - compiler == 'Visual Studio', - compiler_version.major == '16', - compiler_version.minor < '5' - ], - [ - compiler == 'Visual Studio', - compiler_version.major < '15' - ] + [compiler == 'gcc', version.major == '5', version.minor < '1'], + [compiler == 'gcc', version.major < '5'], + [compiler == 'Visual Studio', version.major < '15'] ] + if any(all(combination) for combination in unsupported_combinations): raise ConanInvalidConfiguration( 'unsupported compiler: "{}", version "{}"' - .format(compiler, compiler_version) + .format(compiler, version) ) def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): + for patch in self.conan_data.get('patches', {}).get(self.version, []): tools.patch(**patch) def _configure_cmake(self): if self.settings.compiler == 'Visual Studio': generator = os.getenv('CONAN_CMAKE_GENERATOR', 'NMake Makefiles') cmake = CMake(self, generator=generator) + cmake.definitions['LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN'] = True else: cmake = CMake(self) From d8286db26a2b59e53b74a3c67cadadf477439fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Wed, 4 Nov 2020 10:24:21 +0100 Subject: [PATCH 12/37] Disable object targets properly --- recipes/llvm-core/all/conanfile.py | 2 +- recipes/llvm-core/all/patches/11x-cmake.patch | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 32c57fe1f41ff..24b9914b7ce10 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -207,7 +207,7 @@ def package(self): dummy_targets = defaultdict(list) for target, dep in deps: - if not target.startswith('LLVM') and not dep.startswith('obj'): + if not target.startswith('LLVM'): dummy_targets[target].append(dep) components = defaultdict(list) diff --git a/recipes/llvm-core/all/patches/11x-cmake.patch b/recipes/llvm-core/all/patches/11x-cmake.patch index 7c6a045c97abd..7d36ccb560b6d 100644 --- a/recipes/llvm-core/all/patches/11x-cmake.patch +++ b/recipes/llvm-core/all/patches/11x-cmake.patch @@ -17,6 +17,22 @@ if( NOT FFI_LIBRARY_PATH ) message(FATAL_ERROR "libffi is not found.") endif() +--- cmake/modules/TableGen.cmake ++++ cmake/modules/TableGen.cmake +@@ -138,12 +138,7 @@ + macro(add_tablegen target project) + set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS}) + set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen) +- +- # CMake-3.9 doesn't let compilation units depend on their dependent libraries. +- if(NOT (CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_VERSION VERSION_LESS 3.9) AND NOT XCODE) +- # FIXME: It leaks to user, callee of add_tablegen. +- set(LLVM_ENABLE_OBJLIB ON) +- endif() ++ set(LLVM_ENABLE_OBJLIB OFF) + + add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) + set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) --- lib/WindowsManifest/CMakeLists.txt +++ lib/WindowsManifest/CMakeLists.txt @@ -8,16 +8,6 @@ From b9347dab87004303fcc39ae8b0e7748e155cc034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Thu, 5 Nov 2020 15:21:51 +0100 Subject: [PATCH 13/37] Use external dependencies properly --- recipes/llvm-core/all/conanfile.py | 30 ++++++++++++++----- recipes/llvm-core/all/patches/11x-cmake.patch | 20 +++++++------ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 24b9914b7ce10..61a24f2ea7978 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -56,7 +56,7 @@ class LLVMCoreConan(ConanFile): } exports_sources = ['CMakeLists.txt', 'patches/*'] - generators = 'cmake' + generators = ['cmake', 'cmake_find_package'] no_copy_source = True _source_subfolder = 'source' @@ -106,8 +106,10 @@ def _configure_cmake(self): cmake.definitions['LLVM_ENABLE_LIBCXX'] = \ 'clang' in str(self.settings.compiler) - cmake.definitions['LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO'] = True + # TODO: Temporary hack, it needs to be fixed from outside the recipe. cmake.definitions['LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN'] = False + + cmake.definitions['LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO'] = True cmake.definitions['LLVM_BUILD_INSTRUMENTED_COVERAGE'] = False cmake.definitions['LLVM_OPTIMIZED_TABLEGEN'] = True cmake.definitions['LLVM_REVERSE_ITERATION'] = False @@ -142,18 +144,12 @@ def _configure_cmake(self): cmake.definitions['LLVM_ENABLE_Z3_SOLVER'] = False cmake.definitions['LLVM_ENABLE_LIBPFM'] = False cmake.definitions['LLVM_ENABLE_LIBEDIT'] = False - cmake.definitions['LLVM_ENABLE_ZLIB'] = \ self.options.get_safe('with_zlib', False) cmake.definitions['LLVM_ENABLE_LIBXML2'] = \ self.options.get_safe('with_xml2', False) cmake.definitions['LLVM_ENABLE_FFI'] = \ self.options.get_safe('with_ffi', False) - if self.options.get_safe('with_ffi', False): - cmake.definitions['FFI_INCLUDE_DIR'] = \ - self.deps_cpp_info['libffi'].include_paths[0] - cmake.definitions['FFI_LIBRARY_DIR'] = \ - self.deps_cpp_info['libffi'].lib_paths[0] return cmake def config_options(self): @@ -186,6 +182,15 @@ def source(self): self._patch_sources() def build(self): + # TODO: Temporary hack, it needs to be fixed from outside the recipe. + if Path('FindIconv.cmake').exists(): + tools.replace_in_file( + 'FindIconv.cmake', + 'set(Iconv_LIBRARY_LIST iconv charset)', + 'set(Iconv_LIBRARY_LIST iconv)', + strict=False + ) + cmake = self._configure_cmake() cmake.configure() cmake.build() @@ -210,6 +215,13 @@ def package(self): if not target.startswith('LLVM'): dummy_targets[target].append(dep) + cmake_targets = { + 'ZLIB::ZLIB': 'z', + 'Iconv::Iconv': 'iconv', + 'LibXml2::LibXml2': 'xml2', + 'libffi::libffi': 'ffi' + } + components = defaultdict(list) for lib, dep in deps: if not lib.startswith('LLVM'): @@ -218,6 +230,8 @@ def package(self): continue elif dep.startswith('LLVM'): components[dep] + elif dep in cmake_targets: + dep = cmake_targets[dep] elif Path(dep).exists(): dep = Path(dep).stem.replace('lib', '') dep = dep.replace('-l', '') diff --git a/recipes/llvm-core/all/patches/11x-cmake.patch b/recipes/llvm-core/all/patches/11x-cmake.patch index 7d36ccb560b6d..6f2c7682aa4e0 100644 --- a/recipes/llvm-core/all/patches/11x-cmake.patch +++ b/recipes/llvm-core/all/patches/11x-cmake.patch @@ -1,13 +1,15 @@ --- cmake/config-ix.cmake +++ cmake/config-ix.cmake -@@ -166,6 +166,7 @@ - else() - include_directories(${LIBXML2_INCLUDE_DIR}) - endif() -+ set(LIBXML2_LIBRARIES "xml2;iconv;z") - endif() - endif() - endif() +@@ -159,6 +159,9 @@ + set(LIBXML2_FOUND 0) + if((LLVM_ENABLE_LIBXML2) AND ((CMAKE_SYSTEM_NAME MATCHES "Linux") AND (ICONV_LIBRARY_PATH) OR APPLE)) + find_package(LibXml2) ++ set(LIBXML2_FOUND 1) ++ list(GET LibXml2_INCLUDE_DIRS -1 LIBXML2_INCLUDE_DIR) ++ set(LIBXML2_LIBRARIES ${LibXml2_LIBRARIES}) + if (LIBXML2_FOUND) + set(LLVM_LIBXML2_ENABLED 1) + if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})) @@ -321,7 +321,7 @@ message(FATAL_ERROR "libffi includes are not found.") endif() @@ -51,5 +53,5 @@ - endif() set_property(TARGET LLVMWindowsManifest PROPERTY - LLVM_SYSTEM_LIBS ${xml2_library}) -+ LLVM_SYSTEM_LIBS ${LIBXML2_LIBRARIES}) ++ LLVM_SYSTEM_LIBS ${LIBXML2_LIBRARIES}) endif() From 881ce179c9c1cc5500ccad797229295f9b7d5c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Thu, 5 Nov 2020 17:04:57 +0100 Subject: [PATCH 14/37] Enable building with libffi in Windows --- recipes/llvm-core/all/conanfile.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 61a24f2ea7978..81916698a06e6 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -33,9 +33,9 @@ class LLVMCoreConan(ConanFile): 'unwind_tables': [True, False], 'expensive_checks': [True, False], 'use_perf': [True, False], + 'with_ffi': [True, False], 'with_zlib': [True, False], - 'with_xml2': [True, False], - 'with_ffi': [True, False] + 'with_xml2': [True, False] } default_options = { 'shared': False, @@ -50,9 +50,9 @@ class LLVMCoreConan(ConanFile): 'unwind_tables': True, 'expensive_checks': False, 'use_perf': False, + 'with_ffi': False, 'with_zlib': True, - 'with_xml2': True, - 'with_ffi': False + 'with_xml2': True } exports_sources = ['CMakeLists.txt', 'patches/*'] @@ -94,10 +94,9 @@ def _configure_cmake(self): cmake.definitions['LLVM_TARGETS_TO_BUILD'] = self.options.targets cmake.definitions['LLVM_TARGET_ARCH'] = 'host' cmake.definitions['LLVM_BUILD_LLVM_DYLIB'] = self.options.shared + cmake.definitions['LLVM_DYLIB_COMPONENTS'] = self.options.components cmake.definitions['LLVM_ENABLE_PIC'] = \ self.options.get_safe('fPIC', default=False) - cmake.definitions['LLVM_DYLIB_COMPONENTS'] = \ - self.options.get_safe('components', default='all') cmake.definitions['LLVM_ABI_BREAKING_CHECKS'] = 'WITH_ASSERTS' cmake.definitions['LLVM_ENABLE_WARNINGS'] = True @@ -144,29 +143,26 @@ def _configure_cmake(self): cmake.definitions['LLVM_ENABLE_Z3_SOLVER'] = False cmake.definitions['LLVM_ENABLE_LIBPFM'] = False cmake.definitions['LLVM_ENABLE_LIBEDIT'] = False + cmake.definitions['LLVM_ENABLE_FFI'] = self.options.with_ffi cmake.definitions['LLVM_ENABLE_ZLIB'] = \ self.options.get_safe('with_zlib', False) cmake.definitions['LLVM_ENABLE_LIBXML2'] = \ self.options.get_safe('with_xml2', False) - cmake.definitions['LLVM_ENABLE_FFI'] = \ - self.options.get_safe('with_ffi', False) return cmake def config_options(self): if self.settings.os == 'Windows': del self.options.fPIC - del self.options.components del self.options.with_zlib del self.options.with_xml2 - del self.options.with_ffi def requirements(self): + if self.options.with_ffi: + self.requires('libffi/3.3') if self.options.get_safe('with_zlib', False): self.requires('zlib/1.2.11') if self.options.get_safe('with_xml2', False): self.requires('libxml2/2.9.10') - if self.options.get_safe('with_ffi', False): - self.requires('libffi/3.3') def configure(self): if self.settings.os == 'Windows' and self.options.shared: @@ -216,10 +212,10 @@ def package(self): dummy_targets[target].append(dep) cmake_targets = { + 'libffi::libffi': 'ffi', 'ZLIB::ZLIB': 'z', 'Iconv::Iconv': 'iconv', - 'LibXml2::LibXml2': 'xml2', - 'libffi::libffi': 'ffi' + 'LibXml2::LibXml2': 'xml2' } components = defaultdict(list) @@ -275,11 +271,11 @@ def package_info(self): with components_path.open(mode='r') as file: components = json.load(file) - dependencies = ['z', 'iconv', 'xml2', 'ffi'] + dependencies = ['ffi', 'z', 'iconv', 'xml2'] targets = { + 'ffi': 'libffi::libffi', 'z': 'zlib::zlib', - 'xml2': 'libxml2::libxml2', - 'ffi': 'libffi::libffi' + 'xml2': 'libxml2::libxml2' } for lib, deps in components.items(): From d0c220188cd34fdb0983c08510f7dde7ec9a93bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Fri, 6 Nov 2020 09:39:15 +0100 Subject: [PATCH 15/37] Do not force libc++ in clang builds --- recipes/llvm-core/all/conanfile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 81916698a06e6..50fbd6257877a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -102,8 +102,6 @@ def _configure_cmake(self): cmake.definitions['LLVM_ENABLE_WARNINGS'] = True cmake.definitions['LLVM_ENABLE_PEDANTIC'] = True cmake.definitions['LLVM_ENABLE_WERROR'] = False - cmake.definitions['LLVM_ENABLE_LIBCXX'] = \ - 'clang' in str(self.settings.compiler) # TODO: Temporary hack, it needs to be fixed from outside the recipe. cmake.definitions['LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN'] = False From 329d69e8fb3bc7a84649901e78436c2bda2865ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Fri, 6 Nov 2020 10:43:53 +0100 Subject: [PATCH 16/37] Wrong value for a cmake flag --- recipes/llvm-core/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 50fbd6257877a..3cf96db69bdce 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -104,7 +104,7 @@ def _configure_cmake(self): cmake.definitions['LLVM_ENABLE_WERROR'] = False # TODO: Temporary hack, it needs to be fixed from outside the recipe. - cmake.definitions['LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN'] = False + cmake.definitions['LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN'] = True cmake.definitions['LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO'] = True cmake.definitions['LLVM_BUILD_INSTRUMENTED_COVERAGE'] = False From d876b3463e70cf52f464afb47855c38eea0a561a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Fri, 6 Nov 2020 12:45:50 +0100 Subject: [PATCH 17/37] Building native tools were making some configurations fail --- recipes/llvm-core/all/conandata.yml | 2 + .../llvm-core/all/patches/11x-native.patch | 81 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 recipes/llvm-core/all/patches/11x-native.patch diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 0a38045341f20..7cf61e49acdaf 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -9,4 +9,6 @@ patches: patch_file: "patches/11x-vs2019.patch" - base_path: "source" patch_file: "patches/11x-cmake.patch" + - base_path: "source" + patch_file: "patches/11x-native.patch" diff --git a/recipes/llvm-core/all/patches/11x-native.patch b/recipes/llvm-core/all/patches/11x-native.patch new file mode 100644 index 0000000000000..315fb835843bd --- /dev/null +++ b/recipes/llvm-core/all/patches/11x-native.patch @@ -0,0 +1,81 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -943,10 +943,6 @@ + include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}) + + # when crosscompiling import the executable targets from a file +-if(LLVM_USE_HOST_TOOLS) +- include(CrossCompile) +- llvm_create_cross_target(LLVM NATIVE "" Release) +-endif(LLVM_USE_HOST_TOOLS) + if(LLVM_TARGET_IS_CROSSCOMPILE_HOST) + # Dummy use to avoid CMake Warning: Manually-specified variables were not used + # (this is a variable that CrossCompile sets on recursive invocations) +--- cmake/modules/TableGen.cmake ++++ cmake/modules/TableGen.cmake +@@ -150,33 +150,6 @@ + set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN} PARENT_SCOPE) + set(${project}_TABLEGEN_TARGET ${${project}_TABLEGEN} PARENT_SCOPE) + +- if(LLVM_USE_HOST_TOOLS) +- if( ${${project}_TABLEGEN} STREQUAL "${target}" ) +- # The NATIVE tablegen executable *must* depend on the current target one +- # otherwise the native one won't get rebuilt when the tablgen sources +- # change, and we end up with incorrect builds. +- build_native_tool(${target} ${project}_TABLEGEN_EXE DEPENDS ${target}) +- set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN_EXE} PARENT_SCOPE) +- +- add_custom_target(${project}-tablegen-host DEPENDS ${${project}_TABLEGEN_EXE}) +- set(${project}_TABLEGEN_TARGET ${project}-tablegen-host PARENT_SCOPE) +- +- # Create an artificial dependency between tablegen projects, because they +- # compile the same dependencies, thus using the same build folders. +- # FIXME: A proper fix requires sequentially chaining tablegens. +- if (NOT ${project} STREQUAL LLVM AND TARGET ${project}-tablegen-host AND +- TARGET LLVM-tablegen-host) +- add_dependencies(${project}-tablegen-host LLVM-tablegen-host) +- endif() +- +- # If we're using the host tablegen, and utils were not requested, we have no +- # need to build this tablegen. +- if ( NOT LLVM_BUILD_UTILS ) +- set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL ON) +- endif() +- endif() +- endif() +- + if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS) + set(export_to_llvmexports) + if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR +--- tools/llvm-config/CMakeLists.txt ++++ tools/llvm-config/CMakeLists.txt +@@ -77,11 +77,3 @@ + + # Add the dependency on the generation step. + add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp ${BUILDVARIABLES_OBJPATH}) +- +-if(CMAKE_CROSSCOMPILING AND NOT LLVM_CONFIG_PATH) +- build_native_tool(llvm-config LLVM_CONFIG_PATH) +- set(LLVM_CONFIG_PATH "${LLVM_CONFIG_PATH}" CACHE STRING "") +- +- add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH}) +- add_dependencies(llvm-config NativeLLVMConfig) +-endif() +--- tools/llvm-shlib/CMakeLists.txt ++++ tools/llvm-shlib/CMakeLists.txt +@@ -155,13 +155,8 @@ + + set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports) + if(NOT LLVM_NM) +- if(CMAKE_CROSSCOMPILING) +- build_native_tool(llvm-nm llvm_nm) +- set(llvm_nm_target "${llvm_nm}") +- else() +- set(llvm_nm $) +- set(llvm_nm_target llvm-nm) +- endif() ++ set(llvm_nm $) ++ set(llvm_nm_target llvm-nm) + else() + set(llvm_nm ${LLVM_NM}) + set(llvm_nm_target "") From c9a784c7c165592461ed7850da54b3e82312991e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Fri, 6 Nov 2020 13:00:07 +0100 Subject: [PATCH 18/37] Allow Visual Studio generators now that native tools are disabled --- recipes/llvm-core/all/conanfile.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 3cf96db69bdce..7308919ff574d 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -5,7 +5,6 @@ from collections import defaultdict import json import re -import os class LLVMCoreConan(ConanFile): @@ -81,13 +80,7 @@ def _patch_sources(self): tools.patch(**patch) def _configure_cmake(self): - if self.settings.compiler == 'Visual Studio': - generator = os.getenv('CONAN_CMAKE_GENERATOR', 'NMake Makefiles') - cmake = CMake(self, generator=generator) - cmake.definitions['LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN'] = True - else: - cmake = CMake(self) - + cmake = CMake(self) cmake.definitions['BUILD_SHARED_LIBS'] = False cmake.definitions['CMAKE_SKIP_RPATH'] = True From cf7b3c06bb8cfb30d8ed29dff0989192aa61d218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Fri, 6 Nov 2020 19:37:21 +0100 Subject: [PATCH 19/37] Disable relative paths for the sources in the debug info The latest versions of clang were not able to find the standard library headers if compiling with `-stdlib=libc++` and `-no-canonical-prefixes`. --- recipes/llvm-core/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 7308919ff574d..dba4f469e469a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -99,7 +99,7 @@ def _configure_cmake(self): # TODO: Temporary hack, it needs to be fixed from outside the recipe. cmake.definitions['LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN'] = True - cmake.definitions['LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO'] = True + cmake.definitions['LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO'] = False cmake.definitions['LLVM_BUILD_INSTRUMENTED_COVERAGE'] = False cmake.definitions['LLVM_OPTIMIZED_TABLEGEN'] = True cmake.definitions['LLVM_REVERSE_ITERATION'] = False From 8ce9dec10a8c5d74a1524ebadaf06075f40e0da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sat, 7 Nov 2020 11:20:17 +0100 Subject: [PATCH 20/37] Update supported compilers --- recipes/llvm-core/all/conanfile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index dba4f469e469a..6238ee384e870 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -66,14 +66,14 @@ def _supports_compiler(self): unsupported_combinations = [ [compiler == 'gcc', version.major == '5', version.minor < '1'], [compiler == 'gcc', version.major < '5'], + [compiler == 'clang', version.major < '4'], + [compiler == 'apple-clang', version.major < '9'], [compiler == 'Visual Studio', version.major < '15'] ] if any(all(combination) for combination in unsupported_combinations): - raise ConanInvalidConfiguration( - 'unsupported compiler: "{}", version "{}"' - .format(compiler, version) - ) + message = 'unsupported compiler: "{}", version "{}"' + raise ConanInvalidConfiguration(message.format(compiler, version)) def _patch_sources(self): for patch in self.conan_data.get('patches', {}).get(self.version, []): From 01e6a267d8fd1fd2d47e290ce88569ed8e44450d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sat, 7 Nov 2020 13:04:21 +0100 Subject: [PATCH 21/37] String comparisons are dangerous --- recipes/llvm-core/all/conanfile.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 6238ee384e870..659b6b031c215 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -63,14 +63,15 @@ class LLVMCoreConan(ConanFile): def _supports_compiler(self): compiler = self.settings.compiler.value version = tools.Version(self.settings.compiler.version) + major_rev, minor_rev = int(version.major), int(version.minor) + unsupported_combinations = [ - [compiler == 'gcc', version.major == '5', version.minor < '1'], - [compiler == 'gcc', version.major < '5'], - [compiler == 'clang', version.major < '4'], - [compiler == 'apple-clang', version.major < '9'], - [compiler == 'Visual Studio', version.major < '15'] + [compiler == 'gcc', major_rev == 5, minor_rev < 1], + [compiler == 'gcc', major_rev < 5], + [compiler == 'clang', major_rev < 4], + [compiler == 'apple-clang', major_rev < 9], + [compiler == 'Visual Studio', major_rev < 15] ] - if any(all(combination) for combination in unsupported_combinations): message = 'unsupported compiler: "{}", version "{}"' raise ConanInvalidConfiguration(message.format(compiler, version)) From 33c36f2a6680d27ea8fa9effbd742e3bf468a374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sat, 7 Nov 2020 18:20:00 +0100 Subject: [PATCH 22/37] Remove iconv patch comment Turns out that the hack was justified. Both, iconv and charset libraries, own a localcharset symbol. In normal circumstances this is not an issue but libLLVM gets linked with `--whole-archive` or `-all_load` and the linker complains about duplicated symbols. It is safer to remove charset from the linking step, as its symbols are not needed, than to remove the linker option. --- recipes/llvm-core/all/conanfile.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 659b6b031c215..af74cba9c1fbf 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -80,6 +80,10 @@ def _patch_sources(self): for patch in self.conan_data.get('patches', {}).get(self.version, []): tools.patch(**patch) + def _patch_build(self): + if Path('FindIconv.cmake').exists(): + tools.replace_in_file('FindIconv.cmake', 'iconv charset', 'iconv') + def _configure_cmake(self): cmake = CMake(self) cmake.definitions['BUILD_SHARED_LIBS'] = False @@ -97,9 +101,7 @@ def _configure_cmake(self): cmake.definitions['LLVM_ENABLE_PEDANTIC'] = True cmake.definitions['LLVM_ENABLE_WERROR'] = False - # TODO: Temporary hack, it needs to be fixed from outside the recipe. cmake.definitions['LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN'] = True - cmake.definitions['LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO'] = False cmake.definitions['LLVM_BUILD_INSTRUMENTED_COVERAGE'] = False cmake.definitions['LLVM_OPTIMIZED_TABLEGEN'] = True @@ -170,15 +172,7 @@ def source(self): self._patch_sources() def build(self): - # TODO: Temporary hack, it needs to be fixed from outside the recipe. - if Path('FindIconv.cmake').exists(): - tools.replace_in_file( - 'FindIconv.cmake', - 'set(Iconv_LIBRARY_LIST iconv charset)', - 'set(Iconv_LIBRARY_LIST iconv)', - strict=False - ) - + self._patch_build() cmake = self._configure_cmake() cmake.configure() cmake.build() From bb7baecf32f5c39021702907acfdea58f9040c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sun, 8 Nov 2020 19:11:36 +0100 Subject: [PATCH 23/37] Commit suggestion Co-authored-by: Yoann Potinet --- recipes/llvm-core/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index af74cba9c1fbf..92cca3fe06d58 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -58,7 +58,9 @@ class LLVMCoreConan(ConanFile): generators = ['cmake', 'cmake_find_package'] no_copy_source = True - _source_subfolder = 'source' + @property + def _source_subfolder(self): + return 'source' def _supports_compiler(self): compiler = self.settings.compiler.value From 59d824863b77e5690e246b4d87ac61be8b692b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sun, 8 Nov 2020 19:16:38 +0100 Subject: [PATCH 24/37] More meaningful exception messages --- recipes/llvm-core/all/conanfile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 92cca3fe06d58..5e7a1d608db77 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -162,9 +162,11 @@ def requirements(self): def configure(self): if self.settings.os == 'Windows' and self.options.shared: - raise ConanInvalidConfiguration('shared lib not supported') + message = 'Shared build not supported on Windows' + raise ConanInvalidConfiguration(message) if self.options.exceptions and not self.options.rtti: - raise ConanInvalidConfiguration('exceptions require rtti support') + message = 'Cannot enable exceptions without rtti support' + raise ConanInvalidConfiguration(message) self._supports_compiler() def source(self): From 1ef186a0e4f88c7a193df508dc0abd5b72cc555b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sun, 8 Nov 2020 19:20:05 +0100 Subject: [PATCH 25/37] Remove unnecessary readme --- recipes/llvm-core/all/readme.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 recipes/llvm-core/all/readme.md diff --git a/recipes/llvm-core/all/readme.md b/recipes/llvm-core/all/readme.md deleted file mode 100644 index 85f1becb48342..0000000000000 --- a/recipes/llvm-core/all/readme.md +++ /dev/null @@ -1,9 +0,0 @@ -## Conan package for [LLVM](https://github.com/llvm/llvm-project) - -This is a package for just the core libraries, not the compiler nor any of the **clang**-based tools. - -🚧 Currently under development... 🚧 - -**Copyright (c):** 2020 Alberto Lorenzo Márquez. - -**License:** MIT (see `../license.txt`). From d30f900e48c89b4d9c8a05d45715c4e8c66fcbe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Wed, 11 Nov 2020 20:29:28 +0100 Subject: [PATCH 26/37] Support older Python versions It is such a pity; pathlib is way elegant than os.path. --- recipes/llvm-core/all/conanfile.py | 48 ++++++++++--------- .../llvm-core/all/test_package/conanfile.py | 17 +++---- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 5e7a1d608db77..1363cd7b94746 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -1,10 +1,11 @@ from conans.errors import ConanInvalidConfiguration from conans import ConanFile, CMake, tools -from pathlib import Path from collections import defaultdict import json import re +import os.path +import os class LLVMCoreConan(ConanFile): @@ -83,7 +84,7 @@ def _patch_sources(self): tools.patch(**patch) def _patch_build(self): - if Path('FindIconv.cmake').exists(): + if os.path.exists('FindIconv.cmake'): tools.replace_in_file('FindIconv.cmake', 'iconv charset', 'iconv') def _configure_cmake(self): @@ -171,8 +172,7 @@ def configure(self): def source(self): tools.get(**self.conan_data['sources'][self.version]) - source_path = Path(f'llvm-{self.version}.src') - source_path.rename(self._source_subfolder) + os.rename('llvm-{}.src'.format(self.version), self._source_subfolder) self._patch_sources() def build(self): @@ -183,7 +183,7 @@ def build(self): def package(self): self.copy('LICENSE.TXT', dst='licenses', src=self._source_subfolder) - package_path = Path(self.package_folder) + lib_path = os.path.join(self.package_folder, 'lib') cmake = self._configure_cmake() cmake.install() @@ -218,8 +218,9 @@ def package(self): components[dep] elif dep in cmake_targets: dep = cmake_targets[dep] - elif Path(dep).exists(): - dep = Path(dep).stem.replace('lib', '') + elif os.path.exists(dep): + dep = os.path.splitext(os.path.basename(dep))[0] + dep = dep.replace('lib', '') dep = dep.replace('-l', '') if dep in dummy_targets.keys(): @@ -228,23 +229,24 @@ def package(self): else: components[lib].append(dep) - tools.rmdir(str(package_path.joinpath('bin').resolve())) - tools.rmdir(str(package_path.joinpath('lib', 'cmake').resolve())) - tools.rmdir(str(package_path.joinpath('share').resolve())) + tools.rmdir(os.path.join(self.package_folder, 'bin')) + tools.rmdir(os.path.join(self.package_folder, 'lib', 'cmake')) + tools.rmdir(os.path.join(self.package_folder, 'share')) - for file in package_path.joinpath('lib').iterdir(): - if 'LLVM' not in file.stem: - file.unlink() + for name in os.listdir(lib_path): + if 'LLVM' not in name: + os.remove(os.path.join(lib_path, name)) if not self.options.shared: - components_path = package_path.joinpath('lib', 'components.json') - with components_path.open(mode='w') as file: - json.dump(components, file, indent=4) + components_path = \ + os.path.join(self.package_folder, 'lib', 'components.json') + with open(components_path, 'w') as components_file: + json.dump(components, components_file, indent=4) else: suffixes = ['.dylib', '.so'] - for file in package_path.joinpath('lib').iterdir(): - if not any(suffix in file.suffixes for suffix in suffixes): - file.unlink() + for name in os.listdir(lib_path): + if not any(suffix in name for suffix in suffixes): + os.remove(os.path.join(lib_path, name)) def package_info(self): if self.options.shared: @@ -256,10 +258,10 @@ def package_info(self): self.cpp_info.system_libs = ['curses', 'm'] return - package_path = Path(self.package_folder) - components_path = package_path.joinpath('lib', 'components.json') - with components_path.open(mode='r') as file: - components = json.load(file) + components_path = \ + os.path.join(self.package_folder, 'lib', 'components.json') + with open(components_path, 'r') as components_file: + components = json.load(components_file) dependencies = ['ffi', 'z', 'iconv', 'xml2'] targets = { diff --git a/recipes/llvm-core/all/test_package/conanfile.py b/recipes/llvm-core/all/test_package/conanfile.py index e77a1f748071a..e0ca8f6b664cb 100644 --- a/recipes/llvm-core/all/test_package/conanfile.py +++ b/recipes/llvm-core/all/test_package/conanfile.py @@ -1,9 +1,9 @@ from conans import ConanFile, CMake, tools -from pathlib import Path +import os.path -class LLVMTestPackageConan(ConanFile): +class LLVMCoreTestPackageConan(ConanFile): settings = ('os', 'arch', 'compiler', 'build_type') generators = ('cmake', 'cmake_find_package') @@ -28,11 +28,12 @@ def test(self): test_package = False if test_package: - executable = Path('bin').joinpath('test_package') - input = Path(__file__).parent.joinpath('test_function.ll') - command = [str(file.resolve()) for file in (executable, input)] + command = [ + os.path.join('bin', 'test_package'), + os.path.join(os.path.dirname(__file__), 'test_function.ll') + ] self.run(command, run_environment=True) - llvm_path = Path(self.deps_cpp_info['llvm-core'].rootpath) - license_file = llvm_path.joinpath('licenses', 'LICENSE.TXT') - assert license_file.exists() + llvm_path = self.deps_cpp_info['llvm-core'].rootpath + license_path = os.path.join(llvm_path, 'licenses', 'LICENSE.TXT') + assert os.path.exists(license_path) From 7c9f6ef5dd3fa655d6059dea34a64e9c39840966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sun, 22 Nov 2020 11:23:12 +0100 Subject: [PATCH 27/37] Empty commit to trigger the CI From 304a14ec3064b0dfe82bac41b50e98a438f8d0c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Mon, 4 Jan 2021 10:46:06 +0100 Subject: [PATCH 28/37] Remove unnecessary status message Co-authored-by: Michael Keck --- recipes/llvm-core/all/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/llvm-core/all/CMakeLists.txt b/recipes/llvm-core/all/CMakeLists.txt index ea021e07508d8..e24649232aac7 100644 --- a/recipes/llvm-core/all/CMakeLists.txt +++ b/recipes/llvm-core/all/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.4.3) project(conanllvm) -message(STATUS "Conan CMake Wrapper") include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() From 563e5715b549067619daa990a5d58a001eb6cb38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Mon, 4 Jan 2021 10:46:54 +0100 Subject: [PATCH 29/37] Less strict cmake minimum required version Co-authored-by: Michael Keck --- recipes/llvm-core/all/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/CMakeLists.txt b/recipes/llvm-core/all/CMakeLists.txt index e24649232aac7..3794f0ddca600 100644 --- a/recipes/llvm-core/all/CMakeLists.txt +++ b/recipes/llvm-core/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.1.0) project(conanllvm) include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) From e79842e348e84a6b70d50d51f5f397d8fe2bb1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sat, 16 Jan 2021 20:42:38 +0100 Subject: [PATCH 30/37] LLVM version bumped to 11.0.1 --- recipes/llvm-core/all/conandata.yml | 14 +++++++------- .../{11x-cmake.patch => 11.0.1-cmake.patch} | 0 .../{11x-native.patch => 11.0.1-native.patch} | 2 +- .../{11x-vs2019.patch => 11.0.1-vs2019.patch} | 0 recipes/llvm-core/config.yml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) rename recipes/llvm-core/all/patches/{11x-cmake.patch => 11.0.1-cmake.patch} (100%) rename recipes/llvm-core/all/patches/{11x-native.patch => 11.0.1-native.patch} (99%) rename recipes/llvm-core/all/patches/{11x-vs2019.patch => 11.0.1-vs2019.patch} (100%) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 7cf61e49acdaf..1970766f903be 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -1,14 +1,14 @@ sources: - "11.0.0": - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/llvm-11.0.0.src.tar.xz - sha256: 913f68c898dfb4a03b397c5e11c6a2f39d0f22ed7665c9cefa87a34423a72469 + "11.0.1": + url: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.1/llvm-11.0.1.src.tar.xz + sha256: ccd87c254b6aebc5077e4e6977d08d4be888e7eb672c6630a26a15d58b59b528 patches: - "11.0.0": + "11.0.1": - base_path: "source" - patch_file: "patches/11x-vs2019.patch" + patch_file: "patches/11.0.1-vs2019.patch" - base_path: "source" - patch_file: "patches/11x-cmake.patch" + patch_file: "patches/11.0.1-cmake.patch" - base_path: "source" - patch_file: "patches/11x-native.patch" + patch_file: "patches/11.0.1-native.patch" diff --git a/recipes/llvm-core/all/patches/11x-cmake.patch b/recipes/llvm-core/all/patches/11.0.1-cmake.patch similarity index 100% rename from recipes/llvm-core/all/patches/11x-cmake.patch rename to recipes/llvm-core/all/patches/11.0.1-cmake.patch diff --git a/recipes/llvm-core/all/patches/11x-native.patch b/recipes/llvm-core/all/patches/11.0.1-native.patch similarity index 99% rename from recipes/llvm-core/all/patches/11x-native.patch rename to recipes/llvm-core/all/patches/11.0.1-native.patch index 315fb835843bd..c541a76820341 100644 --- a/recipes/llvm-core/all/patches/11x-native.patch +++ b/recipes/llvm-core/all/patches/11.0.1-native.patch @@ -1,6 +1,6 @@ --- CMakeLists.txt +++ CMakeLists.txt -@@ -943,10 +943,6 @@ +@@ -942,10 +942,6 @@ include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}) # when crosscompiling import the executable targets from a file diff --git a/recipes/llvm-core/all/patches/11x-vs2019.patch b/recipes/llvm-core/all/patches/11.0.1-vs2019.patch similarity index 100% rename from recipes/llvm-core/all/patches/11x-vs2019.patch rename to recipes/llvm-core/all/patches/11.0.1-vs2019.patch diff --git a/recipes/llvm-core/config.yml b/recipes/llvm-core/config.yml index 17553290ebe68..d7fc56a2cf1b3 100644 --- a/recipes/llvm-core/config.yml +++ b/recipes/llvm-core/config.yml @@ -1,3 +1,3 @@ versions: - "11.0.0": + "11.0.1": folder: all From c0ab4e705dd6e6595c7a86dc7953a292e2139af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Wed, 7 Apr 2021 23:20:59 +0200 Subject: [PATCH 31/37] LLVM version bumped to 11.1.0 --- recipes/llvm-core/all/conandata.yml | 14 +++++++------- .../{11.0.1-cmake.patch => 11.1.0-cmake.patch} | 0 .../{11.0.1-native.patch => 11.1.0-native.patch} | 0 .../{11.0.1-vs2019.patch => 11.1.0-vs2019.patch} | 0 recipes/llvm-core/config.yml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename recipes/llvm-core/all/patches/{11.0.1-cmake.patch => 11.1.0-cmake.patch} (100%) rename recipes/llvm-core/all/patches/{11.0.1-native.patch => 11.1.0-native.patch} (100%) rename recipes/llvm-core/all/patches/{11.0.1-vs2019.patch => 11.1.0-vs2019.patch} (100%) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 1970766f903be..b6cf839f6c9d9 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -1,14 +1,14 @@ sources: - "11.0.1": - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.1/llvm-11.0.1.src.tar.xz - sha256: ccd87c254b6aebc5077e4e6977d08d4be888e7eb672c6630a26a15d58b59b528 + "11.1.0": + url: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/llvm-11.1.0.src.tar.xz + sha256: ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5 patches: - "11.0.1": + "11.1.0": - base_path: "source" - patch_file: "patches/11.0.1-vs2019.patch" + patch_file: "patches/11.1.0-vs2019.patch" - base_path: "source" - patch_file: "patches/11.0.1-cmake.patch" + patch_file: "patches/11.1.0-cmake.patch" - base_path: "source" - patch_file: "patches/11.0.1-native.patch" + patch_file: "patches/11.1.0-native.patch" diff --git a/recipes/llvm-core/all/patches/11.0.1-cmake.patch b/recipes/llvm-core/all/patches/11.1.0-cmake.patch similarity index 100% rename from recipes/llvm-core/all/patches/11.0.1-cmake.patch rename to recipes/llvm-core/all/patches/11.1.0-cmake.patch diff --git a/recipes/llvm-core/all/patches/11.0.1-native.patch b/recipes/llvm-core/all/patches/11.1.0-native.patch similarity index 100% rename from recipes/llvm-core/all/patches/11.0.1-native.patch rename to recipes/llvm-core/all/patches/11.1.0-native.patch diff --git a/recipes/llvm-core/all/patches/11.0.1-vs2019.patch b/recipes/llvm-core/all/patches/11.1.0-vs2019.patch similarity index 100% rename from recipes/llvm-core/all/patches/11.0.1-vs2019.patch rename to recipes/llvm-core/all/patches/11.1.0-vs2019.patch diff --git a/recipes/llvm-core/config.yml b/recipes/llvm-core/config.yml index d7fc56a2cf1b3..051c4cad1e3eb 100644 --- a/recipes/llvm-core/config.yml +++ b/recipes/llvm-core/config.yml @@ -1,3 +1,3 @@ versions: - "11.0.1": + "11.1.0": folder: all From 194cf21f70c5a74064d65d6b07ec8f49adb17293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Fri, 9 Apr 2021 22:15:00 +0200 Subject: [PATCH 32/37] Deactivate fPIC if shared --- recipes/llvm-core/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 1363cd7b94746..83567f7b21a48 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -162,6 +162,8 @@ def requirements(self): self.requires('libxml2/2.9.10') def configure(self): + if self.options.shared: + del self.options.fPIC if self.settings.os == 'Windows' and self.options.shared: message = 'Shared build not supported on Windows' raise ConanInvalidConfiguration(message) From e0216391143ade9a0cbe7f364c882b2aec1c53d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Mon, 12 Apr 2021 19:17:09 +0200 Subject: [PATCH 33/37] Fix fPIC flag for shared builds --- recipes/llvm-core/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 83567f7b21a48..79229c853b28a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -91,9 +91,11 @@ def _configure_cmake(self): cmake = CMake(self) cmake.definitions['BUILD_SHARED_LIBS'] = False cmake.definitions['CMAKE_SKIP_RPATH'] = True + cmake.definitions['CMAKE_POSITION_INDEPENDENT_CODE'] = \ + self.options.get_safe('fPIC', default=False) or self.options.shared - cmake.definitions['LLVM_TARGETS_TO_BUILD'] = self.options.targets cmake.definitions['LLVM_TARGET_ARCH'] = 'host' + cmake.definitions['LLVM_TARGETS_TO_BUILD'] = self.options.targets cmake.definitions['LLVM_BUILD_LLVM_DYLIB'] = self.options.shared cmake.definitions['LLVM_DYLIB_COMPONENTS'] = self.options.components cmake.definitions['LLVM_ENABLE_PIC'] = \ From d99091dba016418fed8d98d1d0250da1d27087e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Mon, 12 Apr 2021 21:30:28 +0200 Subject: [PATCH 34/37] Install LLVMTableGenGlobalISel manually As it is not part of the install target. This is a kind of problematic library, see: https://reviews.llvm.org/D74588 --- recipes/llvm-core/all/CMakeLists.txt | 2 +- recipes/llvm-core/all/conanfile.py | 8 ++++++++ recipes/llvm-core/all/test_package/CMakeLists.txt | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/recipes/llvm-core/all/CMakeLists.txt b/recipes/llvm-core/all/CMakeLists.txt index 3794f0ddca600..abb97809bb4ec 100644 --- a/recipes/llvm-core/all/CMakeLists.txt +++ b/recipes/llvm-core/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1.0) +cmake_minimum_required(VERSION 3.13.4) project(conanllvm) include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 79229c853b28a..9eba61acadb52 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -94,6 +94,10 @@ def _configure_cmake(self): cmake.definitions['CMAKE_POSITION_INDEPENDENT_CODE'] = \ self.options.get_safe('fPIC', default=False) or self.options.shared + if not self.options.shared: + cmake.definitions['DISABLE_LLVM_LINK_LLVM_DYLIB'] = True + # cmake.definitions['LLVM_LINK_DYLIB'] = self.options.shared + cmake.definitions['LLVM_TARGET_ARCH'] = 'host' cmake.definitions['LLVM_TARGETS_TO_BUILD'] = self.options.targets cmake.definitions['LLVM_BUILD_LLVM_DYLIB'] = self.options.shared @@ -193,6 +197,10 @@ def package(self): cmake.install() if not self.options.shared: + for ext in ['.a', '.lib']: + lib = '*LLVMTableGenGlobalISel{}'.format(ext) + self.copy(lib, dst='lib', src='lib') + self.run('cmake --graphviz=graph/llvm.dot .') with tools.chdir('graph'): dot_text = tools.load('llvm.dot').replace('\r\n', '\n') diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index 3bb3833284c71..d2d3b1ff641d9 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.13.4) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) From c4ae50c721778ffd49746b0b9d00f8bd8b2ff3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Fri, 21 May 2021 20:36:02 +0200 Subject: [PATCH 35/37] Add option use_sanitizer --- recipes/llvm-core/all/conanfile.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 9eba61acadb52..e61ffd72391af 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -33,6 +33,16 @@ class LLVMCoreConan(ConanFile): 'unwind_tables': [True, False], 'expensive_checks': [True, False], 'use_perf': [True, False], + 'use_sanitizer': [ + 'Address', + 'Memory', + 'MemoryWithOrigins', + 'Undefined', + 'Thread', + 'DataFlow', + 'Address;Undefined', + 'None' + ], 'with_ffi': [True, False], 'with_zlib': [True, False], 'with_xml2': [True, False] @@ -50,6 +60,7 @@ class LLVMCoreConan(ConanFile): 'unwind_tables': True, 'expensive_checks': False, 'use_perf': False, + 'use_sanitizer': 'None', 'with_ffi': False, 'with_zlib': True, 'with_xml2': True @@ -142,6 +153,11 @@ def _configure_cmake(self): cmake.definitions['LLVM_USE_NEWPM'] = False cmake.definitions['LLVM_USE_OPROFILE'] = False cmake.definitions['LLVM_USE_PERF'] = self.options.use_perf + if self.options.use_sanitizer == 'None': + cmake.definitions['LLVM_USE_SANITIZER'] = '' + else: + cmake.definitions['LLVM_USE_SANITIZER'] = \ + self.options.use_sanitizer cmake.definitions['LLVM_ENABLE_Z3_SOLVER'] = False cmake.definitions['LLVM_ENABLE_LIBPFM'] = False From e5b2dee54c8da8cf3c2ab4bb43ec789fbba6135f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Fri, 21 May 2021 20:43:03 +0200 Subject: [PATCH 36/37] Disable all shared builds --- recipes/llvm-core/all/conanfile.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index e61ffd72391af..bff27b412fc65 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -184,11 +184,13 @@ def requirements(self): self.requires('libxml2/2.9.10') def configure(self): - if self.options.shared: - del self.options.fPIC - if self.settings.os == 'Windows' and self.options.shared: - message = 'Shared build not supported on Windows' + if self.options.shared: # Shared builds disabled just due to the CI + message = 'Shared builds not currently supported' raise ConanInvalidConfiguration(message) + # del self.options.fPIC + # if self.settings.os == 'Windows' and self.options.shared: + # message = 'Shared builds not supported on Windows' + # raise ConanInvalidConfiguration(message) if self.options.exceptions and not self.options.rtti: message = 'Cannot enable exceptions without rtti support' raise ConanInvalidConfiguration(message) From f6a023ba475bfb5819f70ad70268cfa4a4b02cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Lorenzo=20M=C3=A1rquez?= Date: Sat, 22 May 2021 07:27:34 +0200 Subject: [PATCH 37/37] Dedent conandata.yml Co-authored-by: Yoann Potinet --- recipes/llvm-core/all/conandata.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index b6cf839f6c9d9..e827098115aa1 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -1,14 +1,13 @@ sources: - "11.1.0": - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/llvm-11.1.0.src.tar.xz - sha256: ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5 + "11.1.0": + url: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/llvm-11.1.0.src.tar.xz + sha256: ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5 patches: - "11.1.0": - - base_path: "source" - patch_file: "patches/11.1.0-vs2019.patch" - - base_path: "source" - patch_file: "patches/11.1.0-cmake.patch" - - base_path: "source" - patch_file: "patches/11.1.0-native.patch" - + "11.1.0": + - base_path: "source" + patch_file: "patches/11.1.0-vs2019.patch" + - base_path: "source" + patch_file: "patches/11.1.0-cmake.patch" + - base_path: "source" + patch_file: "patches/11.1.0-native.patch"