diff --git a/recipes/llvm/all/conandata.yml b/recipes/llvm/all/conandata.yml index c5eda1647e396..10fcb1b7b5ccc 100644 --- a/recipes/llvm/all/conandata.yml +++ b/recipes/llvm/all/conandata.yml @@ -8,3 +8,122 @@ sources: "14.0.0": url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-14.0.0.tar.gz sha256: 87b1a068b370df5b79a892fdb2935922a8efb1fddec4cc506e30fe57b6a1d9c4 + "14.0.1": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-14.0.1.tar.gz + sha256: c8be00406e872c8a24f8571cf6f5517b73ae707104724b1fd1db2f0af9544019 + "14.0.2": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-14.0.2.tar.gz + sha256: ca52232b3451c8e017f00eb882277707c13e30fac1271ec97015f6d0eeb383d1 + "14.0.3": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-14.0.3.tar.gz + sha256: 0e1d049b050127ecf6286107e9a4400b0550f841d5d2288b9d31fd32ed0683d5 + "14.0.4": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-14.0.4.tar.gz + sha256: 1333236f9bee38658762076be4236cb5ebf15ae9b7f2bfce6946b96ae962dc7 + "14.0.5": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-14.0.5.tar.gz + sha256: a4a57f029cb81f04618e05853f05fc2d21b64353c760977d8e7799bf7218a23a + "14.0.6": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-14.0.6.tar.gz + sha256: 98f15f842700bdb7220a166c8d2739a03a72e775b67031205078f39dd756a055 + "15.0.0": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-15.0.0.tar.gz + sha256: 36d83cd84e1caf2bcfda1669c029e2b949adb9860cff01e7d3246ac2348b11ae + "15.0.1": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-15.0.1.tar.gz + sha256: 20bccb964e39f604fdc16d1258f94d2053fbdcdab2b2f6d5e20e6095ec403c00 + "15.0.2": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-15.0.2.tar.gz + sha256: dc11d35e60ab61792baa607dff080c993b39de23fb93b3d3369ba15b0601c307 + "15.0.3": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-15.0.3.tar.gz + sha256: 8ac8e4c0982bf236526d737d385db5e1e66543ab217a9355d54159659eae3774 + "15.0.4": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-15.0.4.tar.gz + sha256: e24b4d3bf7821dcb1c901d1e09096c1f88fb00095c5a6ef893baab4836975e52 + "15.0.5": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-15.0.5.tar.gz + sha256: c47640269e0251e009ae18a25162df4e20e175885286e21d28c054b084b991a4 + "15.0.6": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-15.0.6.tar.gz + sha256: 4d857d7a180918bdacd09a5910bf9743c9861a1e49cb065a85f7a990f812161d + "15.0.7": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-15.0.7.tar.gz + sha256: 42a0088f148edcf6c770dfc780a7273014a9a89b66f357c761b4ca7c8dfa10ba + "16.0.0": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-16.0.0.tar.gz + sha256: cba969a0782a3a398658d439f047b5e548ea04724f4fbfdbe17cfc946f4cd3ed + "16.0.1": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-16.0.1.tar.gz + sha256: b5a9ff1793b1e2d388a3819bf35797002b1d2e40bb35a10c65605e0ea1435271 + "16.0.2": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-16.0.2.tar.gz + sha256: 97c3c6aafb53c4bb0ed2781a18d6f05e75445e24bb1dc57a32b74f8d710ac19f + "16.0.3": + url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-16.0.3.tar.gz + sha256: 0bd71bc687a4e5a250c40afb0decefc50c85178fcce726137b682039de63919b + +patches: + "13.0.0": + - patch_file: "patches/13/calculate_job_pools.patch" + - patch_file: "patches/13/fix_xml2_library_name.patch" + "13.0.1": + - patch_file: "patches/13/calculate_job_pools.patch" + - patch_file: "patches/13/fix_xml2_library_name.patch" + "14.0.0": + - patch_file: "patches/14/calculate_job_pools.patch" + - patch_file: "patches/14/fix_xml2_library_name.patch" + "14.0.1": + - patch_file: "patches/14/calculate_job_pools.patch" + - patch_file: "patches/14/fix_xml2_library_name.patch" + "14.0.2": + - patch_file: "patches/14/calculate_job_pools.patch" + - patch_file: "patches/14/fix_xml2_library_name.patch" + "14.0.3": + - patch_file: "patches/14/calculate_job_pools.patch" + - patch_file: "patches/14/fix_xml2_library_name.patch" + "14.0.4": + - patch_file: "patches/14/calculate_job_pools.patch" + - patch_file: "patches/14/fix_xml2_library_name.patch" + "14.0.5": + - patch_file: "patches/14/calculate_job_pools.patch" + - patch_file: "patches/14/fix_xml2_library_name.patch" + "14.0.6": + - patch_file: "patches/14/calculate_job_pools.patch" + - patch_file: "patches/14/fix_xml2_library_name.patch" + "15.0.0": + - patch_file: "patches/15/calculate_job_pools.patch" + - patch_file: "patches/15/fix_xml2_library_name.patch" + "15.0.1": + - patch_file: "patches/15/calculate_job_pools.patch" + - patch_file: "patches/15/fix_xml2_library_name.patch" + "15.0.2": + - patch_file: "patches/15/calculate_job_pools.patch" + - patch_file: "patches/15/fix_xml2_library_name.patch" + "15.0.3": + - patch_file: "patches/15/calculate_job_pools.patch" + - patch_file: "patches/15/fix_xml2_library_name.patch" + "15.0.4": + - patch_file: "patches/15/calculate_job_pools.patch" + - patch_file: "patches/15/fix_xml2_library_name.patch" + "15.0.5": + - patch_file: "patches/15/calculate_job_pools.patch" + - patch_file: "patches/15/fix_xml2_library_name.patch" + "15.0.6": + - patch_file: "patches/15/calculate_job_pools.patch" + - patch_file: "patches/15/fix_xml2_library_name.patch" + "15.0.7": + - patch_file: "patches/15/calculate_job_pools.patch" + - patch_file: "patches/15/fix_xml2_library_name.patch" + "16.0.0": + - patch_file: "patches/16/calculate_job_pools.patch" + - patch_file: "patches/16/fix_xml2_library_name.patch" + "16.0.1": + - patch_file: "patches/16/calculate_job_pools.patch" + - patch_file: "patches/16/fix_xml2_library_name.patch" + "16.0.2": + - patch_file: "patches/16/calculate_job_pools.patch" + - patch_file: "patches/16/fix_xml2_library_name.patch" + "16.0.3": + - patch_file: "patches/16/calculate_job_pools.patch" + - patch_file: "patches/16/fix_xml2_library_name.patch" diff --git a/recipes/llvm/all/conanfile.py b/recipes/llvm/all/conanfile.py index ded47b60274cd..943ad06bf3787 100644 --- a/recipes/llvm/all/conanfile.py +++ b/recipes/llvm/all/conanfile.py @@ -1,9 +1,21 @@ -from conans import ConanFile, tools, CMake -from conans.tools import Version -from conans.errors import ConanInvalidConfiguration -import os, shutil, glob +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake +from conan.tools.files import get, apply_conandata_patches, rmdir, chdir, load +from conan.tools.microsoft import is_msvc +from conan.tools.files.copy_pattern import copy +from conan.tools.build.cppstd import check_min_cppstd +from conan.tools.system.package_manager import Apt +from conan.errors import ConanInvalidConfiguration +from collections import defaultdict +from conan.tools.cmake.layout import cmake_layout +from conan.errors import ConanException +from conans.model.version import Version +import os +import shutil +import glob +import re +import json -# https://llvm.org/docs/CMake.html#frequently-used-llvm-related-variables projects = [ 'clang', 'clang-tools-extra', @@ -24,15 +36,25 @@ 'openmp', ] default_projects = [ - 'clang', + # 'clang', + # 'clang-tools-extra', + # 'libc', # clang-14/15 crashes in {sin,cos,tan} for llvm-{13.0.0,14.0.6} in debug, clang-15 release looks fine + # 'libclc', + # 'lld', + # 'lldb', + # 'openmp', + # 'polly', + # 'pstl', ] default_runtimes = [ - #'libcxx', - # libcxxabi appears to be required to build libcxx. - # See: https://reviews.llvm.org/D63883 - #'libcxxabi', + # 'compiler-rt', + # 'libc', + # 'libcxx', + # 'libcxxabi', + # 'libunwind', ] + class Llvm(ConanFile): name = 'llvm' description = 'The LLVM Project is a collection of modular and reusable compiler and toolchain technologies' @@ -43,9 +65,9 @@ class Llvm(ConanFile): settings = 'os', 'arch', 'compiler', 'build_type' + # dont copy source to build directory, large software opt no_copy_source = True - _source_subfolder = 'source_subfolder' - short_paths = True + short_paths = True # XXX Conan1 short paths for windows, no longer needed for recent win10 options = { **{'with_project_' + project: [True, False] @@ -54,9 +76,11 @@ class Llvm(ConanFile): for runtime in runtimes}, **{ 'shared': [True, False], + 'llvm_build_llvm_dylib': [True, False], + 'llvm_link_llvm_dylib': [True, False], + 'llvm_dylib_components': ['ANY'], 'fPIC': [True, False], - 'components': 'ANY', - 'targets': 'ANY', + 'targets': ['ANY'], 'exceptions': [True, False], 'rtti': [True, False], 'threads': [True, False], @@ -65,7 +89,7 @@ class Llvm(ConanFile): 'unwind_tables': [True, False], 'expensive_checks': [True, False], 'use_perf': [True, False], - 'use_sanitizer': [ + 'llvm_use_sanitizer': [ 'Address', 'Memory', 'MemoryWithOrigins', @@ -73,13 +97,19 @@ class Llvm(ConanFile): 'Thread', 'DataFlow', 'Address;Undefined', - 'None' + '' ], + 'with_z3': [True, False], 'with_ffi': [True, False], 'with_zlib': [True, False], 'with_xml2': [True, False], + 'keep_binaries_regex': ['ANY'], + + # options removed in package id 'use_llvm_cmake_files': [True, False], - 'enable_debug': [True, False], + 'clean_build_bin': [True, False], + 'ram_per_compile_job': ['ANY'], + 'ram_per_link_job': ['ANY'], }, } default_options = { @@ -93,49 +123,128 @@ class Llvm(ConanFile): }, **{ 'shared': False, + 'llvm_build_llvm_dylib': False, + 'llvm_link_llvm_dylib': False, + 'llvm_dylib_components': 'all', 'fPIC': True, - 'components': 'all', 'targets': 'all', - 'exceptions': True, - 'rtti': True, + 'exceptions': True, # llvm 14 default off + 'rtti': True, # llvm 14 default off 'threads': True, 'lto': 'Off', 'static_stdlib': False, 'unwind_tables': True, 'expensive_checks': False, 'use_perf': False, - 'use_sanitizer': 'None', + 'llvm_use_sanitizer': '', + 'with_z3': False, 'with_ffi': False, 'with_zlib': True, 'with_xml2': True, - 'enable_debug': False, - 'use_llvm_cmake_files': False, + 'keep_binaries_regex': '^$', + + # options removed in package id + 'use_llvm_cmake_files': False, # XXX Should these files used by conan at all? + 'clean_build_bin': True, # prevent 40gb debug build folder + + # creating job pools with current free memory + 'ram_per_compile_job': '2000', + 'ram_per_link_job': '14000', } } - generators = 'cmake_find_package' - @property - def repo_folder(self): - return os.path.join(self.source_folder, self._source_subfolder) + exports_sources = 'patches/**/*' - def project_folder(self, project): - return os.path.join(self.repo_folder, project) + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = 'llvm-project-llvmorg-' + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) - def build_requirements(self): - self.build_requires("cmake/3.21.3") + def is_windows(self): + return self.settings.os == "Windows" + + def is_macos(self): + return self.settings.os == "MacOS" + def is_linux(self): + return self.settings.os == "Linux" + + # checking options before requirements are build def configure(self): + if self.is_windows(): + if is_msvc(self): + if self.options.llvm_build_llvm_dylib: + raise ConanInvalidConfiguration( + "Generating libLLVM is not supported on MSVC" + ) + + # check keep_binaries_regex early to fail early + re.compile(str(self.options.keep_binaries_regex)) + + ver = Version(self.version) + if ver.major < 16: + check_min_cppstd(self, '14') + elif ver.major >= 16: + check_min_cppstd(self, '17') + + for project in projects: + for runtime in runtimes: + if project == runtime and self.options.get_safe('with_project_' + project, False) and self.options.get_safe('with_runtime_' + runtime, False): + raise ConanInvalidConfiguration( + f"Duplicate entry in enabled projects / runtime found for \"with_project_{project}\"") + if self.options.shared: - del self.options.fPIC - if self.settings.os == "Windows": - del self.options.fPIC - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, '14') + if self.options.llvm_build_llvm_dylib: + raise ConanInvalidConfiguration( + "LLVM needs static compilation for dylib.") + self.output.warning( + "BUILD_SHARED_LIBS is only recommended for use by LLVM developers. If you want to build LLVM as a shared library, you should use the LLVM_BUILD_LLVM_DYLIB option.") + + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < Version("10"): + raise ConanInvalidConfiguration( + "Compiler version too low for this package.") + + if is_msvc(self) and Version(self.settings.compiler.version) < Version("16.4"): + raise ConanInvalidConfiguration( + "An up to date version of Microsoft Visual Studio 2019 or newer is required.") + + # XXX configure is called before compiling dependencies, validate after, so to fail as early as possible moved all to configure + # def validate(self): + + def system_requirements(self): + # XXX Still unsure if we should even check for this at all, errors like this would need a lot of fine tuning for each environment to be correct. + if self.is_linux(): + if self.options.get_safe('with_runtime_compiler-rt', False): + # apt should work for ubuntu/debian if apt is not installed this is skipped + if Apt(self).check(["libc6-dev-i386"]): + raise ConanInvalidConfiguration( + "For compiler-rt you need the x86 header bits/libc-header-start.h, please install libc6-dev-i386") + + def requirements(self): + if self.options.with_ffi: + self.requires('libffi/[>3.4.0 <4.0.0]') + if self.options.get_safe('with_zlib', False): + self.requires('zlib/[>1.2.0 <2.0.0]') + if self.options.get_safe('with_xml2', False): + self.requires('libxml2/[>2.9.0 <3.0.0]') + if self.options.get_safe('with_z3', False): + self.requires('z3/[>4.8.0 <5.0.0]') + + def build_requirements(self): + # Older cmake versions may have issues generating the graphviz output used + # to model the components + self.build_requires("cmake/[>=3.21.3 <4.0.0]") + self.build_requires("ninja/[>=1.10.0 <2.0.0]") + + def generate(self): + tc = CMakeToolchain(self, "Ninja") + tc.generate() + + def build(self): + cmake = self._cmake_configure() + cmake.build() def _cmake_configure(self): enabled_projects = [ @@ -151,179 +260,413 @@ def _cmake_configure(self): self.output.info('Enabled LLVM runtimes: {}'.format( ', '.join(enabled_runtimes))) - cmake = CMake(self, parallel=False) - cmake.configure(defs={ - 'BUILD_SHARED_LIBS': False, - 'CMAKE_SKIP_RPATH': True, - 'CMAKE_POSITION_INDEPENDENT_CODE': \ - self.options.get_safe('fPIC', default=False) or self.options.shared, - 'LLVM_TARGET_ARCH': 'host', - 'LLVM_TARGETS_TO_BUILD': self.options.targets, - 'LLVM_BUILD_LLVM_DYLIB': self.options.shared, - 'LLVM_DYLIB_COMPONENTS': self.options.components, - 'LLVM_ENABLE_PIC': self.options.get_safe('fPIC', default=False), - 'LLVM_ABI_BREAKING_CHECKS': 'WITH_ASSERTS', - 'LLVM_ENABLE_WARNINGS': True, - 'LLVM_ENABLE_PEDANTIC': True, - 'LLVM_ENABLE_WERROR': False, - 'LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN': True, - 'LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO': False, - 'LLVM_BUILD_INSTRUMENTED_COVERAGE': False, - 'LLVM_OPTIMIZED_TABLEGEN': True, - 'LLVM_REVERSE_ITERATION': False, - 'LLVM_ENABLE_BINDINGS': False, - 'LLVM_CCACHE_BUILD': False, - 'LLVM_INCLUDE_TOOLS': self.options.shared, - 'LLVM_INCLUDE_EXAMPLES': False, - 'LLVM_INCLUDE_TESTS': False, - 'LLVM_INCLUDE_BENCHMARKS': False, - 'LLVM_APPEND_VC_REV': False, - 'LLVM_BUILD_DOCS': False, - 'LLVM_ENABLE_IDE': False, - 'LLVM_ENABLE_TERMINFO': False, - 'LLVM_ENABLE_EH': self.options.exceptions, - 'LLVM_ENABLE_RTTI': self.options.rtti, - 'LLVM_ENABLE_THREADS': self.options.threads, - 'LLVM_ENABLE_LTO': self.options.lto, - 'LLVM_STATIC_LINK_CXX_STDLIB': self.options.static_stdlib, - 'LLVM_ENABLE_UNWIND_TABLES': self.options.unwind_tables, - 'LLVM_ENABLE_EXPENSIVE_CHECKS': self.options.expensive_checks, - 'LLVM_ENABLE_ASSERTIONS': self.settings.build_type == 'Debug', - 'LLVM_USE_NEWPM': False, - 'LLVM_USE_OPROFILE': False, - 'LLVM_USE_PERF': self.options.use_perf, - 'LLVM_ENABLE_Z3_SOLVER': False, - 'LLVM_ENABLE_LIBPFM': False, - 'LLVM_ENABLE_LIBEDIT': False, - 'LLVM_ENABLE_FFI': self.options.with_ffi, - 'LLVM_ENABLE_ZLIB': self.options.get_safe('with_zlib', False), - 'LLVM_ENABLE_LIBXML2': self.options.get_safe('with_xml2', False), - 'LLVM_ENABLE_PROJECTS': ';'.join(enabled_projects), - 'LLVM_ENABLE_RUNTIMES': ';'.join(enabled_runtimes), - 'LLVM_ENABLE_BINDINGS': False, - 'LLVM_ENABLE_RTTI': self.options.rtti, - }, - source_folder=os.path.join(self._source_subfolder, - 'llvm')) - if not self.options.shared: - cmake.definitions['DISABLE_LLVM_LINK_LLVM_DYLIB'] = True - if self.settings.compiler == 'Visual Studio': + cmake = CMake(self) + # https://releases.llvm.org/13.0.0/docs/CMake.html + # https://releases.llvm.org/14.0.0/docs/CMake.html + # https://releases.llvm.org/15.0.0/docs/CMake.html + # https://releases.llvm.org/16.0.0/docs/CMake.html + # https://llvm.org/docs/CMake.html#frequently-used-llvm-related-variables + cmake.configure( + cli_args=['--graphviz=graph/llvm.dot'], + variables={ + 'BUILD_SHARED_LIBS': self.options.shared, + 'LIBOMP_ENABLE_SHARED': self.options.shared, + # cmake RPATH handling https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#default-rpath-settings + # default behaviour for RPATH is to clear it on install + # skipping RPATH for build affects also RUNPATH but + # llvm-tblgen with BUILD_SHARED_LIBS needs it during build else build invocation fails because .so not found + # e.g. readelf -d bin/llvm-tblgen shows RUNPATH $ORIGIN/../lib for build and install location, which is fine in every case. + # Only if executed with elevated privileges this is ignored because of security concerns (it contains $ORIGIN and isn't absolute). + # CMAKE_SKIP_RPATH # default is fine, kept for documentation. + 'LLVM_TARGET_ARCH': 'host', + 'LLVM_TARGETS_TO_BUILD': self.options.targets, + 'LLVM_BUILD_LLVM_DYLIB': self.options.llvm_build_llvm_dylib, + 'LLVM_DYLIB_COMPONENTS': self.options.llvm_dylib_components, + 'LLVM_LINK_LLVM_DYLIB': self.options.llvm_link_llvm_dylib, + # llvm default on + 'LLVM_ENABLE_PIC': self.options.get_safe('fPIC', default=False), + 'LLVM_ABI_BREAKING_CHECKS': 'WITH_ASSERTS', + 'LLVM_ENABLE_WARNINGS': True, + 'LLVM_ENABLE_PEDANTIC': True, + 'LLVM_ENABLE_WERROR': False, + # from llvm-core: + # 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. + 'LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN': True, + 'LLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO': False, + 'LLVM_BUILD_INSTRUMENTED_COVERAGE': False, + 'LLVM_OPTIMIZED_TABLEGEN': True, # NOT default, can speedup compilation a lot + 'LLVM_REVERSE_ITERATION': False, + 'LLVM_ENABLE_BINDINGS': False, # NOT default, dont build OCaml and go bindings + 'LLVM_CCACHE_BUILD': False, + 'LLVM_INCLUDE_TOOLS': True, + 'LLVM_INCLUDE_EXAMPLES': False, # NOT default + 'LLVM_BUILD_TESTS': False, + 'LLVM_INCLUDE_TESTS': False, # NOT default + 'LLVM_INCLUDE_BENCHMARKS': False, + 'LLVM_APPEND_VC_REV': True, + 'LLVM_BUILD_DOCS': False, + 'LLVM_ENABLE_IDE': False, + # NOT default Use terminfo database if available. + 'LLVM_ENABLE_TERMINFO': False, + 'LLVM_ENABLE_EH': self.options.exceptions, + 'LLVM_ENABLE_RTTI': self.options.rtti, + 'LLVM_ENABLE_THREADS': self.options.threads, + 'LLVM_ENABLE_LTO': self.options.lto, + 'LLVM_STATIC_LINK_CXX_STDLIB': self.options.static_stdlib, + 'LLVM_ENABLE_UNWIND_TABLES': self.options.unwind_tables, + 'LLVM_ENABLE_EXPENSIVE_CHECKS': self.options.expensive_checks, + 'LLVM_ENABLE_ASSERTIONS': self.settings.build_type == 'Debug', + 'LLVM_USE_NEWPM': False, + 'LLVM_USE_OPROFILE': False, + 'LLVM_USE_PERF': self.options.use_perf, + 'LLVM_ENABLE_Z3_SOLVER': self.options.with_z3, + 'LLVM_ENABLE_LIBPFM': False, + 'LLVM_ENABLE_LIBEDIT': False, + 'LLVM_ENABLE_FFI': self.options.with_ffi, + 'LLVM_ENABLE_ZLIB': self.options.get_safe('with_zlib', False), + 'LLVM_ENABLE_LIBXML2': self.options.get_safe('with_xml2', False), + 'LLVM_ENABLE_PROJECTS': ';'.join(enabled_projects), + 'LLVM_ENABLE_RUNTIMES': ';'.join(enabled_runtimes), + 'LLVM_USE_SANITIZER': self.options.llvm_use_sanitizer, + 'LLVM_RAM_PER_COMPILE_JOB': self.options.ram_per_compile_job, + 'LLVM_RAM_PER_LINK_JOB': self.options.ram_per_link_job + }, + build_script_folder=os.path.join(self.source_folder, 'llvm')) + if is_msvc(self): build_type = str(self.settings.build_type).upper() - cmake.definitions['LLVM_USE_CRT_{}'.format(build_type)] = \ - self.settings.compiler.runtime - if self.options.use_sanitizer == 'None': - cmake.definitions['LLVM_USE_SANITIZER'] = '' - else: - cmake.definitions['LLVM_USE_SANITIZER'] = self.options.use_sanitizer + cmake._cache_variables.update( + { + f"LLVM_USE_CRT_{build_type}": self.settings.compiler.runtime + } + ) return cmake - def build(self): - cmake = self._cmake_configure() - cmake.build() - - def package(self): - cmake = self._cmake_configure() - cmake.install() - - self.copy('LICENSE.TXT', - src=self.project_folder('clang'), - dst='licenses', - keep_path=False) - - ignore = ['share', 'libexec', '**/Find*.cmake', '**/*Config.cmake'] - + def _is_installed_llvm_lib(self, target_name): + """Is the given target installed by llvm? Is it a library?""" + package_lib_folder = os.path.join(self.package_folder, "lib") + return os.path.exists(os.path.join(package_lib_folder, f"lib{target_name}.a")) or \ + os.path.exists(os.path.join(package_lib_folder, f"lib{target_name}.so")) or \ + os.path.exists(os.path.join( + package_lib_folder, f"lib{target_name}.dylib")) + + def _is_shared_llvm_lib(self, target_name): + """Depending on llvm configuration there are static and shared libraries, so options.shared isn't correct.""" + package_lib_folder = os.path.join(self.package_folder, "lib") + return os.path.exists(os.path.join(package_lib_folder, f"lib{target_name}.so")) or \ + os.path.exists(os.path.join( + package_lib_folder, f"lib{target_name}.dylib")) + + def _package_bin(self): + """Keep binaries which are matching recipe option keep_binaries_regex. + Keeps also links in between, removes everything else. + Returns list of all binaries.""" + bin_matcher = re.compile(str(self.options.keep_binaries_regex)) + keep_binaries = [] + # resolve binaries to keep which are links, so we need to keep link target as well. + # Binaries are also used to skip targets + build_bin_path = os.path.join(self.build_folder, 'bin') + package_bin_path = os.path.join(self.package_folder, 'bin') + # missed targets by the method below + binaries = ["lldb-test", "clang-fuzzer", "clang-objc-fuzzer"] + binaries.extend(os.listdir(build_bin_path)) + binaries.extend(os.listdir(package_bin_path)) + binaries = list(set(binaries)) + binaries.sort() + for bin in binaries: + if bin_matcher.match(bin): + keep_binaries.append(bin) + current_bin = bin + # there are links like clang++ -> clang -> clang-14 + while os.path.islink(os.path.join('bin', current_bin)): + current_bin = os.path.basename( + os.readlink(os.path.join('bin', current_bin))) + keep_binaries.append(current_bin) + + # remove unneccessary binaries from package + for bin in binaries: + bin_path = os.path.join(package_bin_path, bin) + if bin in keep_binaries: + self.output.info(f"Keeping binary \"{bin}\" from package") + elif os.path.isfile(bin_path) or os.path.islink(bin_path): + self.output.info(f"Removing binary \"{bin}\" from package") + os.remove(bin_path) + + return binaries + + def _package_various_removing(self): + # remove unneccessary files from package + ignore = ["share", "libexec", "**/Find*.cmake", "**/*Config.cmake"] for ignore_entry in ignore: ignore_glob = os.path.join(self.package_folder, ignore_entry) for ignore_path in glob.glob(ignore_glob, recursive=True): self.output.info( - 'Remove ignored file/directory "{}" from package'.format( - ignore_path)) + 'Removing ignored file/directory "{}" from package'.format(ignore_path)) if os.path.isfile(ignore_path): os.remove(ignore_path) else: shutil.rmtree(ignore_path) - def package_id(self): - del self.info.options.enable_debug - del self.info.options.use_llvm_cmake_files + # remove binaries from build, in debug builds these can take 40gb of disk space but are fast to recreate + if self.options.clean_build_bin: + rmdir(self, os.path.join(self.build_folder, 'bin')) - def validate(self): - if self.settings.compiler == "gcc" and tools.Version( - self.settings.compiler.version) < "10": - raise ConanInvalidConfiguration( - "Compiler version too low for this package.") + def package(self): + cmake = self._cmake_configure() + cmake.install() - if (self.settings.compiler == "Visual Studio" - or self.settings.compiler == "msvc") and Version( - self.settings.compiler.version) < "16.4": - raise ConanInvalidConfiguration( - "An up to date version of Microsoft Visual Studio 2019 or newer is required." - ) + copy(self, + "LICENSE.TXT", + src=os.path.join(self.source_folder, "clang"), + dst="licenses", + keep_path=False, + ) + + binaries = self._package_bin() + self._package_various_removing() + + # creating dependency graph + # from: libA -> libB -> obj... -> libSystem + # to: libA -> libB, libB -> libSystem + with chdir(self, 'graph'): + dot_text = load(self, 'llvm.dot').replace('\r\n', '\n') + dep_regex = re.compile(r'//\s(.+)\s->\s(.+)$', re.MULTILINE) + deps = re.findall(dep_regex, dot_text) + + # map dependency names + external_targets = { + 'libffi::libffi': 'ffi', + 'ZLIB::ZLIB': 'z', + 'Iconv::Iconv': 'iconv', + 'libxml2::libxml2': 'xml2', + 'pthread': 'pthread', + 'rt': "rt", + 'm': "m", + 'dl': 'dl' + } + external_targets_keys = external_targets.keys() + dummy_targets = defaultdict(list) + for target, dep in deps: + if not self._is_installed_llvm_lib(target) and target not in external_targets_keys: + dummy_targets[target].append(dep) + dummy_targets_keys = dummy_targets.keys() + + # fill components with relevant targets + # relevant = installed by llvm and is a lib + components = defaultdict(list) + ignored_deps = [] + for lib, dep in deps: + if lib in binaries: + continue + + if self._is_installed_llvm_lib(lib): + components[lib] + + if isinstance(dep, list): + current_deps = dep + elif " " in dep: + current_deps = dep.split() # lib: omp dep: str(-lpthread -lrt) + else: + current_deps = [dep] + + visited = components[lib].copy() + while len(current_deps) > 0: + current_dep = current_deps.pop() + visited.append(current_dep) + + if current_dep in binaries: + continue + elif self._is_installed_llvm_lib(current_dep): + components[current_dep] + + # Copied from llvm-core but not used on linux, maybe for other systems? ==> + elif current_dep.startswith('-delayload:'): + continue + + elif os.path.exists(current_dep): + current_dep = os.path.splitext( + os.path.basename(current_dep))[0] + current_dep = current_dep.replace('lib', '') + # <== + + # e.g. -lpthread -> pthread + if current_dep.startswith("-l"): + current_dep = current_dep[2:] + + if current_dep in dummy_targets_keys: + for d in dummy_targets[current_dep]: + if not visited: + current_deps.append(d) + elif self._is_installed_llvm_lib(current_dep): + # Because .a and .so are mixed for specific llvm configuration, check if the file is actually shared + # shared files contain their internal dependencies in elf header, we dont need to handle them + if not self._is_shared_llvm_lib(current_dep): + components[lib].append(current_dep) + elif current_dep in external_targets_keys: + components[lib].append(external_targets[current_dep]) + else: + ignored_deps.append(current_dep) + components[lib] = list(set(components[lib])) + if lib in components[lib]: + raise ConanException( + f"Conan recipe error, found circular dependency for {lib} over {dep}") + ignored_deps = list(set(ignored_deps)) + self.output.info( + f'ignored these dependencies, will not propagate these to conan: {ignored_deps}') + + # .so already containing .a, so clear deps of e.g. LLVM.so which are installed by LLVM itself + # every component which is in is available = installed + for shared_component in components: + if self._is_shared_llvm_lib(shared_component): + external_dependencies = [] + for dep in components[shared_component]: + if not self._is_installed_llvm_lib(current_dep): + external_dependencies.append(dep) + components[shared_component] = external_dependencies + + # workaround for circular dependencies which will create errors in conan + remove_dependencies = [ + ('lldbBreakpoint', 'lldbCore'), + ('lldbBreakpoint', 'lldbTarget'), + ('lldbPluginCPlusPlusLanguage', 'lldbCore'), + ('lldbPluginObjCLanguage', 'lldbCore'), + ('lldbTarget', 'lldbCore'), + ('lldbInterpreter', 'lldbCore'), + ('lldbSymbol', 'lldbCore'), + ('lldbDataFormatters', 'lldbCore'), + ('lldbExpression', 'lldbCore'), + ('lldbDataFormatters', 'lldbInterpreter'), + ('lldbTarget', 'lldbInterpreter'), + ('lldbInterpreter', 'lldbCommands'), + ('lldbCommands', 'lldbInterpreter'), + ('lldbExpression', 'lldbTarget'), + ('lldbExpression', 'lldbSymbol'), + ('lldbSymbol', 'lldbTarget'), + ('lldbSymbol', 'lldbExpression'), + ('lldbTarget', 'lldbSymbol'), + ('lldbTarget', 'lldbPluginProcessUtility'), + ('lldbTarget', 'lldbExpression'), + ('lldbPluginProcessUtility', 'lldbTarget'), + ('lldbPluginExpressionParserClang', 'lldbPluginTypeSystemClang'), + ('lldbPluginTypeSystemClang', 'lldbPluginSymbolFileDWARF'), + ('lldbPluginTypeSystemClang', 'lldbPluginExpressionParserClang'), + ('lldbPluginTypeSystemClang', 'lldbPluginSymbolFilePDB'), + ('lldbPluginSymbolFileDWARF', 'lldbPluginTypeSystemClang'), + ('lldbPluginSymbolFilePDB', 'lldbPluginTypeSystemClang'), + ('lldbPluginDynamicLoaderPosixDYLD', 'lldbPluginProcessElfCore'), + ('lldbPluginProcessElfCore', 'lldbPluginDynamicLoaderPosixDYLD'), + ] + keys = components.keys() + + # remove circular dependencies in components + for target, remove in remove_dependencies: + if target in keys: + if remove in components[target]: + components[target].remove(remove) + if target in components[remove]: + components[remove].remove(target) + found_circular_dep = False + for c in keys: + for c_dep in components[c]: + if c_dep in keys: + if c in components[c_dep]: + self.output.error( + f"circular dependency found: {c} -> {c_dep} -> {c}") + found_circular_dep = True + if found_circular_dep: + raise ConanException( + f"circular dependency found, see error log above") + + # manually fix some dependencies + if self.options.get_safe('with_zlib', False): + if not 'z' in components['LLVMSupport']: + components['LLVMSupport'].append('z') + + # fix: ERROR: llvm/14.0.6@...: Required package 'libxml2' not in component 'requires' + xml2_linking = ["LLVMWindowsManifest", "lldbHost", "c-index-test"] + report_xml2_issue = self.options.with_xml2 + if self.options.with_xml2: + for component in xml2_linking: + if component in components: + components[component].append( + "xml2") + self.output.info( + f"forced dependency to \"xml2\" for target {component}") + report_xml2_issue = False + + # XXX could be an issue in libxml2 recipe? + # ld: error: undefined symbol: libiconv_open, libiconv_close, libiconv in libxml2_la-encoding + component = "lldbHost" + if component in components: + components[component].append("iconv") + self.output.info( + f"forced dependency to \"iconv\" for target {component}") + if report_xml2_issue: + raise "Recipe issue in llvm/*:with_xml2=True is set but no component requires it, this will only error if consumed." - if self.settings.build_type == "Debug" and not self.options.enable_debug: - raise ConanInvalidConfiguration( - "Set the 'enable_debug' option to allow debug builds") + # write components.json for package_info + 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) + + def package_id(self): + del self.info.options.use_llvm_cmake_files + del self.info.options.clean_build_bin + del self.info.options.ram_per_compile_job + del self.info.options.ram_per_link_job def package_info(self): + module_subfolder = os.path.join("lib", "cmake") self.cpp_info.set_property("cmake_file_name", "LLVM") - if self.options.shared: - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == 'Linux': - self.cpp_info.system_libs = ['pthread', 'rt', 'dl', 'm'] - elif self.settings.os == 'Macos': - self.cpp_info.system_libs = ['m'] - return - 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 = { + external_targets = { 'ffi': 'libffi::libffi', 'z': 'zlib::zlib', - 'xml2': 'libxml2::libxml2' + 'xml2': 'libxml2::libxml2', + 'iconv': 'Iconv::Iconv', } for component, deps in components.items(): self.cpp_info.components[component].libs = [component] - self.cpp_info.components[component].requires.extend(dep for dep in deps if dep.startswith('LLVM')) + self.cpp_info.components[component].requires.extend( + dep for dep in deps if self._is_installed_llvm_lib(dep)) - for lib, target in targets.items(): + for lib, target in external_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 + if not self._is_installed_llvm_lib(dep) and dep not in external_targets.keys() ] - self.cpp_info.components[component].set_property("cmake_target_name", component) - self.cpp_info.components[component].builddirs.append(self._module_subfolder) - - self.cpp_info.components[component].names["cmake_find_package"] = component - self.cpp_info.components[component].names["cmake_find_package_multi"] = component - self.cpp_info.components[component].build_modules["cmake_find_package"].extend([ - self._alias_module_file_rel_path, - self._old_alias_module_file_rel_path, - ]) - self.cpp_info.components[component].build_modules["cmake_find_package_multi"].extend([ - self._alias_module_file_rel_path, - self._old_alias_module_file_rel_path, - ]) + self.cpp_info.components[component].set_property( + "cmake_target_name", component) + self.cpp_info.components[component].builddirs.append( + module_subfolder) + self.cpp_info.components[component].set_property( + "cmake_find_package", component) + self.cpp_info.components[component].set_property( + "cmake_find_package_multi", component) if self.options.use_llvm_cmake_files: self.cpp_info.components[component].build_modules["cmake_find_package"].append( - os.path.join(self._module_subfolder, "LLVMConfigInternal.cmake") + os.path.join(module_subfolder, + "LLVMConfigInternal.cmake") ) self.cpp_info.components[component].build_modules["cmake_find_package_multi"].append( - os.path.join(self._module_subfolder, "LLVMConfigInternal.cmake") + os.path.join(module_subfolder, + "LLVMConfigInternal.cmake") ) - # TODO: to remove in conan v2 once cmake_find_package* generators removed - self.cpp_info.names["cmake_find_package"] = "LLVM" - self.cpp_info.names["cmake_find_package_multi"] = "LLVM" + self.output.info( + "checking if all dependencies added to llvm are referenced by any exposed target") + self.cpp_info.check_component_requires(self) diff --git a/recipes/llvm/all/patches/13/WindowsManifest_libxml2_folder.patch b/recipes/llvm/all/patches/13/WindowsManifest_libxml2_folder.patch new file mode 100644 index 0000000000000..8d0d3b723fe25 --- /dev/null +++ b/recipes/llvm/all/patches/13/WindowsManifest_libxml2_folder.patch @@ -0,0 +1,34 @@ +diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt +index ceef4b08637c..1f9337bb31f0 100644 +--- a/clang/tools/c-index-test/CMakeLists.txt ++++ b/clang/tools/c-index-test/CMakeLists.txt +@@ -40,11 +40,7 @@ set_target_properties(c-index-test + + # If libxml2 is available, make it available for c-index-test. + if (CLANG_HAVE_LIBXML) +- if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})) +- include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}) +- else() +- include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR}) +- endif() ++ include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR}) + target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES}) + endif() + +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 8134ac8c815b..d089ee076348 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -24,10 +24,10 @@ if(LLVM_ENABLE_LIBXML2) + # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. + if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) ++ find_library(libxml2_library NAME xml2 PATHS ${LibXml2_LIB_DIRS} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif() + if(NOT zlib_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) ++ find_library(libxml2_library NAME xml2 PATHS ${LibXml2_LIB_DIRS} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif() + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) diff --git a/recipes/llvm/all/patches/13/calculate_job_pools.patch b/recipes/llvm/all/patches/13/calculate_job_pools.patch new file mode 100644 index 0000000000000..cc74107ac53cd --- /dev/null +++ b/recipes/llvm/all/patches/13/calculate_job_pools.patch @@ -0,0 +1,52 @@ +diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake +index 0c3419390c27..8bcd91e17872 100644 +--- a/llvm/cmake/modules/HandleLLVMOptions.cmake ++++ b/llvm/cmake/modules/HandleLLVMOptions.cmake +@@ -31,8 +31,24 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) + + # Ninja Job Pool support + # The following only works with the Ninja generator in CMake >= 3.0. ++if (NOT LLVM_RAM_PER_COMPILE_JOB) ++ set(LLVM_RAM_PER_COMPILE_JOB "2000") ++endif() + set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING + "Define the maximum number of concurrent compilation jobs (Ninja only).") ++cmake_host_system_information(RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY) ++cmake_host_system_information(RESULT NUMBER_OF_LOGICAL_CORES QUERY NUMBER_OF_LOGICAL_CORES) ++if(LLVM_RAM_PER_COMPILE_JOB) ++ math(EXPR memory_available_jobs "${AVAILABLE_PHYSICAL_MEMORY} / ${LLVM_RAM_PER_COMPILE_JOB}" OUTPUT_FORMAT DECIMAL) ++ if (memory_available_jobs LESS 1) ++ set(memory_available_jobs 1) ++ endif() ++ if (memory_available_jobs LESS NUMBER_OF_LOGICAL_CORES) ++ set(LLVM_PARALLEL_COMPILE_JOBS "${memory_available_jobs}") ++ else() ++ set(LLVM_PARALLEL_COMPILE_JOBS "${NUMBER_OF_LOGICAL_CORES}") ++ endif() ++endif() + if(LLVM_PARALLEL_COMPILE_JOBS) + if(NOT CMAKE_GENERATOR STREQUAL "Ninja") + message(WARNING "Job pooling is only available with Ninja generators.") +@@ -42,8 +58,22 @@ if(LLVM_PARALLEL_COMPILE_JOBS) + endif() + endif() + ++if (NOT LLVM_RAM_PER_LINK_JOB) ++ set(LLVM_RAM_PER_LINK_JOB "14000") ++endif() + set(LLVM_PARALLEL_LINK_JOBS "" CACHE STRING + "Define the maximum number of concurrent link jobs (Ninja only).") ++if(LLVM_RAM_PER_LINK_JOB) ++ math(EXPR memory_available_jobs "${AVAILABLE_PHYSICAL_MEMORY} / ${LLVM_RAM_PER_LINK_JOB}" OUTPUT_FORMAT DECIMAL) ++ if (memory_available_jobs LESS 1) ++ set(memory_available_jobs 1) ++ endif() ++ if (memory_available_jobs LESS NUMBER_OF_LOGICAL_CORES) ++ set(LLVM_PARALLEL_LINK_JOBS "${memory_available_jobs}") ++ else() ++ set(LLVM_PARALLEL_LINK_JOBS "${NUMBER_OF_LOGICAL_CORES}") ++ endif() ++endif() + if(CMAKE_GENERATOR STREQUAL "Ninja") + if(NOT LLVM_PARALLEL_LINK_JOBS AND uppercase_LLVM_ENABLE_LTO STREQUAL "THIN") + message(STATUS "ThinLTO provides its own parallel linking - limiting parallel link jobs to 2.") diff --git a/recipes/llvm/all/patches/13/fix_xml2_library_name.patch b/recipes/llvm/all/patches/13/fix_xml2_library_name.patch new file mode 100644 index 0000000000000..9acb884e8eafd --- /dev/null +++ b/recipes/llvm/all/patches/13/fix_xml2_library_name.patch @@ -0,0 +1,84 @@ +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt +index 95cdbd8f6663..7a862acc7634 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -204,7 +204,7 @@ if(LLVM_ENABLE_LIBXML2) + # code may call MSan interceptors like strlen, leading to false positives. + if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + set (LIBXML2_FOUND 0) +- find_package(LibXml2 2.5.3 QUIET) ++ find_package(libxml2 2.5.3 QUIET) + if (LIBXML2_FOUND) + set(CLANG_HAVE_LIBXML 1) + endif() +diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake +index b62cd7d24438..cb7afeeed16e 100644 +--- a/lldb/cmake/modules/LLDBConfig.cmake ++++ b/lldb/cmake/modules/LLDBConfig.cmake +@@ -57,7 +57,7 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" Curse + add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND) + add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND) + add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND) +-add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8) ++add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" libxml2 LIBXML2_FOUND VERSION 2.8) + + option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF) + option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON) +diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake +index dd0aaadb47c7..e42b9f654193 100644 +--- a/llvm/cmake/config-ix.cmake ++++ b/llvm/cmake/config-ix.cmake +@@ -139,11 +139,11 @@ endif() + + if(LLVM_ENABLE_LIBXML2) + if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON) +- find_package(LibXml2 REQUIRED) ++ find_package(libxml2 REQUIRED) + elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") +- find_package(LibXml2) ++ find_package(libxml2) + endif() +- if(LibXml2_FOUND) ++ if(libxml2_FOUND) + # Check if libxml2 we found is usable; for example, we may have found a 32-bit + # library on a 64-bit system which would result in a link-time failure. + cmake_push_check_state() +diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in +index 60b56b5152ea..9ddb2d08e57f 100644 +--- a/llvm/cmake/modules/LLVMConfig.cmake.in ++++ b/llvm/cmake/modules/LLVMConfig.cmake.in +@@ -63,7 +63,7 @@ endif() + + set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@) + if(LLVM_ENABLE_LIBXML2) +- find_package(LibXml2) ++ find_package(libxml2) + endif() + + set(LLVM_WITH_Z3 @LLVM_WITH_Z3@) +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 8134ac8c815b..19cd38c40cd5 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -1,7 +1,7 @@ + include(GetLibraryName) + + if(LLVM_ENABLE_LIBXML2) +- set(imported_libs LibXml2::LibXml2) ++ set(imported_libs libxml2::libxml2) + endif() + + add_llvm_component_library(LLVMWindowsManifest +@@ -24,10 +24,10 @@ if(LLVM_ENABLE_LIBXML2) + # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. + if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) ++ get_property(libxml2_library TARGET libxml2::libxml2 PROPERTY LOCATION_${build_type}) + endif() + if(NOT zlib_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) ++ get_property(libxml2_library TARGET libxml2::libxml2 PROPERTY LOCATION) + endif() + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) diff --git a/recipes/llvm/all/patches/14/WindowsManifest_libxml2_folder.patch b/recipes/llvm/all/patches/14/WindowsManifest_libxml2_folder.patch new file mode 100644 index 0000000000000..3b893a85028c0 --- /dev/null +++ b/recipes/llvm/all/patches/14/WindowsManifest_libxml2_folder.patch @@ -0,0 +1,17 @@ +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 8134ac8c815b..d089ee076348 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -24,10 +24,10 @@ if(LLVM_ENABLE_LIBXML2) + # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. + if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) ++ find_library(libxml2_library NAME xml2 PATHS ${LibXml2_LIB_DIRS} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif() + if(NOT zlib_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) ++ find_library(libxml2_library NAME xml2 PATHS ${LibXml2_LIB_DIRS} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif() + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) diff --git a/recipes/llvm/all/patches/14/calculate_job_pools.patch b/recipes/llvm/all/patches/14/calculate_job_pools.patch new file mode 100644 index 0000000000000..c8176810bb6ae --- /dev/null +++ b/recipes/llvm/all/patches/14/calculate_job_pools.patch @@ -0,0 +1,53 @@ +diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake +index fcaa8f20bf94..00c6fbf6fa8e 100644 +--- a/llvm/cmake/modules/HandleLLVMOptions.cmake ++++ b/llvm/cmake/modules/HandleLLVMOptions.cmake +@@ -31,8 +31,25 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) + + # Ninja Job Pool support + # The following only works with the Ninja generator in CMake >= 3.0. ++if (NOT LLVM_RAM_PER_COMPILE_JOB) ++ set(LLVM_RAM_PER_COMPILE_JOB "2000") ++endif() + set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING + "Define the maximum number of concurrent compilation jobs (Ninja only).") ++ ++cmake_host_system_information(RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY) ++cmake_host_system_information(RESULT NUMBER_OF_LOGICAL_CORES QUERY NUMBER_OF_LOGICAL_CORES) ++if(LLVM_RAM_PER_COMPILE_JOB) ++ math(EXPR memory_available_jobs "${AVAILABLE_PHYSICAL_MEMORY} / ${LLVM_RAM_PER_COMPILE_JOB}" OUTPUT_FORMAT DECIMAL) ++ if (memory_available_jobs LESS 1) ++ set(memory_available_jobs 1) ++ endif() ++ if (memory_available_jobs LESS NUMBER_OF_LOGICAL_CORES) ++ set(LLVM_PARALLEL_COMPILE_JOBS "${memory_available_jobs}") ++ else() ++ set(LLVM_PARALLEL_COMPILE_JOBS "${NUMBER_OF_LOGICAL_CORES}") ++ endif() ++endif() + if(LLVM_PARALLEL_COMPILE_JOBS) + if(NOT CMAKE_GENERATOR MATCHES "Ninja") + message(WARNING "Job pooling is only available with Ninja generators.") +@@ -42,8 +59,22 @@ if(LLVM_PARALLEL_COMPILE_JOBS) + endif() + endif() + ++if (NOT LLVM_RAM_PER_LINK_JOB) ++ set(LLVM_RAM_PER_LINK_JOB "14000") ++endif() + set(LLVM_PARALLEL_LINK_JOBS "" CACHE STRING + "Define the maximum number of concurrent link jobs (Ninja only).") ++if(LLVM_RAM_PER_LINK_JOB) ++ math(EXPR memory_available_jobs "${AVAILABLE_PHYSICAL_MEMORY} / ${LLVM_RAM_PER_LINK_JOB}" OUTPUT_FORMAT DECIMAL) ++ if (memory_available_jobs LESS 1) ++ set(memory_available_jobs 1) ++ endif() ++ if (memory_available_jobs LESS NUMBER_OF_LOGICAL_CORES) ++ set(LLVM_PARALLEL_LINK_JOBS "${memory_available_jobs}") ++ else() ++ set(LLVM_PARALLEL_LINK_JOBS "${NUMBER_OF_LOGICAL_CORES}") ++ endif() ++endif() + if(CMAKE_GENERATOR MATCHES "Ninja") + if(NOT LLVM_PARALLEL_LINK_JOBS AND uppercase_LLVM_ENABLE_LTO STREQUAL "THIN") + message(STATUS "ThinLTO provides its own parallel linking - limiting parallel link jobs to 2.") diff --git a/recipes/llvm/all/patches/14/fix_xml2_library_name.patch b/recipes/llvm/all/patches/14/fix_xml2_library_name.patch new file mode 100644 index 0000000000000..3f3db45e10700 --- /dev/null +++ b/recipes/llvm/all/patches/14/fix_xml2_library_name.patch @@ -0,0 +1,110 @@ +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt +index 937a8467df1d..13c7191e51c7 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -214,7 +214,7 @@ if(LLVM_ENABLE_LIBXML2) + # code may call MSan interceptors like strlen, leading to false positives. + if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + set (LIBXML2_FOUND 0) +- find_package(LibXml2 2.5.3 QUIET) ++ find_package(libxml2 2.5.3 QUIET) + if (LIBXML2_FOUND) + set(CLANG_HAVE_LIBXML 1) + endif() +diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt +index 0ae1b4e55244..62bdb4b9a157 100644 +--- a/clang/tools/c-index-test/CMakeLists.txt ++++ b/clang/tools/c-index-test/CMakeLists.txt +@@ -40,7 +40,7 @@ set_target_properties(c-index-test + + # If libxml2 is available, make it available for c-index-test. + if (CLANG_HAVE_LIBXML) +- target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2) ++ target_link_libraries(c-index-test PRIVATE libxml2::libxml2) + endif() + + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) +diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake +index e12e548ad0c4..aaec051e7676 100644 +--- a/lldb/cmake/modules/LLDBConfig.cmake ++++ b/lldb/cmake/modules/LLDBConfig.cmake +@@ -61,7 +61,7 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" Curse + add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND) + add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND) + add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND) +-add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8) ++add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" libxml2 LIBXML2_FOUND VERSION 2.8) + add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support in LLDB" FBSDVMCore FBSDVMCore_FOUND QUIET) + + option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF) +diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt +index 4374abca0506..df7a260696dd 100644 +--- a/lldb/source/Host/CMakeLists.txt ++++ b/lldb/source/Host/CMakeLists.txt +@@ -136,7 +136,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "NetBSD") + list(APPEND EXTRA_LIBS kvm) + endif() + if (LLDB_ENABLE_LIBXML2) +- list(APPEND EXTRA_LIBS LibXml2::LibXml2) ++ list(APPEND EXTRA_LIBS libxml2::libxml2) + endif() + if (HAVE_LIBDL) + list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS}) +diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake +index 18d78879c968..4e5737f4c049 100644 +--- a/llvm/cmake/config-ix.cmake ++++ b/llvm/cmake/config-ix.cmake +@@ -139,11 +139,11 @@ endif() + + if(LLVM_ENABLE_LIBXML2) + if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON) +- find_package(LibXml2 REQUIRED) ++ find_package(libxml2 REQUIRED) + elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") +- find_package(LibXml2) ++ find_package(libxml2) + endif() +- if(LibXml2_FOUND) ++ if(libxml2_FOUND) + # Check if libxml2 we found is usable; for example, we may have found a 32-bit + # library on a 64-bit system which would result in a link-time failure. + cmake_push_check_state() +diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in +index e1540ff316f7..7ad29a22830c 100644 +--- a/llvm/cmake/modules/LLVMConfig.cmake.in ++++ b/llvm/cmake/modules/LLVMConfig.cmake.in +@@ -75,7 +75,7 @@ endif() + + set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@) + if(LLVM_ENABLE_LIBXML2) +- find_package(LibXml2) ++ find_package(libxml2) + endif() + + set(LLVM_WITH_Z3 @LLVM_WITH_Z3@) +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 8134ac8c815b..19cd38c40cd5 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -1,7 +1,7 @@ + include(GetLibraryName) + + if(LLVM_ENABLE_LIBXML2) +- set(imported_libs LibXml2::LibXml2) ++ set(imported_libs libxml2::libxml2) + endif() + + add_llvm_component_library(LLVMWindowsManifest +@@ -24,10 +24,10 @@ if(LLVM_ENABLE_LIBXML2) + # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. + if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) ++ get_property(libxml2_library TARGET libxml2::libxml2 PROPERTY LOCATION_${build_type}) + endif() + if(NOT zlib_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) ++ get_property(libxml2_library TARGET libxml2::libxml2 PROPERTY LOCATION) + endif() + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) diff --git a/recipes/llvm/all/patches/15/WindowsManifest_libxml2_folder.patch b/recipes/llvm/all/patches/15/WindowsManifest_libxml2_folder.patch new file mode 100644 index 0000000000000..71bf51abc3455 --- /dev/null +++ b/recipes/llvm/all/patches/15/WindowsManifest_libxml2_folder.patch @@ -0,0 +1,17 @@ +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 910132a4c7de..915d01d6ddc3 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -24,10 +24,10 @@ if(LLVM_ENABLE_LIBXML2) + # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. + if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) ++ find_library(libxml2_library NAME xml2 PATHS ${LibXml2_LIB_DIRS} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif() + if(NOT libxml2_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) ++ find_library(libxml2_library NAME xml2 PATHS ${LibXml2_LIB_DIRS} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif() + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) diff --git a/recipes/llvm/all/patches/15/calculate_job_pools.patch b/recipes/llvm/all/patches/15/calculate_job_pools.patch new file mode 100644 index 0000000000000..5db7a47df0f5c --- /dev/null +++ b/recipes/llvm/all/patches/15/calculate_job_pools.patch @@ -0,0 +1,53 @@ +diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake +index 56d05f5b5fce..43f6c7b83dbe 100644 +--- a/llvm/cmake/modules/HandleLLVMOptions.cmake ++++ b/llvm/cmake/modules/HandleLLVMOptions.cmake +@@ -32,8 +32,25 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) + + # Ninja Job Pool support + # The following only works with the Ninja generator in CMake >= 3.0. ++if (NOT LLVM_RAM_PER_COMPILE_JOB) ++ set(LLVM_RAM_PER_COMPILE_JOB "2000") ++endif() + set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING + "Define the maximum number of concurrent compilation jobs (Ninja only).") ++ ++cmake_host_system_information(RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY) ++cmake_host_system_information(RESULT NUMBER_OF_LOGICAL_CORES QUERY NUMBER_OF_LOGICAL_CORES) ++if(LLVM_RAM_PER_COMPILE_JOB) ++ math(EXPR memory_available_jobs "${AVAILABLE_PHYSICAL_MEMORY} / ${LLVM_RAM_PER_COMPILE_JOB}" OUTPUT_FORMAT DECIMAL) ++ if (memory_available_jobs LESS 1) ++ set(memory_available_jobs 1) ++ endif() ++ if (memory_available_jobs LESS NUMBER_OF_LOGICAL_CORES) ++ set(LLVM_PARALLEL_COMPILE_JOBS "${memory_available_jobs}") ++ else() ++ set(LLVM_PARALLEL_COMPILE_JOBS "${NUMBER_OF_LOGICAL_CORES}") ++ endif() ++endif() + if(LLVM_PARALLEL_COMPILE_JOBS) + if(NOT CMAKE_GENERATOR MATCHES "Ninja") + message(WARNING "Job pooling is only available with Ninja generators.") +@@ -43,8 +60,22 @@ if(LLVM_PARALLEL_COMPILE_JOBS) + endif() + endif() + ++if (NOT LLVM_RAM_PER_LINK_JOB) ++ set(LLVM_RAM_PER_LINK_JOB "14000") ++endif() + set(LLVM_PARALLEL_LINK_JOBS "" CACHE STRING + "Define the maximum number of concurrent link jobs (Ninja only).") ++if(LLVM_RAM_PER_LINK_JOB) ++ math(EXPR memory_available_jobs "${AVAILABLE_PHYSICAL_MEMORY} / ${LLVM_RAM_PER_LINK_JOB}" OUTPUT_FORMAT DECIMAL) ++ if (memory_available_jobs LESS 1) ++ set(memory_available_jobs 1) ++ endif() ++ if (memory_available_jobs LESS NUMBER_OF_LOGICAL_CORES) ++ set(LLVM_PARALLEL_LINK_JOBS "${memory_available_jobs}") ++ else() ++ set(LLVM_PARALLEL_LINK_JOBS "${NUMBER_OF_LOGICAL_CORES}") ++ endif() ++endif() + if(CMAKE_GENERATOR MATCHES "Ninja") + if(NOT LLVM_PARALLEL_LINK_JOBS AND uppercase_LLVM_ENABLE_LTO STREQUAL "THIN") + message(STATUS "ThinLTO provides its own parallel linking - limiting parallel link jobs to 2.") diff --git a/recipes/llvm/all/patches/15/fix_xml2_library_name.patch b/recipes/llvm/all/patches/15/fix_xml2_library_name.patch new file mode 100644 index 0000000000000..5bc4a65b1d7a7 --- /dev/null +++ b/recipes/llvm/all/patches/15/fix_xml2_library_name.patch @@ -0,0 +1,110 @@ +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt +index e3bc4b468fb6..1e573740bf74 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -217,7 +217,7 @@ if(LLVM_ENABLE_LIBXML2) + # code may call MSan interceptors like strlen, leading to false positives. + if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + set (LIBXML2_FOUND 0) +- find_package(LibXml2 2.5.3 QUIET) ++ find_package(libxml2 2.5.3 QUIET) + if (LIBXML2_FOUND) + set(CLANG_HAVE_LIBXML 1) + endif() +diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt +index 0ae1b4e55244..62bdb4b9a157 100644 +--- a/clang/tools/c-index-test/CMakeLists.txt ++++ b/clang/tools/c-index-test/CMakeLists.txt +@@ -40,7 +40,7 @@ set_target_properties(c-index-test + + # If libxml2 is available, make it available for c-index-test. + if (CLANG_HAVE_LIBXML) +- target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2) ++ target_link_libraries(c-index-test PRIVATE libxml2::libxml2) + endif() + + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) +diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake +index 987353517d0d..d62441a5d63e 100644 +--- a/lldb/cmake/modules/LLDBConfig.cmake ++++ b/lldb/cmake/modules/LLDBConfig.cmake +@@ -61,7 +61,7 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" Curse + add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND) + add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND) + add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND) +-add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8) ++add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" libxml2 LIBXML2_FOUND VERSION 2.8) + add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support in LLDB" FBSDVMCore FBSDVMCore_FOUND QUIET) + + option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF) +diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt +index 64d9bb00ffab..0c3ee11104a8 100644 +--- a/lldb/source/Host/CMakeLists.txt ++++ b/lldb/source/Host/CMakeLists.txt +@@ -135,7 +135,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "NetBSD") + list(APPEND EXTRA_LIBS kvm) + endif() + if (LLDB_ENABLE_LIBXML2) +- list(APPEND EXTRA_LIBS LibXml2::LibXml2) ++ list(APPEND EXTRA_LIBS libxml2::libxml2) + endif() + if (HAVE_LIBDL) + list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS}) +diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake +index 7e657fd1532d..d0f0cc38befe 100644 +--- a/llvm/cmake/config-ix.cmake ++++ b/llvm/cmake/config-ix.cmake +@@ -153,11 +153,11 @@ set(LLVM_ENABLE_ZSTD ${zstd_FOUND}) + + if(LLVM_ENABLE_LIBXML2) + if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON) +- find_package(LibXml2 REQUIRED) ++ find_package(libxml2 REQUIRED) + elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") +- find_package(LibXml2) ++ find_package(libxml2) + endif() +- if(LibXml2_FOUND) ++ if(libxml2_FOUND) + # Check if libxml2 we found is usable; for example, we may have found a 32-bit + # library on a 64-bit system which would result in a link-time failure. + cmake_push_check_state() +diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in +index f1362fa032c2..0774363c4413 100644 +--- a/llvm/cmake/modules/LLVMConfig.cmake.in ++++ b/llvm/cmake/modules/LLVMConfig.cmake.in +@@ -80,7 +80,7 @@ endif() + + set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@) + if(LLVM_ENABLE_LIBXML2) +- find_package(LibXml2) ++ find_package(libxml2) + endif() + + set(LLVM_WITH_Z3 @LLVM_WITH_Z3@) +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 910132a4c7de..5e712feaae19 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -1,7 +1,7 @@ + include(GetLibraryName) + + if(LLVM_ENABLE_LIBXML2) +- set(imported_libs LibXml2::LibXml2) ++ set(imported_libs libxml2::libxml2) + endif() + + add_llvm_component_library(LLVMWindowsManifest +@@ -24,10 +24,10 @@ if(LLVM_ENABLE_LIBXML2) + # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. + if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) ++ get_property(libxml2_library TARGET libxml2::libxml2 PROPERTY LOCATION_${build_type}) + endif() + if(NOT libxml2_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) ++ get_property(libxml2_library TARGET libxml2::libxml2 PROPERTY LOCATION) + endif() + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) diff --git a/recipes/llvm/all/patches/16/WindowsManifest_libxml2_folder.patch b/recipes/llvm/all/patches/16/WindowsManifest_libxml2_folder.patch new file mode 100644 index 0000000000000..71bf51abc3455 --- /dev/null +++ b/recipes/llvm/all/patches/16/WindowsManifest_libxml2_folder.patch @@ -0,0 +1,17 @@ +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 910132a4c7de..915d01d6ddc3 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -24,10 +24,10 @@ if(LLVM_ENABLE_LIBXML2) + # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. + if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) ++ find_library(libxml2_library NAME xml2 PATHS ${LibXml2_LIB_DIRS} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif() + if(NOT libxml2_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) ++ find_library(libxml2_library NAME xml2 PATHS ${LibXml2_LIB_DIRS} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + endif() + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) diff --git a/recipes/llvm/all/patches/16/calculate_job_pools.patch b/recipes/llvm/all/patches/16/calculate_job_pools.patch new file mode 100644 index 0000000000000..9384e0470b828 --- /dev/null +++ b/recipes/llvm/all/patches/16/calculate_job_pools.patch @@ -0,0 +1,53 @@ +diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake +index 6119ecdce0f4..bbb5ae038765 100644 +--- a/llvm/cmake/modules/HandleLLVMOptions.cmake ++++ b/llvm/cmake/modules/HandleLLVMOptions.cmake +@@ -32,8 +32,25 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) + + # Ninja Job Pool support + # The following only works with the Ninja generator in CMake >= 3.0. ++if (NOT LLVM_RAM_PER_COMPILE_JOB) ++ set(LLVM_RAM_PER_COMPILE_JOB "2000") ++endif() + set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING + "Define the maximum number of concurrent compilation jobs (Ninja only).") ++ ++cmake_host_system_information(RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY) ++cmake_host_system_information(RESULT NUMBER_OF_LOGICAL_CORES QUERY NUMBER_OF_LOGICAL_CORES) ++if(LLVM_RAM_PER_COMPILE_JOB) ++ math(EXPR memory_available_jobs "${AVAILABLE_PHYSICAL_MEMORY} / ${LLVM_RAM_PER_COMPILE_JOB}" OUTPUT_FORMAT DECIMAL) ++ if (memory_available_jobs LESS 1) ++ set(memory_available_jobs 1) ++ endif() ++ if (memory_available_jobs LESS NUMBER_OF_LOGICAL_CORES) ++ set(LLVM_PARALLEL_COMPILE_JOBS "${memory_available_jobs}") ++ else() ++ set(LLVM_PARALLEL_COMPILE_JOBS "${NUMBER_OF_LOGICAL_CORES}") ++ endif() ++endif() + if(LLVM_PARALLEL_COMPILE_JOBS) + if(NOT CMAKE_GENERATOR MATCHES "Ninja") + message(WARNING "Job pooling is only available with Ninja generators.") +@@ -43,8 +60,22 @@ if(LLVM_PARALLEL_COMPILE_JOBS) + endif() + endif() + ++if (NOT LLVM_RAM_PER_LINK_JOB) ++ set(LLVM_RAM_PER_LINK_JOB "14000") ++endif() + set(LLVM_PARALLEL_LINK_JOBS "" CACHE STRING + "Define the maximum number of concurrent link jobs (Ninja only).") ++if(LLVM_RAM_PER_LINK_JOB) ++ math(EXPR memory_available_jobs "${AVAILABLE_PHYSICAL_MEMORY} / ${LLVM_RAM_PER_LINK_JOB}" OUTPUT_FORMAT DECIMAL) ++ if (memory_available_jobs LESS 1) ++ set(memory_available_jobs 1) ++ endif() ++ if (memory_available_jobs LESS NUMBER_OF_LOGICAL_CORES) ++ set(LLVM_PARALLEL_LINK_JOBS "${memory_available_jobs}") ++ else() ++ set(LLVM_PARALLEL_LINK_JOBS "${NUMBER_OF_LOGICAL_CORES}") ++ endif() ++endif() + if(CMAKE_GENERATOR MATCHES "Ninja") + if(NOT LLVM_PARALLEL_LINK_JOBS AND uppercase_LLVM_ENABLE_LTO STREQUAL "THIN") + message(STATUS "ThinLTO provides its own parallel linking - limiting parallel link jobs to 2.") diff --git a/recipes/llvm/all/patches/16/fix_xml2_library_name.patch b/recipes/llvm/all/patches/16/fix_xml2_library_name.patch new file mode 100644 index 0000000000000..3eda82b59d158 --- /dev/null +++ b/recipes/llvm/all/patches/16/fix_xml2_library_name.patch @@ -0,0 +1,110 @@ +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt +index 090cfa352078..4efe54def875 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -166,7 +166,7 @@ if(CLANG_ENABLE_LIBXML2) + # code may call MSan interceptors like strlen, leading to false positives. + if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + set (LIBXML2_FOUND 0) +- find_package(LibXml2 2.5.3 QUIET) ++ find_package(libxml2 2.5.3 QUIET) + if (LIBXML2_FOUND) + set(CLANG_HAVE_LIBXML 1) + endif() +diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt +index 0ae1b4e55244..62bdb4b9a157 100644 +--- a/clang/tools/c-index-test/CMakeLists.txt ++++ b/clang/tools/c-index-test/CMakeLists.txt +@@ -40,7 +40,7 @@ set_target_properties(c-index-test + + # If libxml2 is available, make it available for c-index-test. + if (CLANG_HAVE_LIBXML) +- target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2) ++ target_link_libraries(c-index-test PRIVATE libxml2::libxml2) + endif() + + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) +diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake +index ec06ba285f27..15f6eba0a8e5 100644 +--- a/lldb/cmake/modules/LLDBConfig.cmake ++++ b/lldb/cmake/modules/LLDBConfig.cmake +@@ -62,7 +62,7 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" Curse + add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND) + add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND) + add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND) +-add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8) ++add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" libxml2 LIBXML2_FOUND VERSION 2.8) + add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support in LLDB" FBSDVMCore FBSDVMCore_FOUND QUIET) + + option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON) +diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt +index 4a5ceeb60b7b..bfa8ef1092b2 100644 +--- a/lldb/source/Host/CMakeLists.txt ++++ b/lldb/source/Host/CMakeLists.txt +@@ -137,7 +137,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "NetBSD") + list(APPEND EXTRA_LIBS kvm) + endif() + if (LLDB_ENABLE_LIBXML2) +- list(APPEND EXTRA_LIBS LibXml2::LibXml2) ++ list(APPEND EXTRA_LIBS libxml2::libxml2) + endif() + if (HAVE_LIBDL) + list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS}) +diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake +index b78c1b34ab8b..54387ed0cdd6 100644 +--- a/llvm/cmake/config-ix.cmake ++++ b/llvm/cmake/config-ix.cmake +@@ -153,11 +153,11 @@ set(LLVM_ENABLE_ZSTD ${zstd_FOUND}) + + if(LLVM_ENABLE_LIBXML2) + if(LLVM_ENABLE_LIBXML2 STREQUAL FORCE_ON) +- find_package(LibXml2 REQUIRED) ++ find_package(libxml2 REQUIRED) + elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") +- find_package(LibXml2) ++ find_package(libxml2) + endif() +- if(LibXml2_FOUND) ++ if(libxml2_FOUND) + # Check if libxml2 we found is usable; for example, we may have found a 32-bit + # library on a 64-bit system which would result in a link-time failure. + cmake_push_check_state() +diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in +index 2d90512bfb06..1b91bb372e64 100644 +--- a/llvm/cmake/modules/LLVMConfig.cmake.in ++++ b/llvm/cmake/modules/LLVMConfig.cmake.in +@@ -80,7 +80,7 @@ endif() + + set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@) + if(LLVM_ENABLE_LIBXML2) +- find_package(LibXml2) ++ find_package(libxml2) + endif() + + set(LLVM_ENABLE_CURL @LLVM_ENABLE_CURL@) +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 910132a4c7de..5e712feaae19 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -1,7 +1,7 @@ + include(GetLibraryName) + + if(LLVM_ENABLE_LIBXML2) +- set(imported_libs LibXml2::LibXml2) ++ set(imported_libs libxml2::libxml2) + endif() + + add_llvm_component_library(LLVMWindowsManifest +@@ -24,10 +24,10 @@ if(LLVM_ENABLE_LIBXML2) + # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. + if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) ++ get_property(libxml2_library TARGET libxml2::libxml2 PROPERTY LOCATION_${build_type}) + endif() + if(NOT libxml2_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) ++ get_property(libxml2_library TARGET libxml2::libxml2 PROPERTY LOCATION) + endif() + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) diff --git a/recipes/llvm/all/test_package/CMakeLists.txt b/recipes/llvm/all/test_package/CMakeLists.txt index 6d70aefb6c065..0a0c528b03ef3 100644 --- a/recipes/llvm/all/test_package/CMakeLists.txt +++ b/recipes/llvm/all/test_package/CMakeLists.txt @@ -1,10 +1,15 @@ cmake_minimum_required(VERSION 3.1) project(test_package) -set(CMAKE_CXX_STANDARD 14) +# enable to print compiler output +set(CMAKE_VERBOSE_MAKEFILE OFF) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(LLVM REQUIRED COMPONENTS LLVMSupport) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} LLVMSupport) + +if (llvm_build_llvm_dylib) + add_executable(${PROJECT_NAME}-dynlib test_package.cpp) + target_link_libraries(${PROJECT_NAME}-dynlib LLVM) +endif() diff --git a/recipes/llvm/all/test_package/conanfile.py b/recipes/llvm/all/test_package/conanfile.py index bd7165a553cf4..ef00698edf99f 100644 --- a/recipes/llvm/all/test_package/conanfile.py +++ b/recipes/llvm/all/test_package/conanfile.py @@ -1,17 +1,50 @@ -from conans import ConanFile, CMake, tools -import os +from conan import ConanFile +from conan.tools.cmake import CMakeDeps, CMakeToolchain, CMake +from conan.tools.build.cross_building import cross_building +from conan.tools.cmake.layout import cmake_layout +from conans.model.version import Version +import re class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.build_requires("cmake/[>=3.21.3 <4.0.0]") + self.build_requires("ninja/[>=1.10.0 <2.0.0]") + + def generate(self): + deps = CMakeDeps(self) + deps.check_components_exist = True + deps.generate() + tc = CMakeToolchain(self) + tc.generate() + + def _llvm_version(self): + pattern = re.compile("^llvm/([0-9.]+)") + return Version(re.findall(pattern, self.tested_reference_str)[0]) + + def _ccpstd(self): + cppstd = 14 + if self._llvm_version() >= Version(16): + cppstd = 17 + return cppstd def build(self): cmake = CMake(self) - cmake.configure() + cmake.configure(variables={ + 'CMAKE_CXX_STANDARD': self._ccpstd(), + 'llvm_build_llvm_dylib': self.dependencies[self.tested_reference_str].options.llvm_build_llvm_dylib, + # We could also add additional testing per project / runtime if needed + }) cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self, self.settings): + self.run("./test_package") diff --git a/recipes/llvm/all/test_package/test_package.cpp b/recipes/llvm/all/test_package/test_package.cpp index 03bd7c44d9349..8b822065d1dfa 100644 --- a/recipes/llvm/all/test_package/test_package.cpp +++ b/recipes/llvm/all/test_package/test_package.cpp @@ -1,6 +1,8 @@ -// Kaleidoscope example from https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl02.html#full-code-listing +// Kaleidoscope example from +// https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl02.html#full-code-listing #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/raw_ostream.h" #include #include #include @@ -302,8 +304,8 @@ static std::unique_ptr ParseBinOpRHS(int ExprPrec, } // Merge LHS/RHS. - LHS = std::make_unique(BinOp, std::move(LHS), - std::move(RHS)); + LHS = + std::make_unique(BinOp, std::move(LHS), std::move(RHS)); } } @@ -359,7 +361,7 @@ static std::unique_ptr ParseTopLevelExpr() { if (auto E = ParseExpression()) { // Make an anonymous proto. auto Proto = std::make_unique("__anon_expr", - std::vector()); + std::vector()); return std::make_unique(std::move(Proto), std::move(E)); } return nullptr; @@ -431,6 +433,7 @@ static void MainLoop() { //===----------------------------------------------------------------------===// int main() { + llvm::outs() << "hello from running conan llvm test_package\n"; return 0; // Return to make conan test_package continue // (The example is interactive) diff --git a/recipes/llvm/config.yml b/recipes/llvm/config.yml index dd5bedb69b02b..3470d7a1c7196 100644 --- a/recipes/llvm/config.yml +++ b/recipes/llvm/config.yml @@ -1,7 +1,9 @@ versions: - "13.0.0": + "16.0.3": folder: all - "13.0.1": + "15.0.7": + folder: all + "14.0.6": folder: all - "14.0.0": + "13.0.1": folder: all