From 2a7b4bf0100d30e3996e4e01e28cec5da26f7a3f Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Tue, 5 Mar 2024 09:50:18 +0000 Subject: [PATCH 01/77] [llvm-core] bring package up to date. Initial support for 13.0.0 --- recipes/llvm-core/all/CMakeLists.txt | 26 - recipes/llvm-core/all/conandata.yml | 16 +- recipes/llvm-core/all/conanfile.py | 507 ++++++------------ .../all/patches/11x/11.1.0-cmake.patch | 57 -- .../all/patches/11x/11.1.0-native.patch | 81 --- .../all/patches/12x/12.0.0-cmake.patch | 55 -- .../all/patches/12x/12.0.0-native.patch | 81 --- .../patches/13x/00-cmake-target-props.patch | 42 ++ .../all/patches/13x/13.0.0-cmake.patch | 54 -- .../all/patches/13x/13.0.0-native.patch | 78 --- .../llvm-core/all/test_package/CMakeLists.txt | 24 +- .../llvm-core/all/test_package/conanfile.py | 78 +-- .../all/test_package/test_function.ll | 6 - .../all/test_package/test_package.cpp | 483 +++++++++++++++-- 14 files changed, 725 insertions(+), 863 deletions(-) delete mode 100644 recipes/llvm-core/all/CMakeLists.txt delete mode 100644 recipes/llvm-core/all/patches/11x/11.1.0-cmake.patch delete mode 100644 recipes/llvm-core/all/patches/11x/11.1.0-native.patch delete mode 100644 recipes/llvm-core/all/patches/12x/12.0.0-cmake.patch delete mode 100644 recipes/llvm-core/all/patches/12x/12.0.0-native.patch create mode 100644 recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch delete mode 100644 recipes/llvm-core/all/patches/13x/13.0.0-cmake.patch delete mode 100644 recipes/llvm-core/all/patches/13x/13.0.0-native.patch delete mode 100644 recipes/llvm-core/all/test_package/test_function.ll diff --git a/recipes/llvm-core/all/CMakeLists.txt b/recipes/llvm-core/all/CMakeLists.txt deleted file mode 100644 index e88dcfa953495..0000000000000 --- a/recipes/llvm-core/all/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -cmake_minimum_required(VERSION 3.13.4) -project(conanllvm) - -include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -if(LLVM_ENABLE_ZLIB) - find_package(ZLIB QUIET) - - # The FindZLIB find module provided by CMake behaves differently than the FindZLIB.cmake script generated by CONAN. - # So the following two lines fill in the needed properties. - list(GET ZLIB_LIBRARIES 0 ZLIB_LIBRARY) - set_property(TARGET ZLIB::ZLIB PROPERTY LOCATION "${ZLIB_LIBRARY}") - - # Additionally LLVM 11.1.0 requires the zlib lib dir to be in the library path. - # This is not needed for later versions and can be removed once - # LLVM-12 becomes the oldest supported version. - if(UNIX) - set(ENV{LIBRARY_PATH} "${CONAN_LIB_DIRS_ZLIB}:$ENV{LIBRARY_PATH}") - elseif(WIN32) - file(TO_NATIVE_PATH "${CONAN_LIB_DIRS_ZLIB}" WINDOWS_ZLIB_PATH) - string(APPEND CMAKE_EXE_LINKER_FLAGS " /LIBPATH:${WINDOWS_ZLIB_PATH}") - endif() -endif() - -add_subdirectory("source") diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 331f5f3a1903f..d6ad564043b1f 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -10,18 +10,4 @@ sources: sha256: ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5 patches: - "11.1.0": - - base_path: "source" - patch_file: "patches/11x/11.1.0-cmake.patch" - - base_path: "source" - patch_file: "patches/11x/11.1.0-native.patch" - "12.0.0": - - base_path: "source" - patch_file: "patches/12x/12.0.0-cmake.patch" - - base_path: "source" - patch_file: "patches/12x/12.0.0-native.patch" - "13.0.0": - - base_path: "source" - patch_file: "patches/13x/13.0.0-cmake.patch" - - base_path: "source" - patch_file: "patches/13x/13.0.0-native.patch" + - patch_file: "patches/13x/00-cmake-target-props.patch" diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 263cb7360506c..c33b69718ce3f 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -1,17 +1,18 @@ -from conan.errors import ConanInvalidConfiguration from conan import ConanFile -from conan.tools.build import cross_building -from conan.tools.files import apply_conandata_patches, chdir, collect_libs, get, load, rename, replace_in_file, rm, rmdir, save +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, get, rmdir, save, copy, export_conandata_patches +from conan.tools.microsoft import is_msvc from conan.tools.scm import Version -from conans import CMake -from collections import defaultdict + +from glob import iglob import json -import re -import os.path import os -import textwrap +from pathlib import Path +import re -required_conan_version = ">=1.50.2" # Due to conan.tools.scm.Version +required_conan_version = ">=2.0.0" class LLVMCoreConan(ConanFile): @@ -25,12 +26,12 @@ class LLVMCoreConan(ConanFile): homepage = 'https://llvm.org' url = 'https://github.com/conan-io/conan-center-index' - settings = ('os', 'arch', 'compiler', 'build_type') + settings = 'os', 'arch', 'compiler', 'build_type' options = { 'shared': [True, False], 'fPIC': [True, False], - 'components': 'ANY', - 'targets': 'ANY', + 'components': ['ANY'], + 'targets': ['ANY'], 'exceptions': [True, False], 'rtti': [True, False], 'threads': [True, False], @@ -50,6 +51,7 @@ class LLVMCoreConan(ConanFile): 'None' ], 'with_ffi': [True, False], + 'with_terminfo': [True, False], 'with_zlib': [True, False], 'with_xml2': [True, False], 'use_llvm_cmake_files': [True, False], @@ -72,358 +74,205 @@ class LLVMCoreConan(ConanFile): 'with_zlib': True, 'with_xml2': True, 'use_llvm_cmake_files': False, + 'with_terminfo': False # differs from LLVM default } - # Older cmake versions may have issues generating the graphviz output used - # to model the components - build_requires = [ - 'cmake/3.20.5' - ] - - generators = 'cmake', 'cmake_find_package' - no_copy_source = True - short_paths = True - @property - def _source_subfolder(self): - return 'source' - - def _supports_compiler(self): - compiler = self.settings.compiler.value - version = Version(self.settings.compiler.version) - major_rev, minor_rev = version.major, (version.minor or 0) - - unsupported_combinations = [ - [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)) - - def _patch_sources(self): - apply_conandata_patches(self) - - def _patch_build(self): - if os.path.exists('FindIconv.cmake'): - replace_in_file(self, 'FindIconv.cmake', 'iconv charset', 'iconv') - - 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 + def _min_cppstd(self): + return 14 - 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 - cmake.definitions['LLVM_DYLIB_COMPONENTS'] = self.options.components - cmake.definitions['LLVM_ENABLE_PIC'] = \ - self.options.get_safe('fPIC', default=False) - - if self.settings.compiler == 'Visual Studio': - build_type = str(self.settings.build_type).upper() - cmake.definitions['LLVM_USE_CRT_{}'.format(build_type)] = \ - self.settings.compiler.runtime - - 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_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 - 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_TERMINFO'] = 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 - 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 - cmake.definitions['LLVM_ENABLE_LIBEDIT'] = False - cmake.definitions['LLVM_ENABLE_FFI'] = self.options.with_ffi - cmake.definitions['LLVM_ENABLE_ZLIB'] = "FORCE_ON" if \ - self.options.get_safe('with_zlib', False) else False - cmake.definitions['LLVM_ENABLE_LIBXML2'] = \ - self.options.get_safe('with_xml2', False) - return cmake + @property + def _compilers_minimum_version(self): + return { + "apple-clang": "10", + "clang": "7", + "gcc": "7", + "msvc": "191", + "Visual Studio": "15", + } def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + export_conandata_patches(self) def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC - del self.options.with_xml2 + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") 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.12') - if self.options.get_safe('with_xml2', False): - self.requires('libxml2/2.9.10') + self.requires('libffi/3.4.4') + if self.options.with_zlib: + self.requires('zlib/1.3.1') + if self.options.with_xml2: + self.requires('libxml2/2.12.4') + self.requires('z3/4.12.4') - def package_id(self): - del self.info.options.use_llvm_cmake_files + @property + def _is_gcc(self): + return self.settings.compiler == "gcc" def validate(self): - 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.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + if self._is_gcc and Version(self.settings.compiler.version) >= "13": + raise ConanInvalidConfiguration( + f"GCC {self.settings.compiler.version} cannot compile LLVM {self.version}" + ) + + if self._is_windows: + if self.options.shared: # Shared builds disabled just due to the CI + raise ConanInvalidConfiguration('Shared builds not currently supported on Windows') + if self.options.exceptions and not self.options.rtti: - message = 'Cannot enable exceptions without rtti support' - raise ConanInvalidConfiguration(message) - self._supports_compiler() - if cross_building(self, skip_x64_x86=True): - raise ConanInvalidConfiguration('Cross-building not implemented') + raise ConanInvalidConfiguration('Cannot enable exceptions without rtti support') def source(self): - get(self, **self.conan_data["sources"][self.version], strip_root=True, - destination=self._source_subfolder) - self._patch_sources() + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + # See https://releases.llvm.org/13.0.0/docs/CMake.html + cmake_definitions = { + 'LLVM_TARGETS_TO_BUILD': self.options.targets, + 'LLVM_BUILD_LLVM_DYLIB': self.options.shared, + 'LLVM_LINK_LLVM_DYLIB': self.options.shared, + 'LLVM_DYLIB_COMPONENTS': self.options.components, + 'LLVM_ABI_BREAKING_CHECKS': 'WITH_ASSERTS', + 'LLVM_INCLUDE_TOOLS': True, + 'LLVM_INCLUDE_EXAMPLES': False, + 'LLVM_INCLUDE_TESTS': False, + 'LLVM_ENABLE_IDE': 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, + 'LLVM_USE_PERF': self.options.use_perf, + 'LLVM_ENABLE_Z3_SOLVER': True, + 'LLVM_ENABLE_FFI': self.options.with_ffi, + 'LLVM_ENABLE_ZLIB': "FORCE_ON" if self.options.with_zlib else False, + 'LLVM_ENABLE_LIBXML2': self.options.with_xml2, + 'LLVM_ENABLE_TERMINFO': self.options.with_terminfo + } + 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 not self.options.shared: + cmake_definitions.update({ + 'DISABLE_LLVM_LINK_LLVM_DYLIB': True, + 'LLVM_ENABLE_PIC': self.options.get_safe('fPIC', default=False) + }) + + if self.options.use_sanitizer == 'None': + cmake_definitions['LLVM_USE_SANITIZER'] = '' + else: + cmake_definitions['LLVM_USE_SANITIZER'] = self.options.use_sanitizer + + tc.variables.update(cmake_definitions) + tc.cache_variables.update({ + 'CMAKE_TRY_COMPILE_CONFIGURATION': str(self.settings.build_type), + 'BUILD_SHARED_LIBS': False, # This variable causes LLVM to build shared libs for each separate component, + # which is probably not what the user wants. Use `LLVM_BUILD_LLVM_DYLIB` instead + # to build a single shared library + }) + tc.generate() + + tc = CMakeDeps(self) + tc.generate() + + def _patch_sources(self): + graphviz_settings = """ +set(GRAPHVIZ_EXECUTABLES OFF) +set(GRAPHVIZ_INTERFACE_LIBS OFF) +set(GRAPHVIZ_OBJECT_LIBS OFF) + """ + save(self, Path(self.build_folder) / "CMakeGraphVizOptions.cmake", graphviz_settings) + apply_conandata_patches(self) def build(self): - self._patch_build() - cmake = self._configure_cmake() - cmake.configure() + self._patch_sources() + cmake = CMake(self) + cmake.configure(cli_args=["--graphviz=graph/llvm.dot"]) cmake.build() - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake", "llvm") + def package_id(self): + del self.info.options.use_llvm_cmake_files @property - def _alias_module_file_rel_path(self): - return os.path.join(self._module_subfolder, "conan-official-{}-targets.cmake".format(self.name)) + def _is_windows(self): + return self.settings.os == 'Windows' + + def _llvm_components(self): + # The definitive list of built targets is provided by running `llvm-config --components` + graphviz_folder = Path(self.build_folder) / "graph" + match_component = re.compile(r"""^llvm.dot.LLVM(.+)\.dependers$""") + for lib in iglob(str(graphviz_folder / '*')): + if os.path.isdir(lib) or os.path.islink(lib): + continue + lib_name = os.path.basename(lib) + match = match_component.match(lib_name) + if match: + component = match.group(1) + yield component.lower(), f"LLVM{component}" @property - def _old_alias_module_file_rel_path(self): - return os.path.join(self._module_subfolder, "conan-official-{}-old-targets.cmake".format(self.name)) - - def _create_cmake_module_alias_targets(self, module_file, targets): - content = "" - for alias, aliased in targets.items(): - content += textwrap.dedent("""\ - if(TARGET {aliased} AND NOT TARGET {alias}) - add_library({alias} INTERFACE IMPORTED) - set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) - endif() - """.format(alias=alias, aliased=aliased)) - save(self, module_file, content) + def _components_data_file(self): + return Path(self.package_folder) / "components.json" - def package(self): - self.copy('LICENSE.TXT', dst='licenses', src=self._source_subfolder) - lib_path = os.path.join(self.package_folder, 'lib') + def _write_components(self): + component_dict = { + component: lib_name for component, lib_name in self._llvm_components() + } + with open(self._components_data_file, 'w') as fp: + json.dump(component_dict, fp) - cmake = self._configure_cmake() + def _read_components(self) -> dict: + with open(self._components_data_file) as fp: + return json.load(fp) + + def package(self): + copy(self, "LICENSE.TXT", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + package_folder = Path(self.package_folder) + rmdir(self, package_folder / "lib" / "cmake") if not self.options.shared: - for ext in ['.a', '.lib']: - lib = '**/lib/*LLVMTableGenGlobalISel{}'.format(ext) - self.copy(lib, dst='lib', keep_path=False) - lib = '*LLVMTableGenGlobalISel{}'.format(ext) - self.copy(lib, dst='lib', src='lib') - - CMake(self).configure(args=['--graphviz=graph/llvm.dot'], source_dir='.', build_dir='.') - 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) - - dummy_targets = defaultdict(list) - for target, dep in deps: - if not target.startswith('LLVM'): - dummy_targets[target].append(dep) - - cmake_targets = { - 'libffi::libffi': 'ffi', - 'ZLIB::ZLIB': 'z', - 'Iconv::Iconv': 'iconv', - 'LibXml2::LibXml2': 'xml2' - } - - components = defaultdict(list) - for lib, dep in deps: - if not lib.startswith('LLVM'): - continue - elif dep.startswith('-delayload:'): - continue - elif dep.startswith('LLVM'): - components[dep] - elif dep in cmake_targets: - dep = cmake_targets[dep] - 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(): - components[lib].extend(dummy_targets[dep]) - components[lib] = list(set(components[lib])) - else: - components[lib].append(dep) - - alias_targets = {} - old_alias_targets = {} - for component, _ in components.items(): - alias_targets[component] = "LLVM::{}".format(component) - old_alias_targets["llvm-core::{}".format(component[4:].replace('LLVM', '').lower())] = "LLVM::{}".format(component) - - # TODO: to remove in conan v2 once cmake_find_package_* generators removed - self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._alias_module_file_rel_path), - alias_targets - ) - - self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._old_alias_module_file_rel_path), - old_alias_targets - ) - - rmdir(self, os.path.join(self.package_folder, 'share')) + self._write_components() - rm(self, "LLVMExports*.cmake", self.package_folder, recursive=True) - rename(self, os.path.join(self.package_folder, self._module_subfolder, 'LLVM-Config.cmake'), - os.path.join(self.package_folder, self._module_subfolder, 'LLVM-ConfigInternal.cmake')) - rename(self, os.path.join(self.package_folder, self._module_subfolder, 'LLVMConfig.cmake'), - os.path.join(self.package_folder, self._module_subfolder, 'LLVMConfigInternal.cmake')) - - replace_in_file(self, os.path.join(self.package_folder, self._module_subfolder, 'AddLLVM.cmake'), - "include(LLVM-Config)", - "include(LLVM-ConfigInternal)") - replace_in_file(self, os.path.join(self.package_folder, self._module_subfolder, 'LLVMConfigInternal.cmake'), - "LLVM-Config.cmake", - "LLVM-ConfigInternal.cmake") - - for mask in ["Find*.cmake", "*Config.cmake", "*-config.cmake"]: - rm(self, mask, self.package_folder, recursive=True) + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "LLVM") - for name in os.listdir(lib_path): - fullname = os.path.join(lib_path, name) - if 'LLVM' not in name and os.path.isfile(fullname): - os.remove(fullname) + dependencies = [ + "zlib::zlib", + "libxml2::libxml2", + "z3::z3" + ] if not self.options.shared: - if self.options.get_safe('with_zlib', False): - if not 'z' in components['LLVMSupport']: - components['LLVMSupport'].append('z') - 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 name in os.listdir(lib_path): - if not any(suffix in name for suffix in suffixes): - os.remove(os.path.join(lib_path, name)) + components = self._read_components() - def package_info(self): - self.cpp_info.set_property("cmake_file_name", "LLVM") + for component_name, lib_name in components.items(): + self.cpp_info.components[component_name].set_property("cmake_target_name", lib_name) + self.cpp_info.components[component_name].libs = [lib_name] + self.cpp_info.components[component_name].requires = dependencies - if self.options.shared: + else: + self.cpp_info.set_property("cmake_target_name", "LLVM") self.cpp_info.libs = 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 = { - 'ffi': 'libffi::libffi', - 'z': 'zlib::zlib', - 'xml2': 'libxml2::libxml2' - } - - 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')) - - 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 - ] - - 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, - ]) - - 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") - ) - self.cpp_info.components[component].build_modules["cmake_find_package_multi"].append( - os.path.join(self._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" diff --git a/recipes/llvm-core/all/patches/11x/11.1.0-cmake.patch b/recipes/llvm-core/all/patches/11x/11.1.0-cmake.patch deleted file mode 100644 index 6f2c7682aa4e0..0000000000000 --- a/recipes/llvm-core/all/patches/11x/11.1.0-cmake.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- cmake/config-ix.cmake -+++ cmake/config-ix.cmake -@@ -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() - -- 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() ---- 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 @@ - 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/11.1.0-native.patch b/recipes/llvm-core/all/patches/11x/11.1.0-native.patch deleted file mode 100644 index c541a76820341..0000000000000 --- a/recipes/llvm-core/all/patches/11x/11.1.0-native.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -942,10 +942,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 "") diff --git a/recipes/llvm-core/all/patches/12x/12.0.0-cmake.patch b/recipes/llvm-core/all/patches/12x/12.0.0-cmake.patch deleted file mode 100644 index 8d3f7dbf7cf98..0000000000000 --- a/recipes/llvm-core/all/patches/12x/12.0.0-cmake.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- cmake/config-ix.cmake -+++ cmake/config-ix.cmake -@@ -143,6 +143,9 @@ - elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") - find_package(LibXml2) - endif() -+ set(LIBXML2_FOUND 1) -+ list(GET LibXml2_INCLUDE_DIRS -1 LIBXML2_INCLUDE_DIR) -+ set(LIBXML2_LIBRARIES ${LibXml2_LIBRARIES}) - 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. -@@ -335,7 +335,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() ---- cmake/modules/TableGen.cmake -+++ cmake/modules/TableGen.cmake -@@ -132,12 +132,7 @@ - macro(add_tablegen target project) - set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS}) - set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen) -- -- # CMake doesn't let compilation units depend on their dependent libraries on some generators. -- if(NOT CMAKE_GENERATOR STREQUAL "Ninja" 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 -@@ -21,14 +21,5 @@ - # This block is only needed for llvm-config. When we deprecate llvm-config and - # move to using CMake export, this block can be removed. - 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}) -- endif() -- if(NOT zlib_library) -- 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}) -+ set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${LIBXML2_LIBRARIES}) - endif() diff --git a/recipes/llvm-core/all/patches/12x/12.0.0-native.patch b/recipes/llvm-core/all/patches/12x/12.0.0-native.patch deleted file mode 100644 index f5c6d542fab8f..0000000000000 --- a/recipes/llvm-core/all/patches/12x/12.0.0-native.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -891,10 +891,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 -@@ -144,33 +144,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 -@@ -75,11 +75,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 "") diff --git a/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch new file mode 100644 index 0000000000000..a96025b74370e --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch @@ -0,0 +1,42 @@ +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +index dd0aaadb47c..e0771f99237 100644 +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake +@@ -127,7 +127,7 @@ if(LLVM_ENABLE_ZLIB) + # library on a 64-bit system which would result in a link-time failure. + cmake_push_check_state() + list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) +- list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARY}) ++ list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES}) + check_symbol_exists(compress2 zlib.h HAVE_ZLIB) + cmake_pop_check_state() + if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB) +diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt +index 014b4a2caf1..486e4f39642 100644 +--- a/lib/Support/CMakeLists.txt ++++ b/lib/Support/CMakeLists.txt +@@ -267,7 +267,7 @@ if(LLVM_ENABLE_ZLIB) + # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. + if(CMAKE_BUILD_TYPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type}) ++ set(zlib_library ${ZLIB_LIBRARIES}) + endif() + if(NOT zlib_library) + get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION) +diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt +index 8134ac8c815..1c317791fba 100644 +--- a/lib/WindowsManifest/CMakeLists.txt ++++ b/lib/WindowsManifest/CMakeLists.txt +@@ -24,9 +24,9 @@ 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}) ++ set(libxml2_library ${libxml2_LIBRARIES}) + endif() +- if(NOT zlib_library) ++ if(NOT libxml2_library) + get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) + endif() + get_library_name(${libxml2_library} libxml2_library) diff --git a/recipes/llvm-core/all/patches/13x/13.0.0-cmake.patch b/recipes/llvm-core/all/patches/13x/13.0.0-cmake.patch deleted file mode 100644 index 981f067a21505..0000000000000 --- a/recipes/llvm-core/all/patches/13x/13.0.0-cmake.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- cmake/config-ix.cmake -+++ cmake/config-ix.cmake -@@ -143,6 +143,9 @@ if(LLVM_ENABLE_LIBXML2) - elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") - find_package(LibXml2) - endif() -+ set(LIBXML2_FOUND 1) -+ list(GET LibXml2_INCLUDE_DIRS -1 LIBXML2_INCLUDE_DIR) -+ set(LIBXML2_LIBRARIES ${LibXml2_LIBRARIES}) - 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. -@@ -343,7 +346,7 @@ if( LLVM_ENABLE_FFI ) - 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() ---- cmake/modules/TableGen.cmake -+++ cmake/modules/TableGen.cmake -@@ -135,11 +135,7 @@ macro(add_tablegen target project) - set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS}) - set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen) - -- # CMake doesn't let compilation units depend on their dependent libraries on some generators. -- if(NOT CMAKE_GENERATOR STREQUAL "Ninja" 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 -@@ -21,14 +21,5 @@ add_llvm_component_library(LLVMWindowsManifest - # This block is only needed for llvm-config. When we deprecate llvm-config and - # move to using CMake export, this block can be removed. - 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}) -- endif() -- if(NOT zlib_library) -- 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}) -+ set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${LIBXML2_LIBRARIES}) - endif() diff --git a/recipes/llvm-core/all/patches/13x/13.0.0-native.patch b/recipes/llvm-core/all/patches/13x/13.0.0-native.patch deleted file mode 100644 index fa8482ce0493b..0000000000000 --- a/recipes/llvm-core/all/patches/13x/13.0.0-native.patch +++ /dev/null @@ -1,78 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -931,10 +931,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) - 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 -@@ -147,32 +147,6 @@ macro(add_tablegen target project) - 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) ---- tools/llvm-config/CMakeLists.txt -+++ tools/llvm-config/CMakeLists.txt -@@ -75,11 +75,3 @@ endif() - - # 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 -@@ -162,13 +162,6 @@ if(LLVM_BUILD_LLVM_C_DYLIB AND MSVC) - - 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() - else() - set(llvm_nm ${LLVM_NM}) - set(llvm_nm_target "") diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index 726aa5975f221..15a051fa96a6e 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -1,20 +1,12 @@ -cmake_minimum_required(VERSION 3.13.4) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(LLVM REQUIRED) +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) add_executable(${PROJECT_NAME} test_package.cpp) -target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) -if(TARGET LLVMInterpreter) # static libraries - target_link_libraries(${PROJECT_NAME} PRIVATE - LLVMInterpreter - LLVMIRReader - LLVMX86CodeGen - ) -else() # shared library - target_link_libraries(${PROJECT_NAME} LLVM) +if (LLVM_SHARED) + find_package(LLVM REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE LLVM) +else() + find_package(LLVM REQUIRED COMPONENTS LLVMSupport) + target_link_libraries(${PROJECT_NAME} PRIVATE LLVMSupport) endif() diff --git a/recipes/llvm-core/all/test_package/conanfile.py b/recipes/llvm-core/all/test_package/conanfile.py index e0ca8f6b664cb..cb454e880203d 100644 --- a/recipes/llvm-core/all/test_package/conanfile.py +++ b/recipes/llvm-core/all/test_package/conanfile.py @@ -1,39 +1,53 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import cmake_layout, CMakeDeps, CMakeToolchain, CMake +from conan.tools.env import VirtualRunEnv +from conan.tools.build import can_run -import os.path +import os +import re -class LLVMCoreTestPackageConan(ConanFile): - settings = ('os', 'arch', 'compiler', 'build_type') - generators = ('cmake', 'cmake_find_package') +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.tool_requires("cmake/[>=3.21.3 <4.0.0]") + self.tool_requires("ninja/[>=1.10.0 <2.0.0]") + + def generate(self): + deps = CMakeDeps(self) + deps.check_components_exist = True + deps.generate() + + tc = CMakeToolchain(self) + if self.dependencies[self.tested_reference_str].options.shared: + tc.variables["LLVM_SHARED"] = True + tc.generate() + + VirtualRunEnv(self).generate() + + def _llvm_major_version(self): + pattern = re.compile("^llvm-core/([0-9]+)") + return int(re.findall(pattern, self.tested_reference_str)[0]) + + def _ccpstd(self): + cppstd = 14 + if self._llvm_major_version() >= 16: + cppstd = 17 + return cppstd def build(self): - build_system = CMake(self) - build_system.configure() - build_system.build() + cmake = CMake(self) + cmake.configure() + cmake.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: - 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 = self.deps_cpp_info['llvm-core'].rootpath - license_path = os.path.join(llvm_path, 'licenses', 'LICENSE.TXT') - assert os.path.exists(license_path) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/llvm-core/all/test_package/test_function.ll b/recipes/llvm-core/all/test_package/test_function.ll deleted file mode 100644 index 6e62088cd308d..0000000000000 --- a/recipes/llvm-core/all/test_package/test_function.ll +++ /dev/null @@ -1,6 +0,0 @@ -@.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 index e5de3a64aa80d..8b822065d1dfa 100644 --- a/recipes/llvm-core/all/test_package/test_package.cpp +++ b/recipes/llvm-core/all/test_package/test_package.cpp @@ -1,38 +1,455 @@ -#include -#include -#include -#include -#include -#include -#include +// 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 +#include +#include #include +#include +#include +//===----------------------------------------------------------------------===// +// Lexer +//===----------------------------------------------------------------------===// -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(); +// The lexer returns tokens [0-255] if it is an unknown character, otherwise one +// of these for known things. +enum Token { + tok_eof = -1, + + // commands + tok_def = -2, + tok_extern = -3, + + // primary + tok_identifier = -4, + tok_number = -5 +}; + +static std::string IdentifierStr; // Filled in if tok_identifier +static double NumVal; // Filled in if tok_number + +/// gettok - Return the next token from standard input. +static int gettok() { + static int LastChar = ' '; + + // Skip any whitespace. + while (isspace(LastChar)) + LastChar = getchar(); + + if (isalpha(LastChar)) { // identifier: [a-zA-Z][a-zA-Z0-9]* + IdentifierStr = LastChar; + while (isalnum((LastChar = getchar()))) + IdentifierStr += LastChar; + + if (IdentifierStr == "def") + return tok_def; + if (IdentifierStr == "extern") + return tok_extern; + return tok_identifier; + } + + if (isdigit(LastChar) || LastChar == '.') { // Number: [0-9.]+ + std::string NumStr; + do { + NumStr += LastChar; + LastChar = getchar(); + } while (isdigit(LastChar) || LastChar == '.'); + + NumVal = strtod(NumStr.c_str(), nullptr); + return tok_number; + } + + if (LastChar == '#') { + // Comment until end of line. + do + LastChar = getchar(); + while (LastChar != EOF && LastChar != '\n' && LastChar != '\r'); + + if (LastChar != EOF) + return gettok(); + } + + // Check for end of file. Don't eat the EOF. + if (LastChar == EOF) + return tok_eof; + + // Otherwise, just return the character as its ascii value. + int ThisChar = LastChar; + LastChar = getchar(); + return ThisChar; +} + +//===----------------------------------------------------------------------===// +// Abstract Syntax Tree (aka Parse Tree) +//===----------------------------------------------------------------------===// + +namespace { + +/// ExprAST - Base class for all expression nodes. +class ExprAST { +public: + virtual ~ExprAST() = default; +}; + +/// NumberExprAST - Expression class for numeric literals like "1.0". +class NumberExprAST : public ExprAST { + double Val; + +public: + NumberExprAST(double Val) : Val(Val) {} +}; + +/// VariableExprAST - Expression class for referencing a variable, like "a". +class VariableExprAST : public ExprAST { + std::string Name; + +public: + VariableExprAST(const std::string &Name) : Name(Name) {} +}; + +/// BinaryExprAST - Expression class for a binary operator. +class BinaryExprAST : public ExprAST { + char Op; + std::unique_ptr LHS, RHS; + +public: + BinaryExprAST(char Op, std::unique_ptr LHS, + std::unique_ptr RHS) + : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {} +}; + +/// CallExprAST - Expression class for function calls. +class CallExprAST : public ExprAST { + std::string Callee; + std::vector> Args; + +public: + CallExprAST(const std::string &Callee, + std::vector> Args) + : Callee(Callee), Args(std::move(Args)) {} +}; + +/// PrototypeAST - This class represents the "prototype" for a function, +/// which captures its name, and its argument names (thus implicitly the number +/// of arguments the function takes). +class PrototypeAST { + std::string Name; + std::vector Args; + +public: + PrototypeAST(const std::string &Name, std::vector Args) + : Name(Name), Args(std::move(Args)) {} + + const std::string &getName() const { return Name; } +}; + +/// FunctionAST - This class represents a function definition itself. +class FunctionAST { + std::unique_ptr Proto; + std::unique_ptr Body; + +public: + FunctionAST(std::unique_ptr Proto, + std::unique_ptr Body) + : Proto(std::move(Proto)), Body(std::move(Body)) {} +}; + +} // end anonymous namespace + +//===----------------------------------------------------------------------===// +// Parser +//===----------------------------------------------------------------------===// + +/// CurTok/getNextToken - Provide a simple token buffer. CurTok is the current +/// token the parser is looking at. getNextToken reads another token from the +/// lexer and updates CurTok with its results. +static int CurTok; +static int getNextToken() { return CurTok = gettok(); } + +/// BinopPrecedence - This holds the precedence for each binary operator that is +/// defined. +static std::map BinopPrecedence; + +/// GetTokPrecedence - Get the precedence of the pending binary operator token. +static int GetTokPrecedence() { + if (!isascii(CurTok)) + return -1; + + // Make sure it's a declared binop. + int TokPrec = BinopPrecedence[CurTok]; + if (TokPrec <= 0) + return -1; + return TokPrec; +} + +/// LogError* - These are little helper functions for error handling. +std::unique_ptr LogError(const char *Str) { + fprintf(stderr, "Error: %s\n", Str); + return nullptr; +} +std::unique_ptr LogErrorP(const char *Str) { + LogError(Str); + return nullptr; +} + +static std::unique_ptr ParseExpression(); + +/// numberexpr ::= number +static std::unique_ptr ParseNumberExpr() { + auto Result = std::make_unique(NumVal); + getNextToken(); // consume the number + return std::move(Result); +} + +/// parenexpr ::= '(' expression ')' +static std::unique_ptr ParseParenExpr() { + getNextToken(); // eat (. + auto V = ParseExpression(); + if (!V) + return nullptr; + + if (CurTok != ')') + return LogError("expected ')'"); + getNextToken(); // eat ). + return V; +} + +/// identifierexpr +/// ::= identifier +/// ::= identifier '(' expression* ')' +static std::unique_ptr ParseIdentifierExpr() { + std::string IdName = IdentifierStr; + + getNextToken(); // eat identifier. + + if (CurTok != '(') // Simple variable ref. + return std::make_unique(IdName); + + // Call. + getNextToken(); // eat ( + std::vector> Args; + if (CurTok != ')') { + while (true) { + if (auto Arg = ParseExpression()) + Args.push_back(std::move(Arg)); + else + return nullptr; + + if (CurTok == ')') + break; + + if (CurTok != ',') + return LogError("Expected ')' or ',' in argument list"); + getNextToken(); + } + } + + // Eat the ')'. + getNextToken(); + + return std::make_unique(IdName, std::move(Args)); +} + +/// primary +/// ::= identifierexpr +/// ::= numberexpr +/// ::= parenexpr +static std::unique_ptr ParsePrimary() { + switch (CurTok) { + default: + return LogError("unknown token when expecting an expression"); + case tok_identifier: + return ParseIdentifierExpr(); + case tok_number: + return ParseNumberExpr(); + case '(': + return ParseParenExpr(); + } +} + +/// binoprhs +/// ::= ('+' primary)* +static std::unique_ptr ParseBinOpRHS(int ExprPrec, + std::unique_ptr LHS) { + // If this is a binop, find its precedence. + while (true) { + int TokPrec = GetTokPrecedence(); + + // If this is a binop that binds at least as tightly as the current binop, + // consume it, otherwise we are done. + if (TokPrec < ExprPrec) + return LHS; + + // Okay, we know this is a binop. + int BinOp = CurTok; + getNextToken(); // eat binop + + // Parse the primary expression after the binary operator. + auto RHS = ParsePrimary(); + if (!RHS) + return nullptr; + + // If BinOp binds less tightly with RHS than the operator after RHS, let + // the pending operator take RHS as its LHS. + int NextPrec = GetTokPrecedence(); + if (TokPrec < NextPrec) { + RHS = ParseBinOpRHS(TokPrec + 1, std::move(RHS)); + if (!RHS) + return nullptr; + } + + // Merge LHS/RHS. + LHS = + std::make_unique(BinOp, std::move(LHS), std::move(RHS)); + } +} + +/// expression +/// ::= primary binoprhs +/// +static std::unique_ptr ParseExpression() { + auto LHS = ParsePrimary(); + if (!LHS) + return nullptr; + + return ParseBinOpRHS(0, std::move(LHS)); +} + +/// prototype +/// ::= id '(' id* ')' +static std::unique_ptr ParsePrototype() { + if (CurTok != tok_identifier) + return LogErrorP("Expected function name in prototype"); + + std::string FnName = IdentifierStr; + getNextToken(); + + if (CurTok != '(') + return LogErrorP("Expected '(' in prototype"); + + std::vector ArgNames; + while (getNextToken() == tok_identifier) + ArgNames.push_back(IdentifierStr); + if (CurTok != ')') + return LogErrorP("Expected ')' in prototype"); + + // success. + getNextToken(); // eat ')'. + + return std::make_unique(FnName, std::move(ArgNames)); +} + +/// definition ::= 'def' prototype expression +static std::unique_ptr ParseDefinition() { + getNextToken(); // eat def. + auto Proto = ParsePrototype(); + if (!Proto) + return nullptr; + + if (auto E = ParseExpression()) + return std::make_unique(std::move(Proto), std::move(E)); + return nullptr; +} + +/// toplevelexpr ::= expression +static std::unique_ptr ParseTopLevelExpr() { + if (auto E = ParseExpression()) { + // Make an anonymous proto. + auto Proto = std::make_unique("__anon_expr", + std::vector()); + return std::make_unique(std::move(Proto), std::move(E)); + } + return nullptr; +} + +/// external ::= 'extern' prototype +static std::unique_ptr ParseExtern() { + getNextToken(); // eat extern. + return ParsePrototype(); +} + +//===----------------------------------------------------------------------===// +// Top-Level parsing +//===----------------------------------------------------------------------===// + +static void HandleDefinition() { + if (ParseDefinition()) { + fprintf(stderr, "Parsed a function definition.\n"); + } else { + // Skip token for error recovery. + getNextToken(); + } +} + +static void HandleExtern() { + if (ParseExtern()) { + fprintf(stderr, "Parsed an extern\n"); + } else { + // Skip token for error recovery. + getNextToken(); + } +} + +static void HandleTopLevelExpression() { + // Evaluate a top-level expression into an anonymous function. + if (ParseTopLevelExpr()) { + fprintf(stderr, "Parsed a top-level expr\n"); + } else { + // Skip token for error recovery. + getNextToken(); + } +} + +/// top ::= definition | external | expression | ';' +static void MainLoop() { + while (true) { + fprintf(stderr, "ready> "); + switch (CurTok) { + case tok_eof: + return; + case ';': // ignore top-level semicolons. + getNextToken(); + break; + case tok_def: + HandleDefinition(); + break; + case tok_extern: + HandleExtern(); + break; + default: + HandleTopLevelExpression(); + break; + } + } +} + +//===----------------------------------------------------------------------===// +// Main driver code. +//===----------------------------------------------------------------------===// + +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) + + // Install standard binary operators. + // 1 is lowest precedence. + BinopPrecedence['<'] = 10; + BinopPrecedence['+'] = 20; + BinopPrecedence['-'] = 20; + BinopPrecedence['*'] = 40; // highest. + + // Prime the first token. + fprintf(stderr, "ready> "); + getNextToken(); + + // Run the main "interpreter loop" now. + MainLoop(); + + return 0; } From e94c89c670c589e1544865f8ecc898d835f35458 Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Tue, 5 Mar 2024 22:19:31 +0000 Subject: [PATCH 02/77] [llvm-core] add support for job pool resource limits from @jusito --- recipes/llvm-core/all/conandata.yml | 7 +++ recipes/llvm-core/all/conanfile.py | 39 ++++++++++---- .../patches/11x/00-calculate-job-pools.patch | 52 +++++++++++++++++++ .../patches/12x/00-cmake-target-props.patch | 20 +++++++ .../patches/12x/01-calculate-job-pools.patch | 52 +++++++++++++++++++ .../patches/13x/01-calculate-job-pools.patch | 52 +++++++++++++++++++ 6 files changed, 212 insertions(+), 10 deletions(-) create mode 100644 recipes/llvm-core/all/patches/11x/00-calculate-job-pools.patch create mode 100644 recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch create mode 100644 recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch create mode 100644 recipes/llvm-core/all/patches/13x/01-calculate-job-pools.patch diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index d6ad564043b1f..060883de39e88 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -10,4 +10,11 @@ sources: sha256: ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5 patches: + "13.0.0": - patch_file: "patches/13x/00-cmake-target-props.patch" + - patch_file: "patches/13x/01-calculate-job-pools.patch" + "12.0.0": + - patch_file: "patches/12x/00-cmake-target-props.patch" + - patch_file: "patches/12x/01-calculate-job-pools.patch" + "11.1.0": + - patch_file: "patches/11x/00-calculate-job-pools.patch" diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index c33b69718ce3f..4577a9727e3a5 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -54,7 +54,10 @@ class LLVMCoreConan(ConanFile): 'with_terminfo': [True, False], 'with_zlib': [True, False], 'with_xml2': [True, False], + 'with_z3': [True, False], 'use_llvm_cmake_files': [True, False], + 'ram_per_compile_job': ['ANY'], + 'ram_per_link_job': ['ANY'], } default_options = { 'shared': False, @@ -71,10 +74,14 @@ class LLVMCoreConan(ConanFile): 'use_perf': False, 'use_sanitizer': 'None', 'with_ffi': False, - 'with_zlib': True, + 'with_terminfo': False, # differs from LLVM default 'with_xml2': True, + 'with_z3': True, + 'with_zlib': True, 'use_llvm_cmake_files': False, - 'with_terminfo': False # differs from LLVM default + # creating job pools with current free memory + 'ram_per_compile_job': '2000', + 'ram_per_link_job': '14000' } @property @@ -143,7 +150,8 @@ def source(self): def generate(self): tc = CMakeToolchain(self) - # See https://releases.llvm.org/13.0.0/docs/CMake.html + # https://releases.llvm.org/12.0.0/docs/CMake.html + # https://releases.llvm.org/13.0.0/docs/CMake.html cmake_definitions = { 'LLVM_TARGETS_TO_BUILD': self.options.targets, 'LLVM_BUILD_LLVM_DYLIB': self.options.shared, @@ -163,11 +171,13 @@ def generate(self): 'LLVM_ENABLE_EXPENSIVE_CHECKS': self.options.expensive_checks, 'LLVM_ENABLE_ASSERTIONS': self.settings.build_type, 'LLVM_USE_PERF': self.options.use_perf, - 'LLVM_ENABLE_Z3_SOLVER': True, + 'LLVM_ENABLE_Z3_SOLVER': self.options.with_z3, 'LLVM_ENABLE_FFI': self.options.with_ffi, 'LLVM_ENABLE_ZLIB': "FORCE_ON" if self.options.with_zlib else False, - 'LLVM_ENABLE_LIBXML2': self.options.with_xml2, - 'LLVM_ENABLE_TERMINFO': self.options.with_terminfo + 'LLVM_ENABLE_LIBXML2': "FORCE_ON" if self.options.with_xml2 else False, + 'LLVM_ENABLE_TERMINFO': self.options.with_terminfo, + 'LLVM_RAM_PER_COMPILE_JOB': self.options.ram_per_compile_job, + 'LLVM_RAM_PER_LINK_JOB': self.options.ram_per_link_job } if is_msvc(self): build_type = str(self.settings.build_type).upper() @@ -211,15 +221,17 @@ def build(self): cmake.configure(cli_args=["--graphviz=graph/llvm.dot"]) cmake.build() - def package_id(self): - del self.info.options.use_llvm_cmake_files - @property def _is_windows(self): return self.settings.os == 'Windows' def _llvm_components(self): + # TODO (@planetmarshall) this is a bit hacky. CMake already has this information, just + # parse the LLVM CMake files. # The definitive list of built targets is provided by running `llvm-config --components` + non_distributed = { + "exegesis" + } graphviz_folder = Path(self.build_folder) / "graph" match_component = re.compile(r"""^llvm.dot.LLVM(.+)\.dependers$""") for lib in iglob(str(graphviz_folder / '*')): @@ -229,7 +241,9 @@ def _llvm_components(self): match = match_component.match(lib_name) if match: component = match.group(1) - yield component.lower(), f"LLVM{component}" + component_name = component.lower() + if component_name not in non_distributed: + yield component.lower(), f"LLVM{component}" @property def _components_data_file(self): @@ -256,6 +270,11 @@ def package(self): if not self.options.shared: self._write_components() + def package_id(self): + del self.info.options.use_llvm_cmake_files + del self.info.options.ram_per_compile_job + del self.info.options.ram_per_link_job + def package_info(self): self.cpp_info.set_property("cmake_file_name", "LLVM") diff --git a/recipes/llvm-core/all/patches/11x/00-calculate-job-pools.patch b/recipes/llvm-core/all/patches/11x/00-calculate-job-pools.patch new file mode 100644 index 0000000000000..ba945c29fb574 --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/00-calculate-job-pools.patch @@ -0,0 +1,52 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 5ef22eb493b..7078ae8bc86 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -25,8 +25,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.") +@@ -36,8 +52,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-core/all/patches/12x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch new file mode 100644 index 0000000000000..d249f9afbd13c --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch @@ -0,0 +1,20 @@ +diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt +index cdee11412eb..f32a7b7909d 100644 +--- a/lib/Support/CMakeLists.txt ++++ b/lib/Support/CMakeLists.txt +@@ -236,14 +236,7 @@ set(llvm_system_libs ${system_libs}) + # This block is only needed for llvm-config. When we deprecate llvm-config and + # move to using CMake export, this block can be removed. + if(LLVM_ENABLE_ZLIB) +- # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. +- if(CMAKE_BUILD_TYPE) +- string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type}) +- endif() +- if(NOT zlib_library) +- get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION) +- endif() ++ set(zlib_library ${ZLIB_LIBRARIES}) + get_library_name(${zlib_library} zlib_library) + set(llvm_system_libs ${llvm_system_libs} "${zlib_library}") + endif() diff --git a/recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch b/recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch new file mode 100644 index 0000000000000..7f3c39eca2f93 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch @@ -0,0 +1,52 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 5d4d692a70a..94717899a02 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -25,8 +25,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.") +@@ -36,8 +52,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-core/all/patches/13x/01-calculate-job-pools.patch b/recipes/llvm-core/all/patches/13x/01-calculate-job-pools.patch new file mode 100644 index 0000000000000..468668eefd89e --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/01-calculate-job-pools.patch @@ -0,0 +1,52 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 0c3419390c2..8bcd91e1787 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/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.") From 060ef41e8a0cf7baacc342ae1e0815716e9c7a85 Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Tue, 5 Mar 2024 23:54:09 +0000 Subject: [PATCH 03/77] [llvm-core] add cmake patch for 12.0.0 --- .../patches/12x/00-cmake-target-props.patch | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch index d249f9afbd13c..d0129d862e158 100644 --- a/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch +++ b/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch @@ -1,3 +1,16 @@ +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +index 818fafbce14..14f5b67f168 100644 +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake +@@ -127,7 +127,7 @@ if(LLVM_ENABLE_ZLIB) + # library on a 64-bit system which would result in a link-time failure. + cmake_push_check_state() + list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) +- list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARY}) ++ list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES}) + check_symbol_exists(compress2 zlib.h HAVE_ZLIB) + cmake_pop_check_state() + if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB) diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index cdee11412eb..f32a7b7909d 100644 --- a/lib/Support/CMakeLists.txt @@ -18,3 +31,23 @@ index cdee11412eb..f32a7b7909d 100644 get_library_name(${zlib_library} zlib_library) set(llvm_system_libs ${llvm_system_libs} "${zlib_library}") endif() +diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt +index 8134ac8c815..f4d91c9d56d 100644 +--- a/lib/WindowsManifest/CMakeLists.txt ++++ b/lib/WindowsManifest/CMakeLists.txt +@@ -21,14 +21,7 @@ add_llvm_component_library(LLVMWindowsManifest + # This block is only needed for llvm-config. When we deprecate llvm-config and + # move to using CMake export, this block can be removed. + 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}) +- endif() +- if(NOT zlib_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) +- endif() ++ set(libxml2_library ${libxml2_LIBRARIES}) + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) + endif() From 38e08a5962718168665ef0fc63ffe74de17158b7 Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Wed, 6 Mar 2024 08:09:29 +0000 Subject: [PATCH 04/77] [llvm-core] add cmake patch for 11.1.0 --- recipes/llvm-core/all/conandata.yml | 3 ++- .../11x/00-cmake-find-package-zlib.patch | 18 ++++++++++++++++++ ...ools.patch => 01-calculate-job-pools.patch} | 0 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch rename recipes/llvm-core/all/patches/11x/{00-calculate-job-pools.patch => 01-calculate-job-pools.patch} (100%) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 060883de39e88..33744da95eb47 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -17,4 +17,5 @@ patches: - patch_file: "patches/12x/00-cmake-target-props.patch" - patch_file: "patches/12x/01-calculate-job-pools.patch" "11.1.0": - - patch_file: "patches/11x/00-calculate-job-pools.patch" + - patch_file: "patches/11x/00-cmake-find-package-zlib.patch" + - patch_file: "patches/11x/01-calculate-job-pools.patch" diff --git a/recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch b/recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch new file mode 100644 index 0000000000000..5cc0429fe874e --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch @@ -0,0 +1,18 @@ +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +index 90e5d327c75..bef1563b861 100644 +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake +@@ -517,11 +517,8 @@ else( LLVM_ENABLE_THREADS ) + message(STATUS "Threads disabled.") + endif() + +-if (LLVM_ENABLE_ZLIB ) +- # Check if zlib is available in the system. +- if ( NOT HAVE_ZLIB_H OR NOT HAVE_LIBZ ) +- set(LLVM_ENABLE_ZLIB 0) +- endif() ++if ( LLVM_ENABLE_ZLIB ) ++ find_package(ZLIB REQUIRED) + endif() + + if (LLVM_ENABLE_DOXYGEN) diff --git a/recipes/llvm-core/all/patches/11x/00-calculate-job-pools.patch b/recipes/llvm-core/all/patches/11x/01-calculate-job-pools.patch similarity index 100% rename from recipes/llvm-core/all/patches/11x/00-calculate-job-pools.patch rename to recipes/llvm-core/all/patches/11x/01-calculate-job-pools.patch From e45b3bc91ee37d2963aebf0d629ed6c2503b9ca3 Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Wed, 6 Mar 2024 08:41:52 +0000 Subject: [PATCH 05/77] [llvm-core] allow conan 1.x --- 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 4577a9727e3a5..193628259adfb 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -12,7 +12,7 @@ from pathlib import Path import re -required_conan_version = ">=2.0.0" +required_conan_version = ">=1.62.0" class LLVMCoreConan(ConanFile): From 026b59eda2143b376a5e82dfb6a191e0dd62916f Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 6 Mar 2024 16:18:45 +0000 Subject: [PATCH 06/77] [llvm-core] fix zlib detection for 11.1.0 --- .../11x/00-cmake-find-package-zlib.patch | 65 +++++++++++++++---- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch b/recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch index 5cc0429fe874e..069d56e8aff6a 100644 --- a/recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch +++ b/recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch @@ -1,18 +1,61 @@ diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake -index 90e5d327c75..bef1563b861 100644 +index 90e5d327c75..2bc924b79e7 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake -@@ -517,11 +517,8 @@ else( LLVM_ENABLE_THREADS ) +@@ -5,6 +5,7 @@ endif() + + include(CheckIncludeFile) + include(CheckLibraryExists) ++include(CMakePushCheckState) + include(CheckSymbolExists) + include(CheckFunctionExists) + include(CheckStructHasMember) +@@ -56,7 +57,15 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H) + check_include_file(termios.h HAVE_TERMIOS_H) + check_include_file(unistd.h HAVE_UNISTD_H) + check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H) +-check_include_file(zlib.h HAVE_ZLIB_H) ++ ++if(LLVM_ENABLE_ZLIB) ++ find_package(ZLIB REQUIRED) ++ cmake_push_check_state() ++ list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) ++ check_include_file(zlib.h HAVE_ZLIB_H) ++ cmake_pop_check_state() ++endif() ++ + check_include_file(fenv.h HAVE_FENV_H) + check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT) + check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT) +@@ -118,17 +127,12 @@ endif() + # Don't look for these libraries if we're using MSan, since uninstrumented third + # party code may call MSan interceptors like strlen, leading to false positives. + if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") +- set(HAVE_LIBZ 0) + if(LLVM_ENABLE_ZLIB) +- foreach(library z zlib_static zlib) +- string(TOUPPER ${library} library_suffix) +- check_library_exists(${library} compress2 "" HAVE_LIBZ_${library_suffix}) +- if(HAVE_LIBZ_${library_suffix}) +- set(HAVE_LIBZ 1) +- set(ZLIB_LIBRARIES "${library}") +- break() +- endif() +- endforeach() ++ cmake_push_check_state() ++ list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) ++ list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES}) ++ check_symbol_exists(compress2 zlib.h HAVE_LIBZ) ++ cmake_pop_check_state() + endif() + + # Don't look for these libraries on Windows. +@@ -517,7 +521,7 @@ else( LLVM_ENABLE_THREADS ) message(STATUS "Threads disabled.") endif() -if (LLVM_ENABLE_ZLIB ) -- # Check if zlib is available in the system. -- if ( NOT HAVE_ZLIB_H OR NOT HAVE_LIBZ ) -- set(LLVM_ENABLE_ZLIB 0) -- endif() -+if ( LLVM_ENABLE_ZLIB ) -+ find_package(ZLIB REQUIRED) - endif() - - if (LLVM_ENABLE_DOXYGEN) ++if (LLVM_ENABLE_ZLIB STREQUAL "FORCE_ON") + # Check if zlib is available in the system. + if ( NOT HAVE_ZLIB_H OR NOT HAVE_LIBZ ) + set(LLVM_ENABLE_ZLIB 0) From 2c1a86322c2c851ed3235b3bc4b722165a8a6643 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 6 Mar 2024 21:22:00 +0000 Subject: [PATCH 07/77] [llvm-core] additional patches for missing includes and patch metadata --- recipes/llvm-core/all/conandata.yml | 34 ++++++++++++++++--- recipes/llvm-core/all/conanfile.py | 7 ++-- .../all/patches/11x/02-missing-includes.patch | 24 +++++++++++++ .../all/patches/12x/02-missing-includes.patch | 12 +++++++ .../all/patches/13x/02-missing-includes.patch | 12 +++++++ 5 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 recipes/llvm-core/all/patches/11x/02-missing-includes.patch create mode 100644 recipes/llvm-core/all/patches/12x/02-missing-includes.patch create mode 100644 recipes/llvm-core/all/patches/13x/02-missing-includes.patch diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 33744da95eb47..1e134971b338f 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -11,11 +11,35 @@ sources: patches: "13.0.0": - - patch_file: "patches/13x/00-cmake-target-props.patch" - - patch_file: "patches/13x/01-calculate-job-pools.patch" + - patch_file: patches/13x/00-cmake-target-props.patch + patch_description: fix references to third party libs to match conan variables and targets + patch_type: conan + - patch_file: patches/13x/01-calculate-job-pools.patch + patch_description: calculate resource limits for compiling LLVM + patch_type: portability + patch_source: https://github.com/conan-io/conan-center-index/pull/17509 + - patch_file: patches/13x/02-missing-includes.patch + patch_description: fix missing header files + patch_type: portability "12.0.0": - - patch_file: "patches/12x/00-cmake-target-props.patch" - - patch_file: "patches/12x/01-calculate-job-pools.patch" + - patch_file: patches/12x/00-cmake-target-props.patch + patch_description: fix references to third party libs to match conan variables and targets + patch_type: conan + - patch_file: patches/12x/01-calculate-job-pools.patch + patch_description: calculate resource limits for compiling LLVM + patch_type: portability + patch_source: https://github.com/conan-io/conan-center-index/pull/17509 + - patch_file: patches/12x/02-missing-includes.patch + patch_description: fix missing header files + patch_type: portability "11.1.0": - - patch_file: "patches/11x/00-cmake-find-package-zlib.patch" + - patch_file: patches/11x/00-cmake-find-package-zlib.patch + patch_description: find zlib using conan rather than assuming a system library + patch_type: conan - patch_file: "patches/11x/01-calculate-job-pools.patch" + patch_description: calculate resource limits for compiling LLVM + patch_type: portability + patch_source: https://github.com/conan-io/conan-center-index/pull/17509 + - patch_file: patches/11x/02-missing-includes.patch + patch_description: fix missing header files + patch_type: portability diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 193628259adfb..be8e125ba0380 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -121,6 +121,9 @@ def requirements(self): self.requires('libxml2/2.12.4') self.requires('z3/4.12.4') + def build_requirements(self): + self.tool_requires("ninja/1.11.1") + @property def _is_gcc(self): return self.settings.compiler == "gcc" @@ -133,10 +136,6 @@ def validate(self): raise ConanInvalidConfiguration( f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) - if self._is_gcc and Version(self.settings.compiler.version) >= "13": - raise ConanInvalidConfiguration( - f"GCC {self.settings.compiler.version} cannot compile LLVM {self.version}" - ) if self._is_windows: if self.options.shared: # Shared builds disabled just due to the CI diff --git a/recipes/llvm-core/all/patches/11x/02-missing-includes.patch b/recipes/llvm-core/all/patches/11x/02-missing-includes.patch new file mode 100644 index 0000000000000..929a539e77369 --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/02-missing-includes.patch @@ -0,0 +1,24 @@ +diff --git a/include/llvm/Support/Signals.h b/include/llvm/Support/Signals.h +index e0a18e72f2a..148216b8f87 100644 +--- a/include/llvm/Support/Signals.h ++++ b/include/llvm/Support/Signals.h +@@ -14,6 +14,7 @@ + #ifndef LLVM_SUPPORT_SIGNALS_H + #define LLVM_SUPPORT_SIGNALS_H + ++#include + #include + + namespace llvm { +diff --git a/utils/benchmark/src/benchmark_register.h b/utils/benchmark/src/benchmark_register.h +index 0705e219f2f..4caa5ad4da0 100644 +--- a/utils/benchmark/src/benchmark_register.h ++++ b/utils/benchmark/src/benchmark_register.h +@@ -1,6 +1,7 @@ + #ifndef BENCHMARK_REGISTER_H + #define BENCHMARK_REGISTER_H + ++#include + #include + + #include "check.h" diff --git a/recipes/llvm-core/all/patches/12x/02-missing-includes.patch b/recipes/llvm-core/all/patches/12x/02-missing-includes.patch new file mode 100644 index 0000000000000..c7cfb90318b49 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/02-missing-includes.patch @@ -0,0 +1,12 @@ +diff --git a/include/llvm/Support/Signals.h b/include/llvm/Support/Signals.h +index 44f5a750ff5..937e0572d4a 100644 +--- a/include/llvm/Support/Signals.h ++++ b/include/llvm/Support/Signals.h +@@ -14,6 +14,7 @@ + #ifndef LLVM_SUPPORT_SIGNALS_H + #define LLVM_SUPPORT_SIGNALS_H + ++#include + #include + + namespace llvm { diff --git a/recipes/llvm-core/all/patches/13x/02-missing-includes.patch b/recipes/llvm-core/all/patches/13x/02-missing-includes.patch new file mode 100644 index 0000000000000..c7cfb90318b49 --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/02-missing-includes.patch @@ -0,0 +1,12 @@ +diff --git a/include/llvm/Support/Signals.h b/include/llvm/Support/Signals.h +index 44f5a750ff5..937e0572d4a 100644 +--- a/include/llvm/Support/Signals.h ++++ b/include/llvm/Support/Signals.h +@@ -14,6 +14,7 @@ + #ifndef LLVM_SUPPORT_SIGNALS_H + #define LLVM_SUPPORT_SIGNALS_H + ++#include + #include + + namespace llvm { From d361f4e5c9c962f73a276bf6cc6b5add69239225 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 6 Mar 2024 23:55:12 +0000 Subject: [PATCH 08/77] [llvm-core] resolve v1 hooks issues --- recipes/llvm-core/all/conanfile.py | 5 ++++- recipes/llvm-core/all/test_package/conanfile.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index be8e125ba0380..b666c6a21adb1 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -246,7 +246,7 @@ def _llvm_components(self): @property def _components_data_file(self): - return Path(self.package_folder) / "components.json" + return Path(self.package_folder) / "lib" / "components.json" def _write_components(self): component_dict = { @@ -265,6 +265,7 @@ def package(self): cmake.install() package_folder = Path(self.package_folder) rmdir(self, package_folder / "lib" / "cmake") + rmdir(self, package_folder / "share") if not self.options.shared: self._write_components() @@ -291,6 +292,8 @@ def package_info(self): self.cpp_info.components[component_name].libs = [lib_name] self.cpp_info.components[component_name].requires = dependencies + if component_name in ["lto", "remarks"] and self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components[component_name].system_libs.append("rt") else: self.cpp_info.set_property("cmake_target_name", "LLVM") self.cpp_info.libs = collect_libs(self) diff --git a/recipes/llvm-core/all/test_package/conanfile.py b/recipes/llvm-core/all/test_package/conanfile.py index cb454e880203d..f3878ab529814 100644 --- a/recipes/llvm-core/all/test_package/conanfile.py +++ b/recipes/llvm-core/all/test_package/conanfile.py @@ -27,7 +27,7 @@ def generate(self): tc = CMakeToolchain(self) if self.dependencies[self.tested_reference_str].options.shared: - tc.variables["LLVM_SHARED"] = True + tc.variables["LLVM_SHARED"] = True tc.generate() VirtualRunEnv(self).generate() From 88d783ea24f4603c021b22172981a52ffdc2b88d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 7 Mar 2024 16:23:11 +0000 Subject: [PATCH 09/77] [llvm-core] use llvm generated config file to extract components --- recipes/llvm-core/all/conanfile.py | 46 +++++++++++++----------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index b666c6a21adb1..172f14a682c44 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -206,18 +206,12 @@ def generate(self): tc.generate() def _patch_sources(self): - graphviz_settings = """ -set(GRAPHVIZ_EXECUTABLES OFF) -set(GRAPHVIZ_INTERFACE_LIBS OFF) -set(GRAPHVIZ_OBJECT_LIBS OFF) - """ - save(self, Path(self.build_folder) / "CMakeGraphVizOptions.cmake", graphviz_settings) apply_conandata_patches(self) def build(self): self._patch_sources() cmake = CMake(self) - cmake.configure(cli_args=["--graphviz=graph/llvm.dot"]) + cmake.configure() cmake.build() @property @@ -225,24 +219,24 @@ def _is_windows(self): return self.settings.os == 'Windows' def _llvm_components(self): - # TODO (@planetmarshall) this is a bit hacky. CMake already has this information, just - # parse the LLVM CMake files. - # The definitive list of built targets is provided by running `llvm-config --components` - non_distributed = { - "exegesis" - } - graphviz_folder = Path(self.build_folder) / "graph" - match_component = re.compile(r"""^llvm.dot.LLVM(.+)\.dependers$""") - for lib in iglob(str(graphviz_folder / '*')): - if os.path.isdir(lib) or os.path.islink(lib): - continue - lib_name = os.path.basename(lib) - match = match_component.match(lib_name) + with open(Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") as fp: + cmake_config = fp.read() + + match_cmake_var = re.compile(r"""^set\(LLVM_AVAILABLE_LIBS (?P.*)\)$""", re.MULTILINE) + match = match_cmake_var.search(cmake_config) + if match is None: + self.output.warning("Could not find components in LLVMConfig.cmake") + return None + + components = match.groupdict()["components"] + + match_component = re.compile(r"""^LLVM(.+)$""") + for component in components.split(";"): + match = match_component.match(component) if match: - component = match.group(1) - component_name = component.lower() - if component_name not in non_distributed: - yield component.lower(), f"LLVM{component}" + yield match.group(1).lower(), component + else: + yield component, component @property def _components_data_file(self): @@ -264,8 +258,8 @@ def package(self): cmake = CMake(self) cmake.install() package_folder = Path(self.package_folder) - rmdir(self, package_folder / "lib" / "cmake") - rmdir(self, package_folder / "share") + #rmdir(self, package_folder / "lib" / "cmake") + #rmdir(self, package_folder / "share") if not self.options.shared: self._write_components() From ca8784252ed65bc5bf770215dabb34b449c58738 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 7 Mar 2024 18:37:11 +0000 Subject: [PATCH 10/77] [llvm-core] add custom cmake build script --- recipes/llvm-core/all/conanfile.py | 53 ++++++++++++++++--- .../llvm-core/all/test_package/CMakeLists.txt | 15 +++++- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 172f14a682c44..04bcc196f9410 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -1,3 +1,5 @@ +import textwrap + from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd @@ -6,7 +8,6 @@ from conan.tools.microsoft import is_msvc from conan.tools.scm import Version -from glob import iglob import json import os from pathlib import Path @@ -78,7 +79,7 @@ class LLVMCoreConan(ConanFile): 'with_xml2': True, 'with_z3': True, 'with_zlib': True, - 'use_llvm_cmake_files': False, + 'use_llvm_cmake_files': False, # no longer used but retained for backwards compatibility # creating job pools with current free memory 'ram_per_compile_job': '2000', 'ram_per_link_job': '14000' @@ -236,12 +237,39 @@ def _llvm_components(self): if match: yield match.group(1).lower(), component else: - yield component, component + yield component.lower(), component + @property def _components_data_file(self): return Path(self.package_folder) / "lib" / "components.json" + @property + def _build_module_file_rel_path(self): + return Path("lib") / "cmake" / "llvm" / f"conan-official-{self.name}-variables.cmake" + + def _create_cmake_build_module(self, components, module_file): + # FIXME: define other LLVM CMake Variables as per + # https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project + json_text = json.dumps(components).replace('"', '\\"') + content = textwrap.dedent(f"""\ + set(LLVM_PACKAGE_VERSION "{self.version}") + + function(llvm_map_components_to_libnames OUTPUT) + set(_libnames ) + set(_components_json "{json_text}") + foreach(_component ${{ARGN}}) + string(JSON _lib_name ERROR_VARIABLE ERR GET ${{_components_json}} ${{_component}}) + if (ERR) + message(WARNING "Component ${{_component}} not found: ${{ERR}}") + endif() + list(APPEND _libnames ${{_lib_name}}) + endforeach() + set(${{OUTPUT}} ${{_libnames}} PARENT_SCOPE) + endfunction() + """) + save(self, module_file, content) + def _write_components(self): component_dict = { component: lib_name for component, lib_name in self._llvm_components() @@ -249,6 +277,8 @@ def _write_components(self): with open(self._components_data_file, 'w') as fp: json.dump(component_dict, fp) + return component_dict + def _read_components(self) -> dict: with open(self._components_data_file) as fp: return json.load(fp) @@ -257,12 +287,20 @@ def package(self): copy(self, "LICENSE.TXT", self.source_folder, os.path.join(self.package_folder, "licenses")) cmake = CMake(self) cmake.install() - package_folder = Path(self.package_folder) - #rmdir(self, package_folder / "lib" / "cmake") - #rmdir(self, package_folder / "share") + + components = {} if not self.options.shared: - self._write_components() + components = self._write_components() + + package_folder = Path(self.package_folder) + rmdir(self, package_folder / "lib" / "cmake") + rmdir(self, package_folder / "share") + + self._create_cmake_build_module( + components, + package_folder / self._build_module_file_rel_path + ) def package_id(self): del self.info.options.use_llvm_cmake_files @@ -271,6 +309,7 @@ def package_id(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "LLVM") + self.cpp_info.set_property("cmake_build_modules", [self._build_module_file_rel_path]) dependencies = [ "zlib::zlib", diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index 15a051fa96a6e..c821fb71ce1e5 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -1,12 +1,23 @@ cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES CXX) +macro(test_llvm_cmake_variable VARIABLE) + if(NOT DEFINED ${VARIABLE}) + message(FATAL_ERROR "${VARIABLE} is not defined") + endif() + message(STATUS "${VARIABLE}: ${${VARIABLE}}") +endmacro() + add_executable(${PROJECT_NAME} test_package.cpp) if (LLVM_SHARED) find_package(LLVM REQUIRED) target_link_libraries(${PROJECT_NAME} PRIVATE LLVM) else() - find_package(LLVM REQUIRED COMPONENTS LLVMSupport) - target_link_libraries(${PROJECT_NAME} PRIVATE LLVMSupport) + find_package(LLVM REQUIRED COMPONENTS LLVMSupport LLVMCore LLVMIRReader) + llvm_map_components_to_libnames(llvm_libs support core irreader) + target_link_libraries(${PROJECT_NAME} PRIVATE ${llvm_libs}) endif() + +message(STATUS "Testing LLVM Build Module Variables") +test_llvm_cmake_variable(LLVM_PACKAGE_VERSION) From 3326832d469364d8cb1ffd2177c199822e8b0c38 Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Fri, 8 Mar 2024 10:46:38 +0000 Subject: [PATCH 11/77] [llvm-core] use run env during build and force ninja --- recipes/llvm-core/all/conanfile.py | 52 +++++++++++++++++------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 04bcc196f9410..1ce195e985c18 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -2,9 +2,10 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.build import check_min_cppstd +from conan.tools.build import check_min_cppstd, can_run from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.files import apply_conandata_patches, collect_libs, get, rmdir, save, copy, export_conandata_patches +from conan.tools.env import VirtualRunEnv +from conan.tools.files import apply_conandata_patches, collect_libs, get, rmdir, save, copy, export_conandata_patches, load from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -120,15 +121,12 @@ def requirements(self): self.requires('zlib/1.3.1') if self.options.with_xml2: self.requires('libxml2/2.12.4') - self.requires('z3/4.12.4') + if self.options.with_z3: + self.requires('z3/4.12.4') def build_requirements(self): self.tool_requires("ninja/1.11.1") - @property - def _is_gcc(self): - return self.settings.compiler == "gcc" - def validate(self): if self.settings.compiler.cppstd: check_min_cppstd(self, self._min_cppstd) @@ -149,11 +147,12 @@ def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): - tc = CMakeToolchain(self) + tc = CMakeToolchain(self, generator="Ninja") # https://releases.llvm.org/12.0.0/docs/CMake.html # https://releases.llvm.org/13.0.0/docs/CMake.html cmake_definitions = { 'LLVM_TARGETS_TO_BUILD': self.options.targets, + # See comment below on LLVM shared library builds 'LLVM_BUILD_LLVM_DYLIB': self.options.shared, 'LLVM_LINK_LLVM_DYLIB': self.options.shared, 'LLVM_DYLIB_COMPONENTS': self.options.components, @@ -196,16 +195,23 @@ def generate(self): tc.variables.update(cmake_definitions) tc.cache_variables.update({ + # Enables LLVM to find conan libraries during try_compile 'CMAKE_TRY_COMPILE_CONFIGURATION': str(self.settings.build_type), - 'BUILD_SHARED_LIBS': False, # This variable causes LLVM to build shared libs for each separate component, - # which is probably not what the user wants. Use `LLVM_BUILD_LLVM_DYLIB` instead - # to build a single shared library + # LLVM has two separate concepts of a "shared library build". + # 'BUILD_SHARED_LIBS' builds shared versions of all of the static components + # 'LLVM_BUILD_LLVM_DYLIB' builds a single shared library containing all components. + # It is likely the latter that the user expects by a 'shared library' build. + 'BUILD_SHARED_LIBS': False, }) tc.generate() tc = CMakeDeps(self) tc.generate() + if can_run(self): + # For running llvm-tblgen during the build + VirtualRunEnv(self).generate(scope="build") + def _patch_sources(self): apply_conandata_patches(self) @@ -220,8 +226,7 @@ def _is_windows(self): return self.settings.os == 'Windows' def _llvm_components(self): - with open(Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") as fp: - cmake_config = fp.read() + cmake_config = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") match_cmake_var = re.compile(r"""^set\(LLVM_AVAILABLE_LIBS (?P.*)\)$""", re.MULTILINE) match = match_cmake_var.search(cmake_config) @@ -239,7 +244,6 @@ def _llvm_components(self): else: yield component.lower(), component - @property def _components_data_file(self): return Path(self.package_folder) / "lib" / "components.json" @@ -274,13 +278,13 @@ def _write_components(self): component_dict = { component: lib_name for component, lib_name in self._llvm_components() } - with open(self._components_data_file, 'w') as fp: + with open(self._components_data_file, 'w', encoding='utf-8') as fp: json.dump(component_dict, fp) return component_dict def _read_components(self) -> dict: - with open(self._components_data_file) as fp: + with open(self._components_data_file, encoding='utf-8') as fp: return json.load(fp) def package(self): @@ -288,7 +292,6 @@ def package(self): cmake = CMake(self) cmake.install() - components = {} if not self.options.shared: components = self._write_components() @@ -310,12 +313,17 @@ def package_id(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "LLVM") self.cpp_info.set_property("cmake_build_modules", [self._build_module_file_rel_path]) + self.cpp_info.builddirs.append(os.path.dirname(self._build_module_file_rel_path)) - dependencies = [ - "zlib::zlib", - "libxml2::libxml2", - "z3::z3" - ] + dependencies = [] + if self.options.with_zlib: + dependencies.append("zlib::zlib") + if self.options.with_xml2: + dependencies.append("libxml2::libxml2") + if self.options.with_ffi: + dependencies.append("libffi::libffi") + if self.options.with_z3: + dependencies.append("z3::z3") if not self.options.shared: components = self._read_components() From 79f3f86e27085e46882c6b17e4053e3ef54832bc Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 8 Mar 2024 17:53:38 +0000 Subject: [PATCH 12/77] [llvm-core] fix patches for libxml --- .../patches/12x/00-cmake-target-props.patch | 23 ++++++++-------- .../patches/13x/00-cmake-target-props.patch | 26 +++++++++++-------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch index d0129d862e158..a2e6d6ed5252b 100644 --- a/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch +++ b/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch @@ -1,7 +1,7 @@ -diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index 818fafbce14..14f5b67f168 100644 ---- a/cmake/config-ix.cmake -+++ b/cmake/config-ix.cmake +--- a/llvm/cmake/config-ix.cmake ++++ b/llvm/cmake/config-ix.cmake @@ -127,7 +127,7 @@ if(LLVM_ENABLE_ZLIB) # library on a 64-bit system which would result in a link-time failure. cmake_push_check_state() @@ -11,10 +11,10 @@ index 818fafbce14..14f5b67f168 100644 check_symbol_exists(compress2 zlib.h HAVE_ZLIB) cmake_pop_check_state() if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB) -diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt +diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt index cdee11412eb..f32a7b7909d 100644 ---- a/lib/Support/CMakeLists.txt -+++ b/lib/Support/CMakeLists.txt +--- a/llvm/lib/Support/CMakeLists.txt ++++ b/llvm/lib/Support/CMakeLists.txt @@ -236,14 +236,7 @@ set(llvm_system_libs ${system_libs}) # This block is only needed for llvm-config. When we deprecate llvm-config and # move to using CMake export, this block can be removed. @@ -31,11 +31,11 @@ index cdee11412eb..f32a7b7909d 100644 get_library_name(${zlib_library} zlib_library) set(llvm_system_libs ${llvm_system_libs} "${zlib_library}") endif() -diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt -index 8134ac8c815..f4d91c9d56d 100644 ---- a/lib/WindowsManifest/CMakeLists.txt -+++ b/lib/WindowsManifest/CMakeLists.txt -@@ -21,14 +21,7 @@ add_llvm_component_library(LLVMWindowsManifest +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 8134ac8c815..652062f7fb9 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -21,14 +21,8 @@ add_llvm_component_library(LLVMWindowsManifest # This block is only needed for llvm-config. When we deprecate llvm-config and # move to using CMake export, this block can be removed. if(LLVM_ENABLE_LIBXML2) @@ -47,6 +47,7 @@ index 8134ac8c815..f4d91c9d56d 100644 - if(NOT zlib_library) - get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) - endif() ++ find_package(libxml2 REQUIRED CONFIG) + set(libxml2_library ${libxml2_LIBRARIES}) get_library_name(${libxml2_library} libxml2_library) set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) diff --git a/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch index a96025b74370e..66bd225427379 100644 --- a/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch +++ b/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch @@ -1,7 +1,7 @@ -diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index dd0aaadb47c..e0771f99237 100644 ---- a/cmake/config-ix.cmake -+++ b/cmake/config-ix.cmake +--- a/llvm/cmake/config-ix.cmake ++++ b/llvm/cmake/config-ix.cmake @@ -127,7 +127,7 @@ if(LLVM_ENABLE_ZLIB) # library on a 64-bit system which would result in a link-time failure. cmake_push_check_state() @@ -11,10 +11,10 @@ index dd0aaadb47c..e0771f99237 100644 check_symbol_exists(compress2 zlib.h HAVE_ZLIB) cmake_pop_check_state() if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB) -diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt +diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt index 014b4a2caf1..486e4f39642 100644 ---- a/lib/Support/CMakeLists.txt -+++ b/lib/Support/CMakeLists.txt +--- a/llvm/lib/Support/CMakeLists.txt ++++ b/llvm/lib/Support/CMakeLists.txt @@ -267,7 +267,7 @@ if(LLVM_ENABLE_ZLIB) # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. if(CMAKE_BUILD_TYPE) @@ -24,11 +24,15 @@ index 014b4a2caf1..486e4f39642 100644 endif() if(NOT zlib_library) get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION) -diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt -index 8134ac8c815..1c317791fba 100644 ---- a/lib/WindowsManifest/CMakeLists.txt -+++ b/lib/WindowsManifest/CMakeLists.txt -@@ -24,9 +24,9 @@ if(LLVM_ENABLE_LIBXML2) +diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +index 8134ac8c815..ccd772f6176 100644 +--- a/llvm/lib/WindowsManifest/CMakeLists.txt ++++ b/llvm/lib/WindowsManifest/CMakeLists.txt +@@ -21,12 +21,13 @@ add_llvm_component_library(LLVMWindowsManifest + # This block is only needed for llvm-config. When we deprecate llvm-config and + # move to using CMake export, this block can be removed. + if(LLVM_ENABLE_LIBXML2) ++ find_package(libxml2 REQUIRED CONFIG) # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. if(CMAKE_BUILD_TYPE) string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) From 7402534d8c056e84cfd528b63ef820eac2c03e09 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 8 Mar 2024 17:55:02 +0000 Subject: [PATCH 13/77] [llvm-core] bump up default ram per link job --- recipes/llvm-core/all/conanfile.py | 4 ++-- .../patches/12x/00-cmake-target-props.patch | 18 +++++++++--------- .../patches/13x/00-cmake-target-props.patch | 18 +++++++++--------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 1ce195e985c18..08e840e2d5e9a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -82,8 +82,8 @@ class LLVMCoreConan(ConanFile): 'with_zlib': True, 'use_llvm_cmake_files': False, # no longer used but retained for backwards compatibility # creating job pools with current free memory - 'ram_per_compile_job': '2000', - 'ram_per_link_job': '14000' + 'ram_per_compile_job': '2048', + 'ram_per_link_job': '16384' } @property diff --git a/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch index a2e6d6ed5252b..37cac5512345c 100644 --- a/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch +++ b/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch @@ -1,7 +1,7 @@ -diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 818fafbce14..14f5b67f168 100644 ---- a/llvm/cmake/config-ix.cmake -+++ b/llvm/cmake/config-ix.cmake +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake @@ -127,7 +127,7 @@ if(LLVM_ENABLE_ZLIB) # library on a 64-bit system which would result in a link-time failure. cmake_push_check_state() @@ -11,10 +11,10 @@ index 818fafbce14..14f5b67f168 100644 check_symbol_exists(compress2 zlib.h HAVE_ZLIB) cmake_pop_check_state() if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB) -diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt +diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index cdee11412eb..f32a7b7909d 100644 ---- a/llvm/lib/Support/CMakeLists.txt -+++ b/llvm/lib/Support/CMakeLists.txt +--- a/lib/Support/CMakeLists.txt ++++ b/lib/Support/CMakeLists.txt @@ -236,14 +236,7 @@ set(llvm_system_libs ${system_libs}) # This block is only needed for llvm-config. When we deprecate llvm-config and # move to using CMake export, this block can be removed. @@ -31,10 +31,10 @@ index cdee11412eb..f32a7b7909d 100644 get_library_name(${zlib_library} zlib_library) set(llvm_system_libs ${llvm_system_libs} "${zlib_library}") endif() -diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt index 8134ac8c815..652062f7fb9 100644 ---- a/llvm/lib/WindowsManifest/CMakeLists.txt -+++ b/llvm/lib/WindowsManifest/CMakeLists.txt +--- a/lib/WindowsManifest/CMakeLists.txt ++++ b/lib/WindowsManifest/CMakeLists.txt @@ -21,14 +21,8 @@ add_llvm_component_library(LLVMWindowsManifest # This block is only needed for llvm-config. When we deprecate llvm-config and # move to using CMake export, this block can be removed. diff --git a/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch index 66bd225427379..8c24bc4ef8320 100644 --- a/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch +++ b/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch @@ -1,7 +1,7 @@ -diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index dd0aaadb47c..e0771f99237 100644 ---- a/llvm/cmake/config-ix.cmake -+++ b/llvm/cmake/config-ix.cmake +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake @@ -127,7 +127,7 @@ if(LLVM_ENABLE_ZLIB) # library on a 64-bit system which would result in a link-time failure. cmake_push_check_state() @@ -11,10 +11,10 @@ index dd0aaadb47c..e0771f99237 100644 check_symbol_exists(compress2 zlib.h HAVE_ZLIB) cmake_pop_check_state() if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB) -diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt +diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index 014b4a2caf1..486e4f39642 100644 ---- a/llvm/lib/Support/CMakeLists.txt -+++ b/llvm/lib/Support/CMakeLists.txt +--- a/lib/Support/CMakeLists.txt ++++ b/lib/Support/CMakeLists.txt @@ -267,7 +267,7 @@ if(LLVM_ENABLE_ZLIB) # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. if(CMAKE_BUILD_TYPE) @@ -24,10 +24,10 @@ index 014b4a2caf1..486e4f39642 100644 endif() if(NOT zlib_library) get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION) -diff --git a/llvm/lib/WindowsManifest/CMakeLists.txt b/llvm/lib/WindowsManifest/CMakeLists.txt +diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt index 8134ac8c815..ccd772f6176 100644 ---- a/llvm/lib/WindowsManifest/CMakeLists.txt -+++ b/llvm/lib/WindowsManifest/CMakeLists.txt +--- a/lib/WindowsManifest/CMakeLists.txt ++++ b/lib/WindowsManifest/CMakeLists.txt @@ -21,12 +21,13 @@ add_llvm_component_library(LLVMWindowsManifest # This block is only needed for llvm-config. When we deprecate llvm-config and # move to using CMake export, this block can be removed. From 2bc8422c0d25c70b29b4cb5249b7cc0c48180e7a Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Sun, 10 Mar 2024 23:20:14 +0000 Subject: [PATCH 14/77] [llvm-core] backport split-dwarf patches from 14.x --- recipes/llvm-core/all/conandata.yml | 9 + recipes/llvm-core/all/conanfile.py | 216 +++++++++--------- .../patches/11x/01-calculate-job-pools.patch | 16 +- .../all/patches/11x/03-split-dwarf.patch | 73 ++++++ .../patches/12x/01-calculate-job-pools.patch | 16 +- .../all/patches/12x/03-split-dwarf.patch | 66 ++++++ .../patches/13x/01-calculate-job-pools.patch | 16 +- .../all/patches/13x/03-split-dwarf.patch | 63 +++++ 8 files changed, 333 insertions(+), 142 deletions(-) create mode 100644 recipes/llvm-core/all/patches/11x/03-split-dwarf.patch create mode 100644 recipes/llvm-core/all/patches/12x/03-split-dwarf.patch create mode 100644 recipes/llvm-core/all/patches/13x/03-split-dwarf.patch diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 1e134971b338f..5f021700d6e25 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -21,6 +21,9 @@ patches: - patch_file: patches/13x/02-missing-includes.patch patch_description: fix missing header files patch_type: portability + - patch_file: patches/13x/03-split-dwarf.patch + patch_description: enable split dwarf option from 14.x + patch_type: backport "12.0.0": - patch_file: patches/12x/00-cmake-target-props.patch patch_description: fix references to third party libs to match conan variables and targets @@ -32,6 +35,9 @@ patches: - patch_file: patches/12x/02-missing-includes.patch patch_description: fix missing header files patch_type: portability + - patch_file: patches/12x/03-split-dwarf.patch + patch_description: enable split dwarf option from 14.x + patch_type: backport "11.1.0": - patch_file: patches/11x/00-cmake-find-package-zlib.patch patch_description: find zlib using conan rather than assuming a system library @@ -43,3 +49,6 @@ patches: - patch_file: patches/11x/02-missing-includes.patch patch_description: fix missing header files patch_type: portability + - patch_file: patches/11x/03-split-dwarf.patch + patch_description: enable split dwarf option from 14.x + patch_type: backport diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 08e840e2d5e9a..e9f1ef3b64dfd 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -18,72 +18,72 @@ class LLVMCoreConan(ConanFile): - name = 'llvm-core' + name = "llvm-core" description = ( - 'A toolkit for the construction of highly optimized compilers,' - 'optimizers, and runtime environments.' + "A toolkit for the construction of highly optimized compilers," + "optimizers, and runtime environments." ) - license = 'Apache-2.0 WITH LLVM-exception' - topics = ('llvm', 'compiler') - homepage = 'https://llvm.org' - url = 'https://github.com/conan-io/conan-center-index' + license = "Apache-2.0 WITH LLVM-exception" + topics = ("llvm", "compiler") + homepage = "https://llvm.org" + url = "https://github.com/conan-io/conan-center-index" - settings = 'os', 'arch', 'compiler', 'build_type' + 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], - 'use_sanitizer': [ - 'Address', - 'Memory', - 'MemoryWithOrigins', - 'Undefined', - 'Thread', - 'DataFlow', - 'Address;Undefined', - 'None' + "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], + "use_sanitizer": [ + "Address", + "Memory", + "MemoryWithOrigins", + "Undefined", + "Thread", + "DataFlow", + "Address;Undefined", + "None" ], - 'with_ffi': [True, False], - 'with_terminfo': [True, False], - 'with_zlib': [True, False], - 'with_xml2': [True, False], - 'with_z3': [True, False], - 'use_llvm_cmake_files': [True, False], - 'ram_per_compile_job': ['ANY'], - 'ram_per_link_job': ['ANY'], + "with_ffi": [True, False], + "with_terminfo": [True, False], + "with_zlib": [True, False], + "with_xml2": [True, False], + "with_z3": [True, False], + "use_llvm_cmake_files": [True, False], + "ram_per_compile_job": ["ANY"], + "ram_per_link_job": ["ANY"], } 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, - 'use_sanitizer': 'None', - 'with_ffi': False, - 'with_terminfo': False, # differs from LLVM default - 'with_xml2': True, - 'with_z3': True, - 'with_zlib': True, - 'use_llvm_cmake_files': False, # no longer used but retained for backwards compatibility + "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, + "use_sanitizer": "None", + "with_ffi": False, + "with_terminfo": False, # differs from LLVM default + "with_xml2": True, + "with_z3": True, + "with_zlib": True, + "use_llvm_cmake_files": False, # no longer used but retained for backwards compatibility # creating job pools with current free memory - 'ram_per_compile_job': '2048', - 'ram_per_link_job': '16384' + "ram_per_compile_job": "2048", + "ram_per_link_job": "16384" } @property @@ -116,13 +116,13 @@ def layout(self): def requirements(self): if self.options.with_ffi: - self.requires('libffi/3.4.4') + self.requires("libffi/3.4.4") if self.options.with_zlib: - self.requires('zlib/1.3.1') + self.requires("zlib/1.3.1") if self.options.with_xml2: - self.requires('libxml2/2.12.4') + self.requires("libxml2/2.12.4") if self.options.with_z3: - self.requires('z3/4.12.4') + self.requires("z3/4.12.4") def build_requirements(self): self.tool_requires("ninja/1.11.1") @@ -138,10 +138,10 @@ def validate(self): if self._is_windows: if self.options.shared: # Shared builds disabled just due to the CI - raise ConanInvalidConfiguration('Shared builds not currently supported on Windows') + raise ConanInvalidConfiguration("Shared builds not currently supported on Windows") if self.options.exceptions and not self.options.rtti: - raise ConanInvalidConfiguration('Cannot enable exceptions without rtti support') + raise ConanInvalidConfiguration("Cannot enable exceptions without rtti support") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -151,57 +151,67 @@ def generate(self): # https://releases.llvm.org/12.0.0/docs/CMake.html # https://releases.llvm.org/13.0.0/docs/CMake.html cmake_definitions = { - 'LLVM_TARGETS_TO_BUILD': self.options.targets, + "LLVM_TARGETS_TO_BUILD": self.options.targets, # See comment below on LLVM shared library builds - 'LLVM_BUILD_LLVM_DYLIB': self.options.shared, - 'LLVM_LINK_LLVM_DYLIB': self.options.shared, - 'LLVM_DYLIB_COMPONENTS': self.options.components, - 'LLVM_ABI_BREAKING_CHECKS': 'WITH_ASSERTS', - 'LLVM_INCLUDE_TOOLS': True, - 'LLVM_INCLUDE_EXAMPLES': False, - 'LLVM_INCLUDE_TESTS': False, - 'LLVM_ENABLE_IDE': 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, - 'LLVM_USE_PERF': self.options.use_perf, - 'LLVM_ENABLE_Z3_SOLVER': self.options.with_z3, - 'LLVM_ENABLE_FFI': self.options.with_ffi, - 'LLVM_ENABLE_ZLIB': "FORCE_ON" if self.options.with_zlib else False, - 'LLVM_ENABLE_LIBXML2': "FORCE_ON" if self.options.with_xml2 else False, - 'LLVM_ENABLE_TERMINFO': self.options.with_terminfo, - 'LLVM_RAM_PER_COMPILE_JOB': self.options.ram_per_compile_job, - 'LLVM_RAM_PER_LINK_JOB': self.options.ram_per_link_job + "LLVM_BUILD_LLVM_DYLIB": self.options.shared, + "LLVM_LINK_LLVM_DYLIB": self.options.shared, + "LLVM_DYLIB_COMPONENTS": self.options.components, + "LLVM_ABI_BREAKING_CHECKS": "WITH_ASSERTS", + "LLVM_INCLUDE_TOOLS": True, + "LLVM_INCLUDE_EXAMPLES": False, + "LLVM_INCLUDE_TESTS": False, + "LLVM_ENABLE_IDE": 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, + "LLVM_USE_PERF": self.options.use_perf, + "LLVM_ENABLE_Z3_SOLVER": self.options.with_z3, + "LLVM_ENABLE_FFI": self.options.with_ffi, + "LLVM_ENABLE_ZLIB": "FORCE_ON" if self.options.with_zlib else False, + "LLVM_ENABLE_LIBXML2": "FORCE_ON" if self.options.with_xml2 else False, + "LLVM_ENABLE_TERMINFO": self.options.with_terminfo, } + if self.options.ram_per_compile_job != "auto": + cmake_definitions["LLVM_RAM_PER_COMPILE_JOB"] = self.options.ram_per_compile_job + if self.options.ram_per_link_job != "auto": + cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = self.options.ram_per_link_job + + is_platform_ELF_based = self.settings.os in [ + "Linux", "Android", "FreeBSD", "SunOS", "AIX", "Neutrino", "VxWorks" + ] + if is_platform_ELF_based: + self.output.info(f"ELF Platform Detected, optimizing memory usage during debug build linking.") + cmake_definitions["LLVM_USE_SPLIT_DWARF"] = True + if is_msvc(self): build_type = str(self.settings.build_type).upper() - cmake_definitions['LLVM_USE_CRT_{}'.format(build_type)] = self.settings.compiler.runtime + cmake_definitions["LLVM_USE_CRT_{}".format(build_type)] = self.settings.compiler.runtime if not self.options.shared: cmake_definitions.update({ - 'DISABLE_LLVM_LINK_LLVM_DYLIB': True, - 'LLVM_ENABLE_PIC': self.options.get_safe('fPIC', default=False) + "DISABLE_LLVM_LINK_LLVM_DYLIB": True, + "LLVM_ENABLE_PIC": self.options.get_safe("fPIC", default=False) }) - if self.options.use_sanitizer == 'None': - cmake_definitions['LLVM_USE_SANITIZER'] = '' + if self.options.use_sanitizer == "None": + cmake_definitions["LLVM_USE_SANITIZER"] = "" else: - cmake_definitions['LLVM_USE_SANITIZER'] = self.options.use_sanitizer + cmake_definitions["LLVM_USE_SANITIZER"] = self.options.use_sanitizer tc.variables.update(cmake_definitions) tc.cache_variables.update({ # Enables LLVM to find conan libraries during try_compile - 'CMAKE_TRY_COMPILE_CONFIGURATION': str(self.settings.build_type), + "CMAKE_TRY_COMPILE_CONFIGURATION": str(self.settings.build_type), # LLVM has two separate concepts of a "shared library build". - # 'BUILD_SHARED_LIBS' builds shared versions of all of the static components - # 'LLVM_BUILD_LLVM_DYLIB' builds a single shared library containing all components. - # It is likely the latter that the user expects by a 'shared library' build. - 'BUILD_SHARED_LIBS': False, + # "BUILD_SHARED_LIBS" builds shared versions of all of the static components + # "LLVM_BUILD_LLVM_DYLIB" builds a single shared library containing all components. + # It is likely the latter that the user expects by a "shared library" build. + "BUILD_SHARED_LIBS": False, }) tc.generate() @@ -223,7 +233,7 @@ def build(self): @property def _is_windows(self): - return self.settings.os == 'Windows' + return self.settings.os == "Windows" def _llvm_components(self): cmake_config = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") @@ -278,13 +288,13 @@ def _write_components(self): component_dict = { component: lib_name for component, lib_name in self._llvm_components() } - with open(self._components_data_file, 'w', encoding='utf-8') as fp: + with open(self._components_data_file, "w", encoding="utf-8") as fp: json.dump(component_dict, fp) return component_dict def _read_components(self) -> dict: - with open(self._components_data_file, encoding='utf-8') as fp: + with open(self._components_data_file, encoding="utf-8") as fp: return json.load(fp) def package(self): diff --git a/recipes/llvm-core/all/patches/11x/01-calculate-job-pools.patch b/recipes/llvm-core/all/patches/11x/01-calculate-job-pools.patch index ba945c29fb574..b00101aa4e526 100644 --- a/recipes/llvm-core/all/patches/11x/01-calculate-job-pools.patch +++ b/recipes/llvm-core/all/patches/11x/01-calculate-job-pools.patch @@ -1,14 +1,9 @@ diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake -index 5ef22eb493b..7078ae8bc86 100644 +index 5ef22eb493b..3478c7ef6eb 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake -@@ -25,8 +25,24 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) - - # Ninja Job Pool support +@@ -27,6 +27,19 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) # 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) @@ -27,13 +22,8 @@ index 5ef22eb493b..7078ae8bc86 100644 if(LLVM_PARALLEL_COMPILE_JOBS) if(NOT CMAKE_GENERATOR STREQUAL "Ninja") message(WARNING "Job pooling is only available with Ninja generators.") -@@ -36,8 +52,22 @@ if(LLVM_PARALLEL_COMPILE_JOBS) - endif() - endif() +@@ -38,6 +51,17 @@ 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) diff --git a/recipes/llvm-core/all/patches/11x/03-split-dwarf.patch b/recipes/llvm-core/all/patches/11x/03-split-dwarf.patch new file mode 100644 index 0000000000000..46d1594239c0f --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/03-split-dwarf.patch @@ -0,0 +1,73 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 3478c7ef6eb..85e141a1a75 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -14,6 +14,14 @@ include(CheckSymbolExists) + include(CMakeDependentOption) + include(LLVMProcessSources) + ++function(append_if condition value) ++ if (${condition}) ++ foreach(variable ${ARGN}) ++ set(${variable} "${${variable}} ${value}" PARENT_SCOPE) ++ endforeach(variable) ++ endif() ++endfunction() ++ + if(CMAKE_LINKER MATCHES "lld-link" OR (MSVC AND (LLVM_USE_LINKER STREQUAL "lld" OR LLVM_ENABLE_LLD))) + set(LINKER_IS_LLD_LINK TRUE) + else() +@@ -75,6 +83,21 @@ elseif(LLVM_PARALLEL_LINK_JOBS) + message(WARNING "Job pooling is only available with Ninja generators.") + endif() + ++# Turn on -gsplit-dwarf if requested in debug builds. ++if (LLVM_USE_SPLIT_DWARF AND ++ ((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR ++ (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO"))) ++ # Limit to clang and gcc so far. Add compilers supporting this option. ++ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR ++ CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ++ add_compile_options(-gsplit-dwarf) ++ include(LLVMCheckLinkerFlag) ++ llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX) ++ append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index" ++ CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) ++ endif() ++endif() ++ + if( LLVM_ENABLE_ASSERTIONS ) + # MSVC doesn't like _DEBUG on release builds. See PR 4379. + if( NOT MSVC ) +diff --git a/cmake/modules/LLVMCheckLinkerFlag.cmake b/cmake/modules/LLVMCheckLinkerFlag.cmake +new file mode 100644 +index 00000000000..79c4e2cb4c2 +--- /dev/null ++++ b/cmake/modules/LLVMCheckLinkerFlag.cmake +@@ -0,0 +1,26 @@ ++include(CheckLinkerFlag OPTIONAL) ++ ++if (COMMAND check_linker_flag) ++ macro(llvm_check_linker_flag) ++ check_linker_flag(${ARGN}) ++ endmacro() ++else() ++ # Until the minimum CMAKE version is 3.18 ++ ++ include(CheckCXXCompilerFlag) ++ include(CMakePushCheckState) ++ ++ # cmake builtin compatible, except we assume lang is C or CXX ++ function(llvm_check_linker_flag lang flag out_var) ++ cmake_push_check_state() ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}") ++ if("${lang}" STREQUAL "C") ++ check_c_compiler_flag("" ${out_var}) ++ elseif("${lang}" STREQUAL "CXX") ++ check_cxx_compiler_flag("" ${out_var}) ++ else() ++ message(FATAL_ERROR "\"${lang}\" is not C or CXX") ++ endif() ++ cmake_pop_check_state() ++ endfunction() ++endif() diff --git a/recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch b/recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch index 7f3c39eca2f93..ab29c3a894ccd 100644 --- a/recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch +++ b/recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch @@ -1,14 +1,9 @@ diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake -index 5d4d692a70a..94717899a02 100644 +index 5d4d692a70a..5776a85b747 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake -@@ -25,8 +25,24 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) - - # Ninja Job Pool support +@@ -27,6 +27,19 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) # 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) @@ -27,13 +22,8 @@ index 5d4d692a70a..94717899a02 100644 if(LLVM_PARALLEL_COMPILE_JOBS) if(NOT CMAKE_GENERATOR STREQUAL "Ninja") message(WARNING "Job pooling is only available with Ninja generators.") -@@ -36,8 +52,22 @@ if(LLVM_PARALLEL_COMPILE_JOBS) - endif() - endif() +@@ -38,6 +51,17 @@ 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) diff --git a/recipes/llvm-core/all/patches/12x/03-split-dwarf.patch b/recipes/llvm-core/all/patches/12x/03-split-dwarf.patch new file mode 100644 index 0000000000000..87f5e53025886 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/03-split-dwarf.patch @@ -0,0 +1,66 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 5d4d692a70a..356ed89b6a6 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -51,6 +51,29 @@ elseif(LLVM_PARALLEL_LINK_JOBS) + message(WARNING "Job pooling is only available with Ninja generators.") + endif() + ++function(append_if condition value) ++ if (${condition}) ++ foreach(variable ${ARGN}) ++ set(${variable} "${${variable}} ${value}" PARENT_SCOPE) ++ endforeach(variable) ++ endif() ++endfunction() ++ ++# Turn on -gsplit-dwarf if requested in debug builds. ++if (LLVM_USE_SPLIT_DWARF AND ++ ((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR ++ (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO"))) ++ # Limit to clang and gcc so far. Add compilers supporting this option. ++ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR ++ CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ++ add_compile_options(-gsplit-dwarf) ++ include(LLVMCheckLinkerFlag) ++ llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX) ++ append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index" ++ CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) ++ endif() ++endif() ++ + if( LLVM_ENABLE_ASSERTIONS ) + # MSVC doesn't like _DEBUG on release builds. See PR 4379. + if( NOT MSVC ) +diff --git a/cmake/modules/LLVMCheckLinkerFlag.cmake b/cmake/modules/LLVMCheckLinkerFlag.cmake +new file mode 100644 +index 00000000000..79c4e2cb4c2 +--- /dev/null ++++ b/cmake/modules/LLVMCheckLinkerFlag.cmake +@@ -0,0 +1,26 @@ ++include(CheckLinkerFlag OPTIONAL) ++ ++if (COMMAND check_linker_flag) ++ macro(llvm_check_linker_flag) ++ check_linker_flag(${ARGN}) ++ endmacro() ++else() ++ # Until the minimum CMAKE version is 3.18 ++ ++ include(CheckCXXCompilerFlag) ++ include(CMakePushCheckState) ++ ++ # cmake builtin compatible, except we assume lang is C or CXX ++ function(llvm_check_linker_flag lang flag out_var) ++ cmake_push_check_state() ++ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}") ++ if("${lang}" STREQUAL "C") ++ check_c_compiler_flag("" ${out_var}) ++ elseif("${lang}" STREQUAL "CXX") ++ check_cxx_compiler_flag("" ${out_var}) ++ else() ++ message(FATAL_ERROR "\"${lang}\" is not C or CXX") ++ endif() ++ cmake_pop_check_state() ++ endfunction() ++endif() diff --git a/recipes/llvm-core/all/patches/13x/01-calculate-job-pools.patch b/recipes/llvm-core/all/patches/13x/01-calculate-job-pools.patch index 468668eefd89e..ec100e4785349 100644 --- a/recipes/llvm-core/all/patches/13x/01-calculate-job-pools.patch +++ b/recipes/llvm-core/all/patches/13x/01-calculate-job-pools.patch @@ -1,14 +1,9 @@ diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake -index 0c3419390c2..8bcd91e1787 100644 +index 0c3419390c2..eb234109e88 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake -@@ -31,8 +31,24 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) - - # Ninja Job Pool support +@@ -33,6 +33,19 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO) # 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) @@ -27,13 +22,8 @@ index 0c3419390c2..8bcd91e1787 100644 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() +@@ -44,6 +57,17 @@ 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) diff --git a/recipes/llvm-core/all/patches/13x/03-split-dwarf.patch b/recipes/llvm-core/all/patches/13x/03-split-dwarf.patch new file mode 100644 index 0000000000000..ad89ceb34bdbc --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/03-split-dwarf.patch @@ -0,0 +1,63 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 0c3419390c2..29dabe858a3 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -57,6 +57,29 @@ elseif(LLVM_PARALLEL_LINK_JOBS) + message(WARNING "Job pooling is only available with Ninja generators.") + endif() + ++function(append_if condition value) ++ if (${condition}) ++ foreach(variable ${ARGN}) ++ set(${variable} "${${variable}} ${value}" PARENT_SCOPE) ++ endforeach(variable) ++ endif() ++endfunction() ++ ++# Turn on -gsplit-dwarf if requested in debug builds. ++if (LLVM_USE_SPLIT_DWARF AND ++ ((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR ++ (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO"))) ++ # Limit to clang and gcc so far. Add compilers supporting this option. ++ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR ++ CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ++ add_compile_options(-gsplit-dwarf) ++ include(LLVMCheckLinkerFlag) ++ llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX) ++ append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index" ++ CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) ++ endif() ++endif() ++ + if( LLVM_ENABLE_ASSERTIONS ) + # MSVC doesn't like _DEBUG on release builds. See PR 4379. + if( NOT MSVC ) +diff --git a/cmake/modules/LLVMCheckLinkerFlag.cmake b/cmake/modules/LLVMCheckLinkerFlag.cmake +index 253dd768654..79c4e2cb4c2 100644 +--- a/cmake/modules/LLVMCheckLinkerFlag.cmake ++++ b/cmake/modules/LLVMCheckLinkerFlag.cmake +@@ -5,14 +5,22 @@ if (COMMAND check_linker_flag) + check_linker_flag(${ARGN}) + endmacro() + else() ++ # Until the minimum CMAKE version is 3.18 ++ + include(CheckCXXCompilerFlag) + include(CMakePushCheckState) + +- # cmake builtin compatible, except we assume lang is CXX ++ # cmake builtin compatible, except we assume lang is C or CXX + function(llvm_check_linker_flag lang flag out_var) + cmake_push_check_state() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}") +- check_cxx_compiler_flag("" ${out_var}) ++ if("${lang}" STREQUAL "C") ++ check_c_compiler_flag("" ${out_var}) ++ elseif("${lang}" STREQUAL "CXX") ++ check_cxx_compiler_flag("" ${out_var}) ++ else() ++ message(FATAL_ERROR "\"${lang}\" is not C or CXX") ++ endif() + cmake_pop_check_state() + endfunction() + endif() From 0cc2f301a20d500ff08c604abdbb3da6e97cff6c Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Mon, 11 Mar 2024 00:34:56 +0000 Subject: [PATCH 15/77] [llvm-core] add support for cross compiling --- recipes/llvm-core/all/conanfile.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index e9f1ef3b64dfd..4298d3d7ecc56 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -2,7 +2,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.build import check_min_cppstd, can_run +from conan.tools.build import check_min_cppstd, can_run, cross_building from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.env import VirtualRunEnv from conan.tools.files import apply_conandata_patches, collect_libs, get, rmdir, save, copy, export_conandata_patches, load @@ -146,6 +146,13 @@ def validate(self): def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) + @property + def _gnu_target_triple(self): + if self.settings.os == "Macos": + return f"{self.settings.arch}-apple-darwin" + + return f"{self.settings.arch}-pc-{str(self.settings.os).lower()}" + def generate(self): tc = CMakeToolchain(self, generator="Ninja") # https://releases.llvm.org/12.0.0/docs/CMake.html @@ -181,6 +188,9 @@ def generate(self): if self.options.ram_per_link_job != "auto": cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = self.options.ram_per_link_job + if cross_building(self): + cmake_definitions["LLVM_HOST_TRIPLE"] = self._gnu_target_triple + is_platform_ELF_based = self.settings.os in [ "Linux", "Android", "FreeBSD", "SunOS", "AIX", "Neutrino", "VxWorks" ] From a834335b0d0b0fab553e8be626a549ec97621616 Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Mon, 11 Mar 2024 09:24:09 +0000 Subject: [PATCH 16/77] [llvm-core] fix patch files for split dwarf --- recipes/llvm-core/all/patches/12x/03-split-dwarf.patch | 4 ++-- recipes/llvm-core/all/patches/13x/03-split-dwarf.patch | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/llvm-core/all/patches/12x/03-split-dwarf.patch b/recipes/llvm-core/all/patches/12x/03-split-dwarf.patch index 87f5e53025886..0acc280e5826b 100644 --- a/recipes/llvm-core/all/patches/12x/03-split-dwarf.patch +++ b/recipes/llvm-core/all/patches/12x/03-split-dwarf.patch @@ -1,8 +1,8 @@ diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake -index 5d4d692a70a..356ed89b6a6 100644 +index 5776a85b747..9e1d1641146 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake -@@ -51,6 +51,29 @@ elseif(LLVM_PARALLEL_LINK_JOBS) +@@ -75,6 +75,29 @@ elseif(LLVM_PARALLEL_LINK_JOBS) message(WARNING "Job pooling is only available with Ninja generators.") endif() diff --git a/recipes/llvm-core/all/patches/13x/03-split-dwarf.patch b/recipes/llvm-core/all/patches/13x/03-split-dwarf.patch index ad89ceb34bdbc..930add90aab96 100644 --- a/recipes/llvm-core/all/patches/13x/03-split-dwarf.patch +++ b/recipes/llvm-core/all/patches/13x/03-split-dwarf.patch @@ -1,8 +1,8 @@ diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake -index 0c3419390c2..29dabe858a3 100644 +index eb234109e88..9a11f0efa49 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake -@@ -57,6 +57,29 @@ elseif(LLVM_PARALLEL_LINK_JOBS) +@@ -81,6 +81,29 @@ elseif(LLVM_PARALLEL_LINK_JOBS) message(WARNING "Job pooling is only available with Ninja generators.") endif() From b78cc12c10a0299de90df9cc552c12b626b7de28 Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Mon, 11 Mar 2024 10:06:26 +0000 Subject: [PATCH 17/77] [llvm-core] disable cross compilation --- recipes/llvm-core/all/conanfile.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 4298d3d7ecc56..cc55cc14ea399 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -143,16 +143,13 @@ def validate(self): if self.options.exceptions and not self.options.rtti: raise ConanInvalidConfiguration("Cannot enable exceptions without rtti support") + if cross_building(self): + # FIXME support cross compilation, at least for common cases like Apple Silicon -> X86 + raise ConanInvalidConfiguration("Cross compilation is not supported") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) - @property - def _gnu_target_triple(self): - if self.settings.os == "Macos": - return f"{self.settings.arch}-apple-darwin" - - return f"{self.settings.arch}-pc-{str(self.settings.os).lower()}" - def generate(self): tc = CMakeToolchain(self, generator="Ninja") # https://releases.llvm.org/12.0.0/docs/CMake.html @@ -188,9 +185,6 @@ def generate(self): if self.options.ram_per_link_job != "auto": cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = self.options.ram_per_link_job - if cross_building(self): - cmake_definitions["LLVM_HOST_TRIPLE"] = self._gnu_target_triple - is_platform_ELF_based = self.settings.os in [ "Linux", "Android", "FreeBSD", "SunOS", "AIX", "Neutrino", "VxWorks" ] From d18fa4629592f43891b2323f82ad92262f160e1e Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Mon, 11 Mar 2024 10:10:38 +0000 Subject: [PATCH 18/77] [llvm-core] add CCI build service specific behaviour --- recipes/llvm-core/all/conanfile.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index cc55cc14ea399..8949afd7685c5 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -81,9 +81,8 @@ class LLVMCoreConan(ConanFile): "with_z3": True, "with_zlib": True, "use_llvm_cmake_files": False, # no longer used but retained for backwards compatibility - # creating job pools with current free memory - "ram_per_compile_job": "2048", - "ram_per_link_job": "16384" + "ram_per_compile_job": "auto", + "ram_per_link_job": "auto" } @property @@ -110,6 +109,9 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") + if os.getenv("CONAN_CENTER_BUILD_SERVICE"): + self.options.ram_per_compile_job = "2048" + self.options.ram_per_link_job = "16384" def layout(self): cmake_layout(self, src_folder="src") @@ -185,6 +187,7 @@ def generate(self): if self.options.ram_per_link_job != "auto": cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = self.options.ram_per_link_job + # this capability is back-ported from LLVM 14.x is_platform_ELF_based = self.settings.os in [ "Linux", "Android", "FreeBSD", "SunOS", "AIX", "Neutrino", "VxWorks" ] From 990b2118bdd3e805b183ddd9826c232e0b70d9c2 Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Mon, 11 Mar 2024 10:27:47 +0000 Subject: [PATCH 19/77] [llvm-core] fix cci resource limitations --- recipes/llvm-core/all/conanfile.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 8949afd7685c5..fde23dad8a728 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -109,9 +109,6 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - if os.getenv("CONAN_CENTER_BUILD_SERVICE"): - self.options.ram_per_compile_job = "2048" - self.options.ram_per_link_job = "16384" def layout(self): cmake_layout(self, src_folder="src") @@ -152,6 +149,18 @@ def validate(self): def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) + def _apply_resource_limits(self, cmake_definitions): + if os.getenv("CONAN_CENTER_BUILD_SERVICE"): + cmake_definitions.update({ + "LLVM_RAM_PER_LINK_JOB": "16384", + "LLVM_RAM_PER_COMPILE_JOB": "2048" + }) + else: + if self.options.ram_per_compile_job != "auto": + cmake_definitions["LLVM_RAM_PER_COMPILE_JOB"] = self.options.ram_per_compile_job + if self.options.ram_per_link_job != "auto": + cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = self.options.ram_per_link_job + def generate(self): tc = CMakeToolchain(self, generator="Ninja") # https://releases.llvm.org/12.0.0/docs/CMake.html @@ -182,10 +191,8 @@ def generate(self): "LLVM_ENABLE_LIBXML2": "FORCE_ON" if self.options.with_xml2 else False, "LLVM_ENABLE_TERMINFO": self.options.with_terminfo, } - if self.options.ram_per_compile_job != "auto": - cmake_definitions["LLVM_RAM_PER_COMPILE_JOB"] = self.options.ram_per_compile_job - if self.options.ram_per_link_job != "auto": - cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = self.options.ram_per_link_job + + self._apply_resource_limits(cmake_definitions) # this capability is back-ported from LLVM 14.x is_platform_ELF_based = self.settings.os in [ From 2bd013fd009ada08b4c84f9c4f9ddabccfcf3ade Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Mon, 11 Mar 2024 11:10:19 +0000 Subject: [PATCH 20/77] [llvm-core] implement component dependencies --- recipes/llvm-core/all/conanfile.py | 104 ++++++++++++------ .../patches/18x/00-cmake-target-props.patch | 54 +++++++++ 2 files changed, 125 insertions(+), 33 deletions(-) create mode 100644 recipes/llvm-core/all/patches/18x/00-cmake-target-props.patch diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index fde23dad8a728..807016ba906a5 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -5,7 +5,7 @@ from conan.tools.build import check_min_cppstd, can_run, cross_building from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.env import VirtualRunEnv -from conan.tools.files import apply_conandata_patches, collect_libs, get, rmdir, save, copy, export_conandata_patches, load +from conan.tools.files import apply_conandata_patches, collect_libs, get, rmdir, save, copy, export_conandata_patches, load, replace_in_file from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -151,6 +151,7 @@ def source(self): def _apply_resource_limits(self, cmake_definitions): if os.getenv("CONAN_CENTER_BUILD_SERVICE"): + self.output.info("Applying CCI Resource Limits") cmake_definitions.update({ "LLVM_RAM_PER_LINK_JOB": "16384", "LLVM_RAM_PER_COMPILE_JOB": "2048" @@ -190,6 +191,7 @@ def generate(self): "LLVM_ENABLE_ZLIB": "FORCE_ON" if self.options.with_zlib else False, "LLVM_ENABLE_LIBXML2": "FORCE_ON" if self.options.with_xml2 else False, "LLVM_ENABLE_TERMINFO": self.options.with_terminfo, + "LLVM_ENABLE_ZSTD": "FORCE_ON" if self.options.get_safe("with_zstd") else False } self._apply_resource_limits(cmake_definitions) @@ -225,7 +227,7 @@ def generate(self): # "BUILD_SHARED_LIBS" builds shared versions of all of the static components # "LLVM_BUILD_LLVM_DYLIB" builds a single shared library containing all components. # It is likely the latter that the user expects by a "shared library" build. - "BUILD_SHARED_LIBS": False, + "BUILD_SHARED_LIBS": False }) tc.generate() @@ -249,6 +251,14 @@ def build(self): def _is_windows(self): return self.settings.os == "Windows" + def _lib_name_to_component(self, lib_name): + match_component_name = re.compile(r"""^LLVM(.+)$""") + match = match_component_name.match(lib_name) + if match: + return match.group(1).lower() + else: + return lib_name.lower() + def _llvm_components(self): cmake_config = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") @@ -259,14 +269,50 @@ def _llvm_components(self): return None components = match.groupdict()["components"] - - match_component = re.compile(r"""^LLVM(.+)$""") - for component in components.split(";"): - match = match_component.match(component) - if match: - yield match.group(1).lower(), component - else: - yield component.lower(), component + for lib_name in components.split(";"): + yield self._lib_name_to_component(lib_name), lib_name + + def _component_dependencies(self): + """ + Returns a dictionary indexed by the LLVM component name containing + the cmake target name (library name), + the component dependencies and system libs. Parsed from the CMake files + generated by the LLVM project + """ + def _parse_deps(deps_list): + match_genex = re.compile(r"""\\\$""") + data = { + "requires": [], + "system_libs": [] + } + ignore = ["libedit::libedit", "edit"] + for dep in deps_list.split(";"): + match = match_genex.search(dep) + if match: + component = match.group(1).lower() + else: + component = self._lib_name_to_component(dep) + + if component in ignore: + continue + + if component in ["rt", "m", "dl"]: + data["system_libs"].append(component) + else: + data["requires"].append(component) + return data + + cmake_exports = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMExports.cmake") + match_dependencies = re.compile( + r'''^set_target_properties\(LLVM(\w+).*\n{0,1}\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) + + components = { component: { "lib_name": lib_name } for component, lib_name in self._llvm_components() } + for llvm_lib, deps_list in match_dependencies.findall(cmake_exports): + component = llvm_lib.lower() + if component in components: + components[component].update(_parse_deps(deps_list)) + + return components @property def _components_data_file(self): @@ -279,15 +325,16 @@ def _build_module_file_rel_path(self): def _create_cmake_build_module(self, components, module_file): # FIXME: define other LLVM CMake Variables as per # https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project - json_text = json.dumps(components).replace('"', '\\"') + json_text = json.dumps(components, indent=2).replace('"', '\\"') content = textwrap.dedent(f"""\ set(LLVM_PACKAGE_VERSION "{self.version}") + set(LLVM_BUILD_TYPE "{self.settings.build_type}") function(llvm_map_components_to_libnames OUTPUT) set(_libnames ) set(_components_json "{json_text}") foreach(_component ${{ARGN}}) - string(JSON _lib_name ERROR_VARIABLE ERR GET ${{_components_json}} ${{_component}}) + string(JSON _lib_name ERROR_VARIABLE ERR GET ${{_components_json}} ${{_component}} "lib_name") if (ERR) message(WARNING "Component ${{_component}} not found: ${{ERR}}") endif() @@ -299,13 +346,11 @@ def _create_cmake_build_module(self, components, module_file): save(self, module_file, content) def _write_components(self): - component_dict = { - component: lib_name for component, lib_name in self._llvm_components() - } + components = self._component_dependencies() with open(self._components_data_file, "w", encoding="utf-8") as fp: - json.dump(component_dict, fp) + json.dump(components, fp, indent=2) - return component_dict + return components def _read_components(self) -> dict: with open(self._components_data_file, encoding="utf-8") as fp: @@ -339,26 +384,19 @@ def package_info(self): self.cpp_info.set_property("cmake_build_modules", [self._build_module_file_rel_path]) self.cpp_info.builddirs.append(os.path.dirname(self._build_module_file_rel_path)) - dependencies = [] - if self.options.with_zlib: - dependencies.append("zlib::zlib") - if self.options.with_xml2: - dependencies.append("libxml2::libxml2") - if self.options.with_ffi: - dependencies.append("libffi::libffi") - if self.options.with_z3: - dependencies.append("z3::z3") - if not self.options.shared: components = self._read_components() - for component_name, lib_name in components.items(): - self.cpp_info.components[component_name].set_property("cmake_target_name", lib_name) - self.cpp_info.components[component_name].libs = [lib_name] - self.cpp_info.components[component_name].requires = dependencies + for component_name, data in components.items(): + self.cpp_info.components[component_name].set_property("cmake_target_name", data["lib_name"]) + self.cpp_info.components[component_name].libs = [data["lib_name"]] + requires = data.get("requires") + if requires is not None: + self.cpp_info.components[component_name].requires += requires + system_libs = data.get("system_libs") + if system_libs is not None: + self.cpp_info.components[component_name].system_libs += system_libs - if component_name in ["lto", "remarks"] and self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components[component_name].system_libs.append("rt") else: self.cpp_info.set_property("cmake_target_name", "LLVM") self.cpp_info.libs = collect_libs(self) diff --git a/recipes/llvm-core/all/patches/18x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/18x/00-cmake-target-props.patch new file mode 100644 index 0000000000000..7b01add7c5caf --- /dev/null +++ b/recipes/llvm-core/all/patches/18x/00-cmake-target-props.patch @@ -0,0 +1,54 @@ +diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt +index e19223fdef4..f2590479c84 100644 +--- a/lib/Support/CMakeLists.txt ++++ b/lib/Support/CMakeLists.txt +@@ -297,27 +297,13 @@ set(llvm_system_libs ${system_libs}) + # This block is only needed for llvm-config. When we deprecate llvm-config and + # move to using CMake export, this block can be removed. + if(LLVM_ENABLE_ZLIB) +- # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. +- if(CMAKE_BUILD_TYPE) +- string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type}) +- endif() +- if(NOT zlib_library) +- get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION) +- endif() ++ set(zlib_library ${ZLIB_LIBRARIES}) + get_library_name(${zlib_library} zlib_library) + set(llvm_system_libs ${llvm_system_libs} "${zlib_library}") + endif() + + if(LLVM_ENABLE_ZSTD) +- # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. +- if(CMAKE_BUILD_TYPE) +- string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION_${build_type}) +- endif() +- if(NOT zstd_library) +- get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION) +- endif() ++ set(zstd_library ${zstd_LIBRARIES}) + get_library_name(${zstd_library} zstd_library) + set(llvm_system_libs ${llvm_system_libs} "${zstd_library}") + endif() +diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt +index 910132a4c7d..f4d91c9d56d 100644 +--- a/lib/WindowsManifest/CMakeLists.txt ++++ b/lib/WindowsManifest/CMakeLists.txt +@@ -21,14 +21,7 @@ add_llvm_component_library(LLVMWindowsManifest + # This block is only needed for llvm-config. When we deprecate llvm-config and + # move to using CMake export, this block can be removed. + 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}) +- endif() +- if(NOT libxml2_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) +- endif() ++ set(libxml2_library ${libxml2_LIBRARIES}) + get_library_name(${libxml2_library} libxml2_library) + set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) + endif() From 42efcc72d03467624ba29e32d024829f46315772 Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Tue, 12 Mar 2024 16:01:28 +0000 Subject: [PATCH 21/77] [llvm-core] sanitize component names --- recipes/llvm-core/all/conanfile.py | 71 +++++++++++-------- .../llvm-core/all/test_package/CMakeLists.txt | 3 + 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 807016ba906a5..97bb3e8c58ce5 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -5,7 +5,17 @@ from conan.tools.build import check_min_cppstd, can_run, cross_building from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.env import VirtualRunEnv -from conan.tools.files import apply_conandata_patches, collect_libs, get, rmdir, save, copy, export_conandata_patches, load, replace_in_file +from conan.tools.files import ( + apply_conandata_patches, + collect_libs, + get, + rmdir, + save, + copy, + export_conandata_patches, + load, + rm +) from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -279,24 +289,27 @@ def _component_dependencies(self): the component dependencies and system libs. Parsed from the CMake files generated by the LLVM project """ - def _parse_deps(deps_list): + def _sanitized_components(deps_list): match_genex = re.compile(r"""\\\$""") - data = { - "requires": [], - "system_libs": [] - } - ignore = ["libedit::libedit", "edit"] for dep in deps_list.split(";"): match = match_genex.search(dep) if match: - component = match.group(1).lower() + yield match.group(1).lower() + elif dep.startswith("-l"): + yield dep[2:] else: - component = self._lib_name_to_component(dep) + yield self._lib_name_to_component(dep) + def _parse_deps(deps_list): + ignore = ["libedit::libedit", "edit"] + data = { + "requires": [], + "system_libs": [] + } + for component in _sanitized_components(deps_list): if component in ignore: continue - - if component in ["rt", "m", "dl"]: + if component in ["rt", "m", "dl", "pthread"]: data["system_libs"].append(component) else: data["requires"].append(component) @@ -318,30 +331,23 @@ def _parse_deps(deps_list): def _components_data_file(self): return Path(self.package_folder) / "lib" / "components.json" + @property + def _cmake_module_path(self): + return Path("lib") / "cmake" / "llvm" + @property def _build_module_file_rel_path(self): - return Path("lib") / "cmake" / "llvm" / f"conan-official-{self.name}-variables.cmake" + return self._cmake_module_path / f"conan-official-{self.name}-variables.cmake" def _create_cmake_build_module(self, components, module_file): - # FIXME: define other LLVM CMake Variables as per - # https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project - json_text = json.dumps(components, indent=2).replace('"', '\\"') + package_folder = Path(self.package_folder) content = textwrap.dedent(f"""\ set(LLVM_PACKAGE_VERSION "{self.version}") + set(LLVM_AVAILABLE_LIBS "{';'.join(component['lib_name'] for component in components.values())}") set(LLVM_BUILD_TYPE "{self.settings.build_type}") - - function(llvm_map_components_to_libnames OUTPUT) - set(_libnames ) - set(_components_json "{json_text}") - foreach(_component ${{ARGN}}) - string(JSON _lib_name ERROR_VARIABLE ERR GET ${{_components_json}} ${{_component}} "lib_name") - if (ERR) - message(WARNING "Component ${{_component}} not found: ${{ERR}}") - endif() - list(APPEND _libnames ${{_lib_name}}) - endforeach() - set(${{OUTPUT}} ${{_libnames}} PARENT_SCOPE) - endfunction() + set(LLVM_CMAKE_DIR "{str(package_folder / "lib" / "cmake" / "llvm")}") + set(LLVM_TOOLS_BINARY_DIR "{str(package_folder / "bin")}") + set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On) """) save(self, module_file, content) @@ -366,7 +372,9 @@ def package(self): components = self._write_components() package_folder = Path(self.package_folder) - rmdir(self, package_folder / "lib" / "cmake") + cmake_folder = package_folder / "lib" / "cmake" / "llvm" + rm(self, "LLVMConfig*", cmake_folder) + rm(self, "LLVMExports*", cmake_folder) rmdir(self, package_folder / "share") self._create_cmake_build_module( @@ -381,8 +389,9 @@ def package_id(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "LLVM") - self.cpp_info.set_property("cmake_build_modules", [self._build_module_file_rel_path]) - self.cpp_info.builddirs.append(os.path.dirname(self._build_module_file_rel_path)) + self.cpp_info.set_property("cmake_build_modules", + [self._build_module_file_rel_path, self._cmake_module_path / "LLVM-Config.cmake"]) + self.cpp_info.builddirs.append(self._cmake_module_path) if not self.options.shared: components = self._read_components() diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index c821fb71ce1e5..f1dd46012df31 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -21,3 +21,6 @@ endif() message(STATUS "Testing LLVM Build Module Variables") test_llvm_cmake_variable(LLVM_PACKAGE_VERSION) +test_llvm_cmake_variable(LLVM_BUILD_TYPE) +test_llvm_cmake_variable(LLVM_CMAKE_DIR) +test_llvm_cmake_variable(LLVM_TOOLS_BINARY_DIR) From c3475d101c23c9fff6432569f12c9e1848bd470d Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Wed, 13 Mar 2024 08:48:35 +0000 Subject: [PATCH 22/77] [llvm-core] bump ram per link job for cci shared debug --- recipes/llvm-core/all/conanfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 97bb3e8c58ce5..4c0a21981e5f2 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -162,8 +162,12 @@ def source(self): def _apply_resource_limits(self, cmake_definitions): if os.getenv("CONAN_CENTER_BUILD_SERVICE"): self.output.info("Applying CCI Resource Limits") + if self.options.shared and self.settings.build_type == "Debug": + ram_per_link_job = "32768" + else: + ram_per_link_job = "16384" cmake_definitions.update({ - "LLVM_RAM_PER_LINK_JOB": "16384", + "LLVM_RAM_PER_LINK_JOB": ram_per_link_job, "LLVM_RAM_PER_COMPILE_JOB": "2048" }) else: From e20d4816b74b8ffc0f0ddea91306df545fd50bd3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 10:36:34 +0000 Subject: [PATCH 23/77] [llvm-core] exclude cmake find modules --- recipes/llvm-core/all/conanfile.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 4c0a21981e5f2..351f2a446472f 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -14,7 +14,7 @@ copy, export_conandata_patches, load, - rm + rm, rename ) from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -379,6 +379,10 @@ def package(self): cmake_folder = package_folder / "lib" / "cmake" / "llvm" rm(self, "LLVMConfig*", cmake_folder) rm(self, "LLVMExports*", cmake_folder) + rm(self, "Find*", cmake_folder) + # need to rename this as Conan will flag it, but it's not actually a Config file and is needed by + # downstream packages + rename(self, cmake_folder / "LLVM-Config.cmake", cmake_folder / "LLVM-ConfigInternal.cmake") rmdir(self, package_folder / "share") self._create_cmake_build_module( @@ -394,7 +398,9 @@ def package_id(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "LLVM") self.cpp_info.set_property("cmake_build_modules", - [self._build_module_file_rel_path, self._cmake_module_path / "LLVM-Config.cmake"]) + [self._build_module_file_rel_path, + self._cmake_module_path / "LLVM-ConfigInternal.cmake"] + ) self.cpp_info.builddirs.append(self._cmake_module_path) if not self.options.shared: From 3c7c219848c1949af56b5ba31fa34cbed0dd231c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 10:40:53 +0000 Subject: [PATCH 24/77] [llvm-core] skip rpath on macos --- recipes/llvm-core/all/conanfile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 351f2a446472f..579ea90aa2a16 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -2,6 +2,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os from conan.tools.build import check_min_cppstd, can_run, cross_building from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.env import VirtualRunEnv @@ -233,6 +234,10 @@ def generate(self): else: cmake_definitions["LLVM_USE_SANITIZER"] = self.options.use_sanitizer + if is_apple_os(self): + # otherwise we can't find shared dependencies during the build + cmake_definitions["CMAKE_SKIP_RPATH"] = True + tc.variables.update(cmake_definitions) tc.cache_variables.update({ # Enables LLVM to find conan libraries during try_compile From e8474300b668e8d3d5b2c1e68a09dcd3a5eb63a2 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 15:27:38 +0000 Subject: [PATCH 25/77] [llvm-core] reformat and fix linting issues --- recipes/llvm-core/all/conandata.yml | 15 ++++++++------ recipes/llvm-core/all/conanfile.py | 31 ++++++++++++++++------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 5f021700d6e25..bcc8788fed052 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -17,13 +17,14 @@ patches: - patch_file: patches/13x/01-calculate-job-pools.patch patch_description: calculate resource limits for compiling LLVM patch_type: portability - patch_source: https://github.com/conan-io/conan-center-index/pull/17509 + patch_source: https://github.com/llvm/llvm-project/pull/65274 - patch_file: patches/13x/02-missing-includes.patch patch_description: fix missing header files patch_type: portability - patch_file: patches/13x/03-split-dwarf.patch patch_description: enable split dwarf option from 14.x - patch_type: backport + patch_source: https://reviews.llvm.org/D108776 + patch_type: bugfix "12.0.0": - patch_file: patches/12x/00-cmake-target-props.patch patch_description: fix references to third party libs to match conan variables and targets @@ -31,13 +32,14 @@ patches: - patch_file: patches/12x/01-calculate-job-pools.patch patch_description: calculate resource limits for compiling LLVM patch_type: portability - patch_source: https://github.com/conan-io/conan-center-index/pull/17509 + patch_source: https://github.com/llvm/llvm-project/pull/65274 - patch_file: patches/12x/02-missing-includes.patch patch_description: fix missing header files patch_type: portability - patch_file: patches/12x/03-split-dwarf.patch patch_description: enable split dwarf option from 14.x - patch_type: backport + patch_source: https://reviews.llvm.org/D108776 + patch_type: bugfix "11.1.0": - patch_file: patches/11x/00-cmake-find-package-zlib.patch patch_description: find zlib using conan rather than assuming a system library @@ -45,10 +47,11 @@ patches: - patch_file: "patches/11x/01-calculate-job-pools.patch" patch_description: calculate resource limits for compiling LLVM patch_type: portability - patch_source: https://github.com/conan-io/conan-center-index/pull/17509 + patch_source: https://github.com/llvm/llvm-project/pull/65274 - patch_file: patches/11x/02-missing-includes.patch patch_description: fix missing header files patch_type: portability - patch_file: patches/11x/03-split-dwarf.patch patch_description: enable split dwarf option from 14.x - patch_type: backport + patch_source: https://reviews.llvm.org/D108776 + patch_type: bugfix diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 579ea90aa2a16..9c3d2ceb7b3ba 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -15,7 +15,8 @@ copy, export_conandata_patches, load, - rm, rename + rm, + rename ) from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -87,11 +88,11 @@ class LLVMCoreConan(ConanFile): "use_perf": False, "use_sanitizer": "None", "with_ffi": False, - "with_terminfo": False, # differs from LLVM default + "with_terminfo": False, # differs from LLVM default "with_xml2": True, "with_z3": True, "with_zlib": True, - "use_llvm_cmake_files": False, # no longer used but retained for backwards compatibility + "use_llvm_cmake_files": False, # no longer used but retained for backwards compatibility "ram_per_compile_job": "auto", "ram_per_link_job": "auto" } @@ -216,12 +217,12 @@ def generate(self): "Linux", "Android", "FreeBSD", "SunOS", "AIX", "Neutrino", "VxWorks" ] if is_platform_ELF_based: - self.output.info(f"ELF Platform Detected, optimizing memory usage during debug build linking.") + self.output.info("ELF Platform Detected, optimizing memory usage during debug build linking.") cmake_definitions["LLVM_USE_SPLIT_DWARF"] = True if is_msvc(self): build_type = str(self.settings.build_type).upper() - cmake_definitions["LLVM_USE_CRT_{}".format(build_type)] = self.settings.compiler.runtime + cmake_definitions[f"LLVM_USE_CRT_{build_type}"] = self.settings.compiler.runtime if not self.options.shared: cmake_definitions.update({ @@ -243,7 +244,7 @@ def generate(self): # Enables LLVM to find conan libraries during try_compile "CMAKE_TRY_COMPILE_CONFIGURATION": str(self.settings.build_type), # LLVM has two separate concepts of a "shared library build". - # "BUILD_SHARED_LIBS" builds shared versions of all of the static components + # "BUILD_SHARED_LIBS" builds shared versions of all the static components # "LLVM_BUILD_LLVM_DYLIB" builds a single shared library containing all components. # It is likely the latter that the user expects by a "shared library" build. "BUILD_SHARED_LIBS": False @@ -270,7 +271,8 @@ def build(self): def _is_windows(self): return self.settings.os == "Windows" - def _lib_name_to_component(self, lib_name): + @staticmethod + def _lib_name_to_component(lib_name): match_component_name = re.compile(r"""^LLVM(.+)$""") match = match_component_name.match(lib_name) if match: @@ -298,6 +300,7 @@ def _component_dependencies(self): the component dependencies and system libs. Parsed from the CMake files generated by the LLVM project """ + def _sanitized_components(deps_list): match_genex = re.compile(r"""\\\$""") for dep in deps_list.split(";"): @@ -326,13 +329,13 @@ def _parse_deps(deps_list): cmake_exports = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMExports.cmake") match_dependencies = re.compile( - r'''^set_target_properties\(LLVM(\w+).*\n{0,1}\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) + r'''^set_target_properties\(LLVM(\w+).*\n?\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) - components = { component: { "lib_name": lib_name } for component, lib_name in self._llvm_components() } - for llvm_lib, deps_list in match_dependencies.findall(cmake_exports): + components = {component: {"lib_name": lib_name} for component, lib_name in self._llvm_components()} + for llvm_lib, dependencies in match_dependencies.findall(cmake_exports): component = llvm_lib.lower() if component in components: - components[component].update(_parse_deps(deps_list)) + components[component].update(_parse_deps(dependencies)) return components @@ -403,9 +406,9 @@ def package_id(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "LLVM") self.cpp_info.set_property("cmake_build_modules", - [self._build_module_file_rel_path, - self._cmake_module_path / "LLVM-ConfigInternal.cmake"] - ) + [self._build_module_file_rel_path, + self._cmake_module_path / "LLVM-ConfigInternal.cmake"] + ) self.cpp_info.builddirs.append(self._cmake_module_path) if not self.options.shared: From cf693ed1406ef1d51161b468e3076c33721a0287 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 15:47:28 +0000 Subject: [PATCH 26/77] [llvm-core] delete 18x patch (added in error) --- .../patches/18x/00-cmake-target-props.patch | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 recipes/llvm-core/all/patches/18x/00-cmake-target-props.patch diff --git a/recipes/llvm-core/all/patches/18x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/18x/00-cmake-target-props.patch deleted file mode 100644 index 7b01add7c5caf..0000000000000 --- a/recipes/llvm-core/all/patches/18x/00-cmake-target-props.patch +++ /dev/null @@ -1,54 +0,0 @@ -diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt -index e19223fdef4..f2590479c84 100644 ---- a/lib/Support/CMakeLists.txt -+++ b/lib/Support/CMakeLists.txt -@@ -297,27 +297,13 @@ set(llvm_system_libs ${system_libs}) - # This block is only needed for llvm-config. When we deprecate llvm-config and - # move to using CMake export, this block can be removed. - if(LLVM_ENABLE_ZLIB) -- # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. -- if(CMAKE_BUILD_TYPE) -- string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) -- get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type}) -- endif() -- if(NOT zlib_library) -- get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION) -- endif() -+ set(zlib_library ${ZLIB_LIBRARIES}) - get_library_name(${zlib_library} zlib_library) - set(llvm_system_libs ${llvm_system_libs} "${zlib_library}") - endif() - - if(LLVM_ENABLE_ZSTD) -- # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. -- if(CMAKE_BUILD_TYPE) -- string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) -- get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION_${build_type}) -- endif() -- if(NOT zstd_library) -- get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION) -- endif() -+ set(zstd_library ${zstd_LIBRARIES}) - get_library_name(${zstd_library} zstd_library) - set(llvm_system_libs ${llvm_system_libs} "${zstd_library}") - endif() -diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt -index 910132a4c7d..f4d91c9d56d 100644 ---- a/lib/WindowsManifest/CMakeLists.txt -+++ b/lib/WindowsManifest/CMakeLists.txt -@@ -21,14 +21,7 @@ add_llvm_component_library(LLVMWindowsManifest - # This block is only needed for llvm-config. When we deprecate llvm-config and - # move to using CMake export, this block can be removed. - 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}) -- endif() -- if(NOT libxml2_library) -- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) -- endif() -+ set(libxml2_library ${libxml2_LIBRARIES}) - get_library_name(${libxml2_library} libxml2_library) - set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) - endif() From cb232af41728b0c02ddddee7507b12edd60b4336 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 15:52:16 +0000 Subject: [PATCH 27/77] [llvm-core] rename references to LLVM-Config --- recipes/llvm-core/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 9c3d2ceb7b3ba..e348fcf75b95a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -16,7 +16,7 @@ export_conandata_patches, load, rm, - rename + rename, replace_in_file ) from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -391,6 +391,7 @@ def package(self): # need to rename this as Conan will flag it, but it's not actually a Config file and is needed by # downstream packages rename(self, cmake_folder / "LLVM-Config.cmake", cmake_folder / "LLVM-ConfigInternal.cmake") + replace_in_file(self, cmake_folder / "AddLLVM.cmake", "LLVM-Config", "LLVM-ConfigInternal") rmdir(self, package_folder / "share") self._create_cmake_build_module( From e1c78fb64bd23ee66e44f61fa5c7dcf96a554a2d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 16:10:36 +0000 Subject: [PATCH 28/77] [llvm-core] retain LLVMConfigExtensions.cmake --- recipes/llvm-core/all/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index e348fcf75b95a..8a1d130eb0514 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -16,7 +16,8 @@ export_conandata_patches, load, rm, - rename, replace_in_file + rename, + replace_in_file ) from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -385,7 +386,7 @@ def package(self): package_folder = Path(self.package_folder) cmake_folder = package_folder / "lib" / "cmake" / "llvm" - rm(self, "LLVMConfig*", cmake_folder) + rm(self, "LLVMConfig.cmake", cmake_folder) rm(self, "LLVMExports*", cmake_folder) rm(self, "Find*", cmake_folder) # need to rename this as Conan will flag it, but it's not actually a Config file and is needed by From 735e7fe275c43b3683322d9c57dc2216d695bbb3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 16:59:12 +0000 Subject: [PATCH 29/77] [llvm-core] add fake targets for *-gen --- recipes/llvm-core/all/conanfile.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 8a1d130eb0514..3e7bee5c2308a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -361,6 +361,15 @@ def _create_cmake_build_module(self, components, module_file): set(LLVM_CMAKE_DIR "{str(package_folder / "lib" / "cmake" / "llvm")}") set(LLVM_TOOLS_BINARY_DIR "{str(package_folder / "bin")}") set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On) + if (NOT TARGET intrinsics_gen) + add_custom_target(intrinsics_gen) + endif() + if (NOT TARGET omp_gen) + add_custom_target(omp_gen) + endif() + if (NOT TARGET acc_gen) + add_custom_target(acc_gen) + endif() """) save(self, module_file, content) From 4f7afc5dd1fb9d433862d248e94ccaeedcb258f1 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 17:58:03 +0000 Subject: [PATCH 30/77] [llvm-core] use the actual cmake target name as component name --- recipes/llvm-core/all/conanfile.py | 40 +++++++++++------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 3e7bee5c2308a..a059fa0c5846a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -272,15 +272,6 @@ def build(self): def _is_windows(self): return self.settings.os == "Windows" - @staticmethod - def _lib_name_to_component(lib_name): - match_component_name = re.compile(r"""^LLVM(.+)$""") - match = match_component_name.match(lib_name) - if match: - return match.group(1).lower() - else: - return lib_name.lower() - def _llvm_components(self): cmake_config = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") @@ -291,27 +282,25 @@ def _llvm_components(self): return None components = match.groupdict()["components"] - for lib_name in components.split(";"): - yield self._lib_name_to_component(lib_name), lib_name + for component in components.split(";"): + yield component def _component_dependencies(self): """ - Returns a dictionary indexed by the LLVM component name containing - the cmake target name (library name), + Returns a dictionary indexed by the LLVM component name (target) containing the component dependencies and system libs. Parsed from the CMake files generated by the LLVM project """ - def _sanitized_components(deps_list): - match_genex = re.compile(r"""\\\$""") + match_genex = re.compile(r"""\\\$""") for dep in deps_list.split(";"): match = match_genex.search(dep) if match: - yield match.group(1).lower() + yield match.group(1) elif dep.startswith("-l"): yield dep[2:] else: - yield self._lib_name_to_component(dep) + yield dep def _parse_deps(deps_list): ignore = ["libedit::libedit", "edit"] @@ -332,11 +321,10 @@ def _parse_deps(deps_list): match_dependencies = re.compile( r'''^set_target_properties\(LLVM(\w+).*\n?\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) - components = {component: {"lib_name": lib_name} for component, lib_name in self._llvm_components()} + components = {component: {} for component in self._llvm_components()} for llvm_lib, dependencies in match_dependencies.findall(cmake_exports): - component = llvm_lib.lower() - if component in components: - components[component].update(_parse_deps(dependencies)) + if llvm_lib in components: + components[llvm_lib].update(_parse_deps(dependencies)) return components @@ -352,11 +340,11 @@ def _cmake_module_path(self): def _build_module_file_rel_path(self): return self._cmake_module_path / f"conan-official-{self.name}-variables.cmake" - def _create_cmake_build_module(self, components, module_file): + def _create_cmake_build_module(self, component_names, module_file): package_folder = Path(self.package_folder) content = textwrap.dedent(f"""\ set(LLVM_PACKAGE_VERSION "{self.version}") - set(LLVM_AVAILABLE_LIBS "{';'.join(component['lib_name'] for component in components.values())}") + set(LLVM_AVAILABLE_LIBS "{';'.join(component_names)}") set(LLVM_BUILD_TYPE "{self.settings.build_type}") set(LLVM_CMAKE_DIR "{str(package_folder / "lib" / "cmake" / "llvm")}") set(LLVM_TOOLS_BINARY_DIR "{str(package_folder / "bin")}") @@ -405,7 +393,7 @@ def package(self): rmdir(self, package_folder / "share") self._create_cmake_build_module( - components, + components.keys(), package_folder / self._build_module_file_rel_path ) @@ -426,8 +414,8 @@ def package_info(self): components = self._read_components() for component_name, data in components.items(): - self.cpp_info.components[component_name].set_property("cmake_target_name", data["lib_name"]) - self.cpp_info.components[component_name].libs = [data["lib_name"]] + self.cpp_info.components[component_name].set_property("cmake_target_name", component_name) + self.cpp_info.components[component_name].libs = [component_name] requires = data.get("requires") if requires is not None: self.cpp_info.components[component_name].requires += requires From d71e0bc3111ee6ab58cb28d54cadc5e88426acd8 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 17:29:07 +0000 Subject: [PATCH 31/77] [llvm-core] fix component dependencies --- recipes/llvm-core/all/conanfile.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index a059fa0c5846a..e4dc6d2c45754 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -259,11 +259,8 @@ def generate(self): # For running llvm-tblgen during the build VirtualRunEnv(self).generate(scope="build") - def _patch_sources(self): - apply_conandata_patches(self) - def build(self): - self._patch_sources() + apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() @@ -293,14 +290,22 @@ def _component_dependencies(self): """ def _sanitized_components(deps_list): match_genex = re.compile(r"""\\\$""") + replacements = { + "LibXml2::LibXml2": "libxml2::libxml2", + "ZLIB::ZLIB": "zlib::zlib" + } for dep in deps_list.split(";"): match = match_genex.search(dep) if match: yield match.group(1) - elif dep.startswith("-l"): - yield dep[2:] else: - yield dep + replacement = replacements.get(dep) + if replacement: + yield replacement + elif dep.startswith("-l"): + yield dep[2:] + else: + yield dep def _parse_deps(deps_list): ignore = ["libedit::libedit", "edit"] @@ -309,7 +314,7 @@ def _parse_deps(deps_list): "system_libs": [] } for component in _sanitized_components(deps_list): - if component in ignore: + if component.lower() in ignore: continue if component in ["rt", "m", "dl", "pthread"]: data["system_libs"].append(component) @@ -319,7 +324,7 @@ def _parse_deps(deps_list): cmake_exports = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMExports.cmake") match_dependencies = re.compile( - r'''^set_target_properties\(LLVM(\w+).*\n?\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) + r'''^set_target_properties\((\w+).*\n?\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) components = {component: {} for component in self._llvm_components()} for llvm_lib, dependencies in match_dependencies.findall(cmake_exports): From b09a60ebd1091f04854c65962406e761eca95029 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 19:53:17 +0000 Subject: [PATCH 32/77] [llvm-core] add target options --- recipes/llvm-core/all/conanfile.py | 35 ++++++++++++++----- .../llvm-core/all/test_package/CMakeLists.txt | 2 ++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index e4dc6d2c45754..bb1b25b3df53a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -29,6 +29,8 @@ required_conan_version = ">=1.62.0" +LLVM_TARGETS = "AArch64;AMDGPU;ARM;AVR;BPF;Hexagon;Lanai;LoongArch;Mips;MSP430;NVPTX;PowerPC;RISCV;Sparc;SystemZ;VE;WebAssembly;X86;XCore" + class LLVMCoreConan(ConanFile): name = "llvm-core" @@ -46,7 +48,6 @@ class LLVMCoreConan(ConanFile): "shared": [True, False], "fPIC": [True, False], "components": ["ANY"], - "targets": ["ANY"], "exceptions": [True, False], "rtti": [True, False], "threads": [True, False], @@ -70,15 +71,14 @@ class LLVMCoreConan(ConanFile): "with_zlib": [True, False], "with_xml2": [True, False], "with_z3": [True, False], - "use_llvm_cmake_files": [True, False], "ram_per_compile_job": ["ANY"], "ram_per_link_job": ["ANY"], } + options.update({f"with_target_{target.lower()}": [True, False] for target in LLVM_TARGETS.split(";")}) default_options = { "shared": False, "fPIC": True, "components": "all", - "targets": "all", "exceptions": True, "rtti": True, "threads": True, @@ -93,10 +93,10 @@ class LLVMCoreConan(ConanFile): "with_xml2": True, "with_z3": True, "with_zlib": True, - "use_llvm_cmake_files": False, # no longer used but retained for backwards compatibility "ram_per_compile_job": "auto", "ram_per_link_job": "auto" } + default_options.update({f"with_target_{target.lower()}": True for target in LLVM_TARGETS.split(";")}) @property def _min_cppstd(self): @@ -115,9 +115,16 @@ def _compilers_minimum_version(self): def export_sources(self): export_conandata_patches(self) + @property + def _major_version(self): + return Version(self.version).major + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self._major_version < 14: + del self.options.with_target_loongarch # experimental + del self.options.with_target_ve # experimental def configure(self): if self.options.shared: @@ -179,12 +186,23 @@ def _apply_resource_limits(self, cmake_definitions): if self.options.ram_per_link_job != "auto": cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = self.options.ram_per_link_job + @property + def _targets_to_build(self): + return ";".join(target for target in LLVM_TARGETS.split(";") if self.options.get_safe(f"with_target_{target.lower()}")) + + @property + def _all_targets(self): + # This is not just LLVM_TARGETS as it is version specific + return ";".join( + target for target in LLVM_TARGETS.split(";") if + self.options.get_safe(f"with_target_{target.lower()}") is not None) + def generate(self): tc = CMakeToolchain(self, generator="Ninja") # https://releases.llvm.org/12.0.0/docs/CMake.html # https://releases.llvm.org/13.0.0/docs/CMake.html cmake_definitions = { - "LLVM_TARGETS_TO_BUILD": self.options.targets, + "LLVM_TARGETS_TO_BUILD": self._targets_to_build, # See comment below on LLVM shared library builds "LLVM_BUILD_LLVM_DYLIB": self.options.shared, "LLVM_LINK_LLVM_DYLIB": self.options.shared, @@ -207,8 +225,7 @@ def generate(self): "LLVM_ENABLE_FFI": self.options.with_ffi, "LLVM_ENABLE_ZLIB": "FORCE_ON" if self.options.with_zlib else False, "LLVM_ENABLE_LIBXML2": "FORCE_ON" if self.options.with_xml2 else False, - "LLVM_ENABLE_TERMINFO": self.options.with_terminfo, - "LLVM_ENABLE_ZSTD": "FORCE_ON" if self.options.get_safe("with_zstd") else False + "LLVM_ENABLE_TERMINFO": self.options.with_terminfo } self._apply_resource_limits(cmake_definitions) @@ -288,6 +305,7 @@ def _component_dependencies(self): the component dependencies and system libs. Parsed from the CMake files generated by the LLVM project """ + def _sanitized_components(deps_list): match_genex = re.compile(r"""\\\$""") replacements = { @@ -353,6 +371,8 @@ def _create_cmake_build_module(self, component_names, module_file): set(LLVM_BUILD_TYPE "{self.settings.build_type}") set(LLVM_CMAKE_DIR "{str(package_folder / "lib" / "cmake" / "llvm")}") set(LLVM_TOOLS_BINARY_DIR "{str(package_folder / "bin")}") + set(LLVM_ALL_TARGETS "{self._all_targets}") + set(LLVM_TARGETS_TO_BUILD "{self._targets_to_build}") set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On) if (NOT TARGET intrinsics_gen) add_custom_target(intrinsics_gen) @@ -403,7 +423,6 @@ def package(self): ) def package_id(self): - del self.info.options.use_llvm_cmake_files del self.info.options.ram_per_compile_job del self.info.options.ram_per_link_job diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index f1dd46012df31..2b7d245b17e51 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -24,3 +24,5 @@ test_llvm_cmake_variable(LLVM_PACKAGE_VERSION) test_llvm_cmake_variable(LLVM_BUILD_TYPE) test_llvm_cmake_variable(LLVM_CMAKE_DIR) test_llvm_cmake_variable(LLVM_TOOLS_BINARY_DIR) +test_llvm_cmake_variable(LLVM_ALL_TARGETS) +test_llvm_cmake_variable(LLVM_TARGETS_TO_BUILD) From 53efb4a6bfcfa56ce4dcae68765e1f3e4886a7c9 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 13 Mar 2024 23:41:48 +0000 Subject: [PATCH 33/77] [llvm-core] add editline requirement (WIP) --- recipes/llvm-core/all/conandata.yml | 26 +++++------ recipes/llvm-core/all/conanfile.py | 8 ++-- ...ib.patch => 0000-cmake-dependencies.patch} | 43 +++++++++++++++++-- ...s.patch => 0001-calculate-job-pools.patch} | 0 ...udes.patch => 0002-missing-includes.patch} | 0 ...lit-dwarf.patch => 0003-split-dwarf.patch} | 0 ...ps.patch => 0000-cmake-dependencies.patch} | 42 +++++++++++++++++- ...s.patch => 0001-calculate-job-pools.patch} | 0 ...udes.patch => 0002-missing-includes.patch} | 0 ...lit-dwarf.patch => 0003-split-dwarf.patch} | 0 ...ps.patch => 0000-cmake-target-props.patch} | 0 ...s.patch => 0001-calculate-job-pools.patch} | 0 ...udes.patch => 0002-missing-includes.patch} | 0 ...lit-dwarf.patch => 0003-split-dwarf.patch} | 0 14 files changed, 97 insertions(+), 22 deletions(-) rename recipes/llvm-core/all/patches/11x/{00-cmake-find-package-zlib.patch => 0000-cmake-dependencies.patch} (57%) rename recipes/llvm-core/all/patches/11x/{01-calculate-job-pools.patch => 0001-calculate-job-pools.patch} (100%) rename recipes/llvm-core/all/patches/11x/{02-missing-includes.patch => 0002-missing-includes.patch} (100%) rename recipes/llvm-core/all/patches/11x/{03-split-dwarf.patch => 0003-split-dwarf.patch} (100%) rename recipes/llvm-core/all/patches/12x/{00-cmake-target-props.patch => 0000-cmake-dependencies.patch} (61%) rename recipes/llvm-core/all/patches/12x/{01-calculate-job-pools.patch => 0001-calculate-job-pools.patch} (100%) rename recipes/llvm-core/all/patches/12x/{02-missing-includes.patch => 0002-missing-includes.patch} (100%) rename recipes/llvm-core/all/patches/12x/{03-split-dwarf.patch => 0003-split-dwarf.patch} (100%) rename recipes/llvm-core/all/patches/13x/{00-cmake-target-props.patch => 0000-cmake-target-props.patch} (100%) rename recipes/llvm-core/all/patches/13x/{01-calculate-job-pools.patch => 0001-calculate-job-pools.patch} (100%) rename recipes/llvm-core/all/patches/13x/{02-missing-includes.patch => 0002-missing-includes.patch} (100%) rename recipes/llvm-core/all/patches/13x/{03-split-dwarf.patch => 0003-split-dwarf.patch} (100%) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index bcc8788fed052..1ed004e7e0099 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -11,47 +11,47 @@ sources: patches: "13.0.0": - - patch_file: patches/13x/00-cmake-target-props.patch + - patch_file: patches/13x/0000-cmake-target-props.patch patch_description: fix references to third party libs to match conan variables and targets patch_type: conan - - patch_file: patches/13x/01-calculate-job-pools.patch + - patch_file: patches/13x/0001-calculate-job-pools.patch patch_description: calculate resource limits for compiling LLVM patch_type: portability patch_source: https://github.com/llvm/llvm-project/pull/65274 - - patch_file: patches/13x/02-missing-includes.patch + - patch_file: patches/13x/0002-missing-includes.patch patch_description: fix missing header files patch_type: portability - - patch_file: patches/13x/03-split-dwarf.patch + - patch_file: patches/13x/0003-split-dwarf.patch patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 patch_type: bugfix "12.0.0": - - patch_file: patches/12x/00-cmake-target-props.patch + - patch_file: patches/12x/0000-cmake-dependencies.patch patch_description: fix references to third party libs to match conan variables and targets patch_type: conan - - patch_file: patches/12x/01-calculate-job-pools.patch + - patch_file: patches/12x/0001-calculate-job-pools.patch patch_description: calculate resource limits for compiling LLVM patch_type: portability patch_source: https://github.com/llvm/llvm-project/pull/65274 - - patch_file: patches/12x/02-missing-includes.patch + - patch_file: patches/12x/0002-missing-includes.patch patch_description: fix missing header files patch_type: portability - - patch_file: patches/12x/03-split-dwarf.patch + - patch_file: patches/12x/0003-split-dwarf.patch patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 patch_type: bugfix "11.1.0": - - patch_file: patches/11x/00-cmake-find-package-zlib.patch - patch_description: find zlib using conan rather than assuming a system library + - patch_file: patches/11x/0000-cmake-dependencies.patch + patch_description: fix references to third party libs to match conan variables and targets patch_type: conan - - patch_file: "patches/11x/01-calculate-job-pools.patch" + - patch_file: "patches/11x/0001-calculate-job-pools.patch" patch_description: calculate resource limits for compiling LLVM patch_type: portability patch_source: https://github.com/llvm/llvm-project/pull/65274 - - patch_file: patches/11x/02-missing-includes.patch + - patch_file: patches/11x/0002-missing-includes.patch patch_description: fix missing header files patch_type: portability - - patch_file: patches/11x/03-split-dwarf.patch + - patch_file: patches/11x/0003-split-dwarf.patch patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 patch_type: bugfix diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index bb1b25b3df53a..7048ce26bc02f 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -67,6 +67,7 @@ class LLVMCoreConan(ConanFile): "None" ], "with_ffi": [True, False], + "with_libedit": [True, False], "with_terminfo": [True, False], "with_zlib": [True, False], "with_xml2": [True, False], @@ -88,6 +89,7 @@ class LLVMCoreConan(ConanFile): "expensive_checks": False, "use_perf": False, "use_sanitizer": "None", + "with_libedit": True, "with_ffi": False, "with_terminfo": False, # differs from LLVM default "with_xml2": True, @@ -136,6 +138,8 @@ def layout(self): def requirements(self): if self.options.with_ffi: self.requires("libffi/3.4.4") + if self.options.with_libedit: + self.requires("editline/3.1") if self.options.with_zlib: self.requires("zlib/1.3.1") if self.options.with_xml2: @@ -221,6 +225,7 @@ def generate(self): "LLVM_ENABLE_EXPENSIVE_CHECKS": self.options.expensive_checks, "LLVM_ENABLE_ASSERTIONS": self.settings.build_type, "LLVM_USE_PERF": self.options.use_perf, + "LLVM_ENABLE_LIBEDIT": self.options.with_libedit, "LLVM_ENABLE_Z3_SOLVER": self.options.with_z3, "LLVM_ENABLE_FFI": self.options.with_ffi, "LLVM_ENABLE_ZLIB": "FORCE_ON" if self.options.with_zlib else False, @@ -326,14 +331,11 @@ def _sanitized_components(deps_list): yield dep def _parse_deps(deps_list): - ignore = ["libedit::libedit", "edit"] data = { "requires": [], "system_libs": [] } for component in _sanitized_components(deps_list): - if component.lower() in ignore: - continue if component in ["rt", "m", "dl", "pthread"]: data["system_libs"].append(component) else: diff --git a/recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch b/recipes/llvm-core/all/patches/11x/0000-cmake-dependencies.patch similarity index 57% rename from recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch rename to recipes/llvm-core/all/patches/11x/0000-cmake-dependencies.patch index 069d56e8aff6a..5ea442b9e4926 100644 --- a/recipes/llvm-core/all/patches/11x/00-cmake-find-package-zlib.patch +++ b/recipes/llvm-core/all/patches/11x/0000-cmake-dependencies.patch @@ -1,5 +1,5 @@ diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake -index 90e5d327c75..2bc924b79e7 100644 +index 90e5d327c75..618b19b6a2d 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -5,6 +5,7 @@ endif() @@ -10,7 +10,7 @@ index 90e5d327c75..2bc924b79e7 100644 include(CheckSymbolExists) include(CheckFunctionExists) include(CheckStructHasMember) -@@ -56,7 +57,15 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H) +@@ -56,13 +57,27 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(termios.h HAVE_TERMIOS_H) check_include_file(unistd.h HAVE_UNISTD_H) check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H) @@ -27,7 +27,20 @@ index 90e5d327c75..2bc924b79e7 100644 check_include_file(fenv.h HAVE_FENV_H) check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT) check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT) -@@ -118,17 +127,12 @@ endif() + + check_include_file(mach/mach.h HAVE_MACH_MACH_H) +-check_include_file(histedit.h HAVE_HISTEDIT_H) ++if(LLVM_ENABLE_LIBEDIT) ++ find_package(editline REQUIRED) ++ cmake_push_check_state() ++ list(APPEND CMAKE_REQUIRED_INCLUDES ${editline_INCLUDE_DIRS}) ++ check_include_file(histedit.h HAVE_HISTEDIT_H) ++ cmake_pop_check_state() ++endif() + check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H) + if(APPLE) + include(CheckCSourceCompiles) +@@ -118,24 +133,23 @@ endif() # Don't look for these libraries if we're using MSan, since uninstrumented third # party code may call MSan interceptors like strlen, leading to false positives. if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") @@ -50,7 +63,18 @@ index 90e5d327c75..2bc924b79e7 100644 endif() # Don't look for these libraries on Windows. -@@ -517,7 +521,7 @@ else( LLVM_ENABLE_THREADS ) + if (NOT PURE_WINDOWS) + # Skip libedit if using ASan as it contains memory leaks. + if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*") ++ cmake_push_check_state() ++ list(APPEND CMAKE_REQUIRED_INCLUDES ${editline_INCLUDE_DIRS}) ++ list(APPEND CMAKE_REQUIRED_LIBRARIES ${editline_LIBRARIES}) + check_library_exists(edit el_init "" HAVE_LIBEDIT) ++ cmake_pop_check_state() + else() + set(HAVE_LIBEDIT 0) + endif() +@@ -517,7 +531,7 @@ else( LLVM_ENABLE_THREADS ) message(STATUS "Threads disabled.") endif() @@ -59,3 +83,14 @@ index 90e5d327c75..2bc924b79e7 100644 # Check if zlib is available in the system. if ( NOT HAVE_ZLIB_H OR NOT HAVE_LIBZ ) set(LLVM_ENABLE_ZLIB 0) +diff --git a/lib/LineEditor/CMakeLists.txt b/lib/LineEditor/CMakeLists.txt +index 59190379406..3952bf0144f 100644 +--- a/lib/LineEditor/CMakeLists.txt ++++ b/lib/LineEditor/CMakeLists.txt +@@ -1,5 +1,5 @@ + if(HAVE_LIBEDIT) +- set(link_libs edit) ++ set(link_libs editline::editline) + endif() + + add_llvm_component_library(LLVMLineEditor diff --git a/recipes/llvm-core/all/patches/11x/01-calculate-job-pools.patch b/recipes/llvm-core/all/patches/11x/0001-calculate-job-pools.patch similarity index 100% rename from recipes/llvm-core/all/patches/11x/01-calculate-job-pools.patch rename to recipes/llvm-core/all/patches/11x/0001-calculate-job-pools.patch diff --git a/recipes/llvm-core/all/patches/11x/02-missing-includes.patch b/recipes/llvm-core/all/patches/11x/0002-missing-includes.patch similarity index 100% rename from recipes/llvm-core/all/patches/11x/02-missing-includes.patch rename to recipes/llvm-core/all/patches/11x/0002-missing-includes.patch diff --git a/recipes/llvm-core/all/patches/11x/03-split-dwarf.patch b/recipes/llvm-core/all/patches/11x/0003-split-dwarf.patch similarity index 100% rename from recipes/llvm-core/all/patches/11x/03-split-dwarf.patch rename to recipes/llvm-core/all/patches/11x/0003-split-dwarf.patch diff --git a/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/12x/0000-cmake-dependencies.patch similarity index 61% rename from recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch rename to recipes/llvm-core/all/patches/12x/0000-cmake-dependencies.patch index 37cac5512345c..319d08bc1921c 100644 --- a/recipes/llvm-core/all/patches/12x/00-cmake-target-props.patch +++ b/recipes/llvm-core/all/patches/12x/0000-cmake-dependencies.patch @@ -1,8 +1,23 @@ diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake -index 818fafbce14..14f5b67f168 100644 +index 818fafbce14..8ef381257b6 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake -@@ -127,7 +127,7 @@ if(LLVM_ENABLE_ZLIB) +@@ -63,7 +63,13 @@ check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT) + check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT) + + check_include_file(mach/mach.h HAVE_MACH_MACH_H) +-check_include_file(histedit.h HAVE_HISTEDIT_H) ++if (LLVM_ENABLE_LIBEDIT) ++ find_package(editline REQUIRED) ++ cmake_push_check_state() ++ list(APPEND CMAKE_REQUIRED_INCLUDES ${editline_INCLUDE_DIRS}) ++ check_include_file(histedit.h HAVE_HISTEDIT_H) ++ cmake_pop_check_state() ++endif() + check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H) + if(APPLE) + include(CheckCSourceCompiles) +@@ -127,7 +133,7 @@ if(LLVM_ENABLE_ZLIB) # library on a 64-bit system which would result in a link-time failure. cmake_push_check_state() list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) @@ -11,6 +26,29 @@ index 818fafbce14..14f5b67f168 100644 check_symbol_exists(compress2 zlib.h HAVE_ZLIB) cmake_pop_check_state() if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB) +@@ -165,7 +171,11 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + if (NOT PURE_WINDOWS) + # Skip libedit if using ASan as it contains memory leaks. + if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*") ++ cmake_push_check_state() ++ list(APPEND CMAKE_REQUIRED_INCLUDES ${editline_INCLUDE_DIRS}) ++ list(APPEND CMAKE_REQUIRED_LIBRARIES ${editline_LIBRARIES}) + check_library_exists(edit el_init "" HAVE_LIBEDIT) ++ cmake_pop_check_state() + else() + set(HAVE_LIBEDIT 0) + endif() +diff --git a/lib/LineEditor/CMakeLists.txt b/lib/LineEditor/CMakeLists.txt +index 61328f76905..b95d073d972 100644 +--- a/lib/LineEditor/CMakeLists.txt ++++ b/lib/LineEditor/CMakeLists.txt +@@ -1,5 +1,5 @@ + if(HAVE_LIBEDIT) +- set(link_libs edit) ++ set(link_libs editline::editline) + endif() + + add_llvm_component_library(LLVMLineEditor diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index cdee11412eb..f32a7b7909d 100644 --- a/lib/Support/CMakeLists.txt diff --git a/recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch b/recipes/llvm-core/all/patches/12x/0001-calculate-job-pools.patch similarity index 100% rename from recipes/llvm-core/all/patches/12x/01-calculate-job-pools.patch rename to recipes/llvm-core/all/patches/12x/0001-calculate-job-pools.patch diff --git a/recipes/llvm-core/all/patches/12x/02-missing-includes.patch b/recipes/llvm-core/all/patches/12x/0002-missing-includes.patch similarity index 100% rename from recipes/llvm-core/all/patches/12x/02-missing-includes.patch rename to recipes/llvm-core/all/patches/12x/0002-missing-includes.patch diff --git a/recipes/llvm-core/all/patches/12x/03-split-dwarf.patch b/recipes/llvm-core/all/patches/12x/0003-split-dwarf.patch similarity index 100% rename from recipes/llvm-core/all/patches/12x/03-split-dwarf.patch rename to recipes/llvm-core/all/patches/12x/0003-split-dwarf.patch diff --git a/recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch b/recipes/llvm-core/all/patches/13x/0000-cmake-target-props.patch similarity index 100% rename from recipes/llvm-core/all/patches/13x/00-cmake-target-props.patch rename to recipes/llvm-core/all/patches/13x/0000-cmake-target-props.patch diff --git a/recipes/llvm-core/all/patches/13x/01-calculate-job-pools.patch b/recipes/llvm-core/all/patches/13x/0001-calculate-job-pools.patch similarity index 100% rename from recipes/llvm-core/all/patches/13x/01-calculate-job-pools.patch rename to recipes/llvm-core/all/patches/13x/0001-calculate-job-pools.patch diff --git a/recipes/llvm-core/all/patches/13x/02-missing-includes.patch b/recipes/llvm-core/all/patches/13x/0002-missing-includes.patch similarity index 100% rename from recipes/llvm-core/all/patches/13x/02-missing-includes.patch rename to recipes/llvm-core/all/patches/13x/0002-missing-includes.patch diff --git a/recipes/llvm-core/all/patches/13x/03-split-dwarf.patch b/recipes/llvm-core/all/patches/13x/0003-split-dwarf.patch similarity index 100% rename from recipes/llvm-core/all/patches/13x/03-split-dwarf.patch rename to recipes/llvm-core/all/patches/13x/0003-split-dwarf.patch From d06773a1536e56039f91330540677fc06a894ebe Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 14 Mar 2024 00:50:22 +0000 Subject: [PATCH 34/77] [llvm-core] support for libedit (editline) in 13.x --- recipes/llvm-core/all/conandata.yml | 2 +- ...ps.patch => 0000-cmake-dependencies.patch} | 42 ++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) rename recipes/llvm-core/all/patches/13x/{0000-cmake-target-props.patch => 0000-cmake-dependencies.patch} (57%) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 1ed004e7e0099..a0594fd60a947 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -11,7 +11,7 @@ sources: patches: "13.0.0": - - patch_file: patches/13x/0000-cmake-target-props.patch + - patch_file: patches/13x/0000-cmake-dependencies.patch patch_description: fix references to third party libs to match conan variables and targets patch_type: conan - patch_file: patches/13x/0001-calculate-job-pools.patch diff --git a/recipes/llvm-core/all/patches/13x/0000-cmake-target-props.patch b/recipes/llvm-core/all/patches/13x/0000-cmake-dependencies.patch similarity index 57% rename from recipes/llvm-core/all/patches/13x/0000-cmake-target-props.patch rename to recipes/llvm-core/all/patches/13x/0000-cmake-dependencies.patch index 8c24bc4ef8320..a49abd15efa6c 100644 --- a/recipes/llvm-core/all/patches/13x/0000-cmake-target-props.patch +++ b/recipes/llvm-core/all/patches/13x/0000-cmake-dependencies.patch @@ -1,8 +1,23 @@ diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake -index dd0aaadb47c..e0771f99237 100644 +index dd0aaadb47c..790a0b27a49 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake -@@ -127,7 +127,7 @@ if(LLVM_ENABLE_ZLIB) +@@ -63,7 +63,13 @@ check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT) + check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT) + + check_include_file(mach/mach.h HAVE_MACH_MACH_H) +-check_include_file(histedit.h HAVE_HISTEDIT_H) ++if(LLVM_ENABLE_LIBEDIT) ++ find_package(editline REQUIRED) ++ cmake_push_check_state() ++ list(APPEND CMAKE_REQUIRED_INCLUDES ${editline_INCLUDE_DIRS}) ++ check_include_file(histedit.h HAVE_HISTEDIT_H) ++ cmake_pop_check_state() ++endif() + check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H) + if(APPLE) + include(CheckCSourceCompiles) +@@ -127,7 +133,7 @@ if(LLVM_ENABLE_ZLIB) # library on a 64-bit system which would result in a link-time failure. cmake_push_check_state() list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) @@ -11,6 +26,29 @@ index dd0aaadb47c..e0771f99237 100644 check_symbol_exists(compress2 zlib.h HAVE_ZLIB) cmake_pop_check_state() if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB) +@@ -166,7 +172,11 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + if (NOT PURE_WINDOWS) + # Skip libedit if using ASan as it contains memory leaks. + if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*") ++ cmake_push_check_state() ++ list(APPEND CMAKE_REQUIRED_INCLUDES ${editline_INCLUDE_DIRS}) ++ list(APPEND CMAKE_REQUIRED_LIBRARIES ${editline_LIBRARIES}) + check_library_exists(edit el_init "" HAVE_LIBEDIT) ++ cmake_pop_check_state() + else() + set(HAVE_LIBEDIT 0) + endif() +diff --git a/lib/LineEditor/CMakeLists.txt b/lib/LineEditor/CMakeLists.txt +index 61328f76905..b95d073d972 100644 +--- a/lib/LineEditor/CMakeLists.txt ++++ b/lib/LineEditor/CMakeLists.txt +@@ -1,5 +1,5 @@ + if(HAVE_LIBEDIT) +- set(link_libs edit) ++ set(link_libs editline::editline) + endif() + + add_llvm_component_library(LLVMLineEditor diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt index 014b4a2caf1..486e4f39642 100644 --- a/lib/Support/CMakeLists.txt From 916acf630581afdda3a2871d78d1d7f9c6e38dca Mon Sep 17 00:00:00 2001 From: planetmarshall Date: Fri, 15 Mar 2024 10:44:52 +0000 Subject: [PATCH 35/77] [llvm-core] disable shared debug for CCI, update license identifier and refactor --- recipes/llvm-core/all/conanfile.py | 46 +++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 7048ce26bc02f..8291bd8371c5c 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -29,7 +29,30 @@ required_conan_version = ">=1.62.0" -LLVM_TARGETS = "AArch64;AMDGPU;ARM;AVR;BPF;Hexagon;Lanai;LoongArch;Mips;MSP430;NVPTX;PowerPC;RISCV;Sparc;SystemZ;VE;WebAssembly;X86;XCore" +# LLVM's default config is enable all targets, but end users can significantly reduce +# build times for the package by disabling the ones they don't need with the corresponding option +# `-o llvm-core/*:with_target_=False` +LLVM_TARGETS = [ + "AArch64", + "AMDGPU", + "ARM", + "AVR", + "BPF", + "Hexagon", + "Lanai", + "LoongArch", + "Mips", + "MSP430", + "NVPTX", + "PowerPC", + "RISCV", + "Sparc", + "SystemZ", + "VE", + "WebAssembly", + "X86", + "XCore" +] class LLVMCoreConan(ConanFile): @@ -38,11 +61,10 @@ class LLVMCoreConan(ConanFile): "A toolkit for the construction of highly optimized compilers," "optimizers, and runtime environments." ) - license = "Apache-2.0 WITH LLVM-exception" + license = "LLVM-exception" topics = ("llvm", "compiler") homepage = "https://llvm.org" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -75,7 +97,7 @@ class LLVMCoreConan(ConanFile): "ram_per_compile_job": ["ANY"], "ram_per_link_job": ["ANY"], } - options.update({f"with_target_{target.lower()}": [True, False] for target in LLVM_TARGETS.split(";")}) + options.update({f"with_target_{target.lower()}": [True, False] for target in LLVM_TARGETS}) default_options = { "shared": False, "fPIC": True, @@ -98,7 +120,7 @@ class LLVMCoreConan(ConanFile): "ram_per_compile_job": "auto", "ram_per_link_job": "auto" } - default_options.update({f"with_target_{target.lower()}": True for target in LLVM_TARGETS.split(";")}) + default_options.update({f"with_target_{target.lower()}": True for target in LLVM_TARGETS}) @property def _min_cppstd(self): @@ -170,18 +192,17 @@ def validate(self): # FIXME support cross compilation, at least for common cases like Apple Silicon -> X86 raise ConanInvalidConfiguration("Cross compilation is not supported") + if os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.options.shared and self.settings.build_type == "Debug": + raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def _apply_resource_limits(self, cmake_definitions): if os.getenv("CONAN_CENTER_BUILD_SERVICE"): self.output.info("Applying CCI Resource Limits") - if self.options.shared and self.settings.build_type == "Debug": - ram_per_link_job = "32768" - else: - ram_per_link_job = "16384" cmake_definitions.update({ - "LLVM_RAM_PER_LINK_JOB": ram_per_link_job, + "LLVM_RAM_PER_LINK_JOB": "16384", "LLVM_RAM_PER_COMPILE_JOB": "2048" }) else: @@ -192,14 +213,13 @@ def _apply_resource_limits(self, cmake_definitions): @property def _targets_to_build(self): - return ";".join(target for target in LLVM_TARGETS.split(";") if self.options.get_safe(f"with_target_{target.lower()}")) + return ";".join(target for target in LLVM_TARGETS if self.options.get_safe(f"with_target_{target.lower()}")) @property def _all_targets(self): # This is not just LLVM_TARGETS as it is version specific return ";".join( - target for target in LLVM_TARGETS.split(";") if - self.options.get_safe(f"with_target_{target.lower()}") is not None) + target for target in LLVM_TARGETS if self.options.get_safe(f"with_target_{target.lower()}") is not None) def generate(self): tc = CMakeToolchain(self, generator="Ninja") From 43ac3ac707eef3aae06f176269af620cc10ca63a Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 16 Mar 2024 00:09:45 +0000 Subject: [PATCH 36/77] [llvm-core] require cxx std 14 for test package --- recipes/llvm-core/all/conanfile.py | 16 ++++++++-------- .../llvm-core/all/test_package/CMakeLists.txt | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 8291bd8371c5c..b37ec567e2f44 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -1,5 +1,3 @@ -import textwrap - from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os @@ -26,6 +24,8 @@ import os from pathlib import Path import re +import textwrap + required_conan_version = ">=1.62.0" @@ -181,20 +181,20 @@ def validate(self): f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) - if self._is_windows: - if self.options.shared: # Shared builds disabled just due to the CI + if self.options.shared: + if self._is_windows: raise ConanInvalidConfiguration("Shared builds not currently supported on Windows") + if os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug": + raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") if self.options.exceptions and not self.options.rtti: raise ConanInvalidConfiguration("Cannot enable exceptions without rtti support") if cross_building(self): # FIXME support cross compilation, at least for common cases like Apple Silicon -> X86 + # requires a host-compiled version of llvm-tablegen raise ConanInvalidConfiguration("Cross compilation is not supported") - if os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.options.shared and self.settings.build_type == "Debug": - raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") - def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -279,7 +279,7 @@ def generate(self): cmake_definitions["LLVM_USE_SANITIZER"] = self.options.use_sanitizer if is_apple_os(self): - # otherwise we can't find shared dependencies during the build + # otherwise llvm-tablegen can't find shared dependencies during the build cmake_definitions["CMAKE_SKIP_RPATH"] = True tc.variables.update(cmake_definitions) diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index 2b7d245b17e51..036f136c63938 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -8,6 +8,7 @@ macro(test_llvm_cmake_variable VARIABLE) message(STATUS "${VARIABLE}: ${${VARIABLE}}") endmacro() +set(CMAKE_CXX_STANDARD 14) add_executable(${PROJECT_NAME} test_package.cpp) if (LLVM_SHARED) From 9bb46e2e4718411b542602a44962865ee1a2c9a9 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 16 Mar 2024 19:47:55 +0000 Subject: [PATCH 37/77] [llvm-core] handle edge case of static libiconv being linked into a dynamic library on macos --- recipes/llvm-core/all/conanfile.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index b37ec567e2f44..67b1963f506cc 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -186,6 +186,13 @@ def validate(self): raise ConanInvalidConfiguration("Shared builds not currently supported on Windows") if os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug": raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") + if is_apple_os(self): + # FIXME iconv contains duplicate symbols in the libiconv and libcharset libraries (both of which are + # provided by libiconv). This may be an issue with how conan packages libiconv + iconv_dep = self.dependencies.get("libiconv") + if iconv_dep and not iconv_dep.options.shared: + raise ConanInvalidConfiguration("Static iconv cannot be linked into a shared library on macos " + "due to duplicate symbols. Use libxml2/*:iconv=False.") if self.options.exceptions and not self.options.rtti: raise ConanInvalidConfiguration("Cannot enable exceptions without rtti support") From b3d17c9f4972952fc42a3540219c98c179e5e76d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 16 Mar 2024 20:13:57 +0000 Subject: [PATCH 38/77] [llvm-core] skip rpath handling for build on macos --- recipes/llvm-core/all/conanfile.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 67b1963f506cc..c18f488ac5f17 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -285,10 +285,6 @@ def generate(self): else: cmake_definitions["LLVM_USE_SANITIZER"] = self.options.use_sanitizer - if is_apple_os(self): - # otherwise llvm-tablegen can't find shared dependencies during the build - cmake_definitions["CMAKE_SKIP_RPATH"] = True - tc.variables.update(cmake_definitions) tc.cache_variables.update({ # Enables LLVM to find conan libraries during try_compile @@ -299,6 +295,11 @@ def generate(self): # It is likely the latter that the user expects by a "shared library" build. "BUILD_SHARED_LIBS": False }) + + if is_apple_os(self): + # otherwise llvm-tablegen can't find shared dependencies during the build + tc.cache_variables["CMAKE_SKIP_BUILD_RPATH"] = True + tc.generate() tc = CMakeDeps(self) From 954a39673cf736a64432b7fdd512a70108317654 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 17 Mar 2024 11:57:25 +0000 Subject: [PATCH 39/77] [llvm-core] propagate DYLD_LIBRARY_PATH to tblgen during build --- recipes/llvm-core/all/conandata.yml | 13 +++++++++---- recipes/llvm-core/all/conanfile.py | 5 ----- .../all/patches/11x/0004-tblgen-dyld-lib-path.patch | 13 +++++++++++++ .../all/patches/12x/0004-tblgen-dyld-lib-path.patch | 13 +++++++++++++ .../all/patches/13x/0004-tblgen-dyld-lib-path.patch | 13 +++++++++++++ 5 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 recipes/llvm-core/all/patches/11x/0004-tblgen-dyld-lib-path.patch create mode 100644 recipes/llvm-core/all/patches/12x/0004-tblgen-dyld-lib-path.patch create mode 100644 recipes/llvm-core/all/patches/13x/0004-tblgen-dyld-lib-path.patch diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index a0594fd60a947..99b44de35d2d3 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -25,6 +25,9 @@ patches: patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 patch_type: bugfix + - patch_file: patches/13x/0004-tblgen-dyld-lib-path.patch + patch_description: propagate DTLD_LIBRARY_PATH to tblgen command + patch_type: conan "12.0.0": - patch_file: patches/12x/0000-cmake-dependencies.patch patch_description: fix references to third party libs to match conan variables and targets @@ -36,10 +39,9 @@ patches: - patch_file: patches/12x/0002-missing-includes.patch patch_description: fix missing header files patch_type: portability - - patch_file: patches/12x/0003-split-dwarf.patch - patch_description: enable split dwarf option from 14.x - patch_source: https://reviews.llvm.org/D108776 - patch_type: bugfix + - patch_file: patches/12x/0004-tblgen-dyld-lib-path.patch + patch_description: propagate DTLD_LIBRARY_PATH to tblgen command + patch_type: conan "11.1.0": - patch_file: patches/11x/0000-cmake-dependencies.patch patch_description: fix references to third party libs to match conan variables and targets @@ -55,3 +57,6 @@ patches: patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 patch_type: bugfix + - patch_file: patches/11x/0004-tblgen-dyld-lib-path.patch + patch_description: propagate DTLD_LIBRARY_PATH to tblgen command + patch_type: conan diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index c18f488ac5f17..e97974b909852 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -295,11 +295,6 @@ def generate(self): # It is likely the latter that the user expects by a "shared library" build. "BUILD_SHARED_LIBS": False }) - - if is_apple_os(self): - # otherwise llvm-tablegen can't find shared dependencies during the build - tc.cache_variables["CMAKE_SKIP_BUILD_RPATH"] = True - tc.generate() tc = CMakeDeps(self) diff --git a/recipes/llvm-core/all/patches/11x/0004-tblgen-dyld-lib-path.patch b/recipes/llvm-core/all/patches/11x/0004-tblgen-dyld-lib-path.patch new file mode 100644 index 0000000000000..e981acd9aeae4 --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/0004-tblgen-dyld-lib-path.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake +index 73c1e96d3d9..e86014dbb69 100644 +--- a/cmake/modules/TableGen.cmake ++++ b/cmake/modules/TableGen.cmake +@@ -98,7 +98,7 @@ function(tablegen project ofn) + # ("${${project}_TABLEGEN_TARGET}" STREQUAL "${${project}_TABLEGEN_EXE}") + # but lets us having smaller and cleaner code here. + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} +- COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} ++ COMMAND ${CMAKE_COMMAND} -E env DYLD_LIBRARY_PATH="$ENV{DYLD_LIBRARY_PATH}" $ ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} + ${tblgen_includes} + ${LLVM_TABLEGEN_FLAGS} + ${LLVM_TARGET_DEFINITIONS_ABSOLUTE} diff --git a/recipes/llvm-core/all/patches/12x/0004-tblgen-dyld-lib-path.patch b/recipes/llvm-core/all/patches/12x/0004-tblgen-dyld-lib-path.patch new file mode 100644 index 0000000000000..8e43443bb6e43 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/0004-tblgen-dyld-lib-path.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake +index 5f07acc1f69..44b5286be62 100644 +--- a/cmake/modules/TableGen.cmake ++++ b/cmake/modules/TableGen.cmake +@@ -92,7 +92,7 @@ function(tablegen project ofn) + list(TRANSFORM tblgen_includes PREPEND -I) + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} +- COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} ++ COMMAND ${CMAKE_COMMAND} -E env DYLD_LIBRARY_PATH="$ENV{DYLD_LIBRARY_PATH}" $ ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} + ${tblgen_includes} + ${LLVM_TABLEGEN_FLAGS} + ${LLVM_TARGET_DEFINITIONS_ABSOLUTE} diff --git a/recipes/llvm-core/all/patches/13x/0004-tblgen-dyld-lib-path.patch b/recipes/llvm-core/all/patches/13x/0004-tblgen-dyld-lib-path.patch new file mode 100644 index 0000000000000..941434310964a --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/0004-tblgen-dyld-lib-path.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake +index 5e9e2674405..ca7c83132c7 100644 +--- a/cmake/modules/TableGen.cmake ++++ b/cmake/modules/TableGen.cmake +@@ -93,7 +93,7 @@ function(tablegen project ofn) + list(TRANSFORM tblgen_includes PREPEND -I) + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} +- COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} ++ COMMAND ${CMAKE_COMMAND} -E env DYLD_LIBRARY_PATH="$ENV{DYLD_LIBRARY_PATH}" $ ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} + ${tblgen_includes} + ${LLVM_TABLEGEN_FLAGS} + ${LLVM_TARGET_DEFINITIONS_ABSOLUTE} From 42847cffd8b9f59e1c62c94e64aa4f15b6625a4e Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 17 Mar 2024 12:20:53 +0000 Subject: [PATCH 40/77] [llvm-core] propagate DYLD_LIBRARY_PATH to tblgen during build --- recipes/llvm-core/all/conandata.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 99b44de35d2d3..5541ccaa62a48 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -39,6 +39,10 @@ patches: - patch_file: patches/12x/0002-missing-includes.patch patch_description: fix missing header files patch_type: portability + - patch_file: patches/12x/0003-split-dwarf.patch + patch_description: enable split dwarf option from 14.x + patch_source: https://reviews.llvm.org/D108776 + patch_type: bugfix - patch_file: patches/12x/0004-tblgen-dyld-lib-path.patch patch_description: propagate DTLD_LIBRARY_PATH to tblgen command patch_type: conan From 87f40f4a0d25599af350db4d1535870148a46884 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 18 Mar 2024 12:22:54 +0000 Subject: [PATCH 41/77] [llvm-core] do not build shared libs with the install rpath --- recipes/llvm-core/all/conandata.yml | 13 ++++++------- .../11x/0004-no-build-with-install-rpath.patch | 13 +++++++++++++ .../all/patches/11x/0004-tblgen-dyld-lib-path.patch | 13 ------------- .../12x/0004-no-build-with-install-rpath.patch | 13 +++++++++++++ .../all/patches/12x/0004-tblgen-dyld-lib-path.patch | 13 ------------- .../13x/0004-no-build-with-install-rpath.patch | 13 +++++++++++++ .../all/patches/13x/0004-tblgen-dyld-lib-path.patch | 13 ------------- 7 files changed, 45 insertions(+), 46 deletions(-) create mode 100644 recipes/llvm-core/all/patches/11x/0004-no-build-with-install-rpath.patch delete mode 100644 recipes/llvm-core/all/patches/11x/0004-tblgen-dyld-lib-path.patch create mode 100644 recipes/llvm-core/all/patches/12x/0004-no-build-with-install-rpath.patch delete mode 100644 recipes/llvm-core/all/patches/12x/0004-tblgen-dyld-lib-path.patch create mode 100644 recipes/llvm-core/all/patches/13x/0004-no-build-with-install-rpath.patch delete mode 100644 recipes/llvm-core/all/patches/13x/0004-tblgen-dyld-lib-path.patch diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 5541ccaa62a48..3fe429548be3c 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -24,9 +24,8 @@ patches: - patch_file: patches/13x/0003-split-dwarf.patch patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 - patch_type: bugfix - - patch_file: patches/13x/0004-tblgen-dyld-lib-path.patch - patch_description: propagate DTLD_LIBRARY_PATH to tblgen command + - patch_file: patches/13x/0004-no-build-with-install-rpath.patch + patch_description: do not build shared libs with install rpath patch_type: conan "12.0.0": - patch_file: patches/12x/0000-cmake-dependencies.patch @@ -43,8 +42,8 @@ patches: patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 patch_type: bugfix - - patch_file: patches/12x/0004-tblgen-dyld-lib-path.patch - patch_description: propagate DTLD_LIBRARY_PATH to tblgen command + - patch_file: patches/12x/0004-no-build-with-install-rpath.patch + patch_description: do not build shared libs with install rpath patch_type: conan "11.1.0": - patch_file: patches/11x/0000-cmake-dependencies.patch @@ -61,6 +60,6 @@ patches: patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 patch_type: bugfix - - patch_file: patches/11x/0004-tblgen-dyld-lib-path.patch - patch_description: propagate DTLD_LIBRARY_PATH to tblgen command + - patch_file: patches/11x/0004-no-build-with-install-rpath.patch + patch_description: do not build shared libs with install rpath patch_type: conan diff --git a/recipes/llvm-core/all/patches/11x/0004-no-build-with-install-rpath.patch b/recipes/llvm-core/all/patches/11x/0004-no-build-with-install-rpath.patch new file mode 100644 index 0000000000000..e56177aab947f --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/0004-no-build-with-install-rpath.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index b74adc11ade9..8c70fe15d2a0 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -2081,7 +2081,7 @@ function(llvm_setup_rpath name) + endif() + + set_target_properties(${name} PROPERTIES +- BUILD_WITH_INSTALL_RPATH On ++ BUILD_WITH_INSTALL_RPATH OFF + INSTALL_RPATH "${_install_rpath}" + ${_install_name_dir}) + endfunction() diff --git a/recipes/llvm-core/all/patches/11x/0004-tblgen-dyld-lib-path.patch b/recipes/llvm-core/all/patches/11x/0004-tblgen-dyld-lib-path.patch deleted file mode 100644 index e981acd9aeae4..0000000000000 --- a/recipes/llvm-core/all/patches/11x/0004-tblgen-dyld-lib-path.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake -index 73c1e96d3d9..e86014dbb69 100644 ---- a/cmake/modules/TableGen.cmake -+++ b/cmake/modules/TableGen.cmake -@@ -98,7 +98,7 @@ function(tablegen project ofn) - # ("${${project}_TABLEGEN_TARGET}" STREQUAL "${${project}_TABLEGEN_EXE}") - # but lets us having smaller and cleaner code here. - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} -- COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} -+ COMMAND ${CMAKE_COMMAND} -E env DYLD_LIBRARY_PATH="$ENV{DYLD_LIBRARY_PATH}" $ ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} - ${tblgen_includes} - ${LLVM_TABLEGEN_FLAGS} - ${LLVM_TARGET_DEFINITIONS_ABSOLUTE} diff --git a/recipes/llvm-core/all/patches/12x/0004-no-build-with-install-rpath.patch b/recipes/llvm-core/all/patches/12x/0004-no-build-with-install-rpath.patch new file mode 100644 index 0000000000000..df143f02d6491 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/0004-no-build-with-install-rpath.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index 97c9980c7de3..23fead47c2d7 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -2118,7 +2118,7 @@ function(llvm_setup_rpath name) + + # Enable BUILD_WITH_INSTALL_RPATH unless CMAKE_BUILD_RPATH is set. + if("${CMAKE_BUILD_RPATH}" STREQUAL "") +- set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH ON) ++ set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH OFF) + endif() + + set_target_properties(${name} PROPERTIES diff --git a/recipes/llvm-core/all/patches/12x/0004-tblgen-dyld-lib-path.patch b/recipes/llvm-core/all/patches/12x/0004-tblgen-dyld-lib-path.patch deleted file mode 100644 index 8e43443bb6e43..0000000000000 --- a/recipes/llvm-core/all/patches/12x/0004-tblgen-dyld-lib-path.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake -index 5f07acc1f69..44b5286be62 100644 ---- a/cmake/modules/TableGen.cmake -+++ b/cmake/modules/TableGen.cmake -@@ -92,7 +92,7 @@ function(tablegen project ofn) - list(TRANSFORM tblgen_includes PREPEND -I) - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} -- COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} -+ COMMAND ${CMAKE_COMMAND} -E env DYLD_LIBRARY_PATH="$ENV{DYLD_LIBRARY_PATH}" $ ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} - ${tblgen_includes} - ${LLVM_TABLEGEN_FLAGS} - ${LLVM_TARGET_DEFINITIONS_ABSOLUTE} diff --git a/recipes/llvm-core/all/patches/13x/0004-no-build-with-install-rpath.patch b/recipes/llvm-core/all/patches/13x/0004-no-build-with-install-rpath.patch new file mode 100644 index 0000000000000..05560e5a0c714 --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/0004-no-build-with-install-rpath.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index 29e40f45fef8..bde9a02b3432 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -2143,7 +2143,7 @@ function(llvm_setup_rpath name) + + # Enable BUILD_WITH_INSTALL_RPATH unless CMAKE_BUILD_RPATH is set. + if("${CMAKE_BUILD_RPATH}" STREQUAL "") +- set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH ON) ++ set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH OFF) + endif() + + set_target_properties(${name} PROPERTIES diff --git a/recipes/llvm-core/all/patches/13x/0004-tblgen-dyld-lib-path.patch b/recipes/llvm-core/all/patches/13x/0004-tblgen-dyld-lib-path.patch deleted file mode 100644 index 941434310964a..0000000000000 --- a/recipes/llvm-core/all/patches/13x/0004-tblgen-dyld-lib-path.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake -index 5e9e2674405..ca7c83132c7 100644 ---- a/cmake/modules/TableGen.cmake -+++ b/cmake/modules/TableGen.cmake -@@ -93,7 +93,7 @@ function(tablegen project ofn) - list(TRANSFORM tblgen_includes PREPEND -I) - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} -- COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} -+ COMMAND ${CMAKE_COMMAND} -E env DYLD_LIBRARY_PATH="$ENV{DYLD_LIBRARY_PATH}" $ ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR} - ${tblgen_includes} - ${LLVM_TABLEGEN_FLAGS} - ${LLVM_TARGET_DEFINITIONS_ABSOLUTE} From 652d4b35867d7965f6cc7eb9d2214ca410197f14 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 18 Mar 2024 13:43:53 +0000 Subject: [PATCH 42/77] [llvm-core] use original test package --- .../llvm-core/all/test_package/CMakeLists.txt | 2 +- .../llvm-core/all/test_package/conanfile.py | 20 +- .../all/test_package/test_function.ll | 6 + .../all/test_package/test_package.cpp | 483 ++---------------- 4 files changed, 43 insertions(+), 468 deletions(-) create mode 100644 recipes/llvm-core/all/test_package/test_function.ll diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index 036f136c63938..9edc7e4401af4 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -8,7 +8,7 @@ macro(test_llvm_cmake_variable VARIABLE) message(STATUS "${VARIABLE}: ${${VARIABLE}}") endmacro() -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) add_executable(${PROJECT_NAME} test_package.cpp) if (LLVM_SHARED) diff --git a/recipes/llvm-core/all/test_package/conanfile.py b/recipes/llvm-core/all/test_package/conanfile.py index f3878ab529814..acf43d80c5932 100644 --- a/recipes/llvm-core/all/test_package/conanfile.py +++ b/recipes/llvm-core/all/test_package/conanfile.py @@ -4,7 +4,6 @@ from conan.tools.build import can_run import os -import re class TestPackageConan(ConanFile): @@ -16,10 +15,6 @@ def layout(self): def requirements(self): self.requires(self.tested_reference_str) - def build_requirements(self): - self.tool_requires("cmake/[>=3.21.3 <4.0.0]") - self.tool_requires("ninja/[>=1.10.0 <2.0.0]") - def generate(self): deps = CMakeDeps(self) deps.check_components_exist = True @@ -32,16 +27,6 @@ def generate(self): VirtualRunEnv(self).generate() - def _llvm_major_version(self): - pattern = re.compile("^llvm-core/([0-9]+)") - return int(re.findall(pattern, self.tested_reference_str)[0]) - - def _ccpstd(self): - cppstd = 14 - if self._llvm_major_version() >= 16: - cppstd = 17 - return cppstd - def build(self): cmake = CMake(self) cmake.configure() @@ -49,5 +34,6 @@ def build(self): def test(self): if can_run(self): - bin_path = os.path.join(self.cpp.build.bindir, "test_package") - self.run(bin_path, env="conanrun") + cmd = os.path.join(self.cpp.build.bindir, "test_package") + args = os.path.join(os.path.dirname(__file__), "test_function.ll") + self.run(f"{cmd} {args}", env="conanrun") 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 index 8b822065d1dfa..e5de3a64aa80d 100644 --- a/recipes/llvm-core/all/test_package/test_package.cpp +++ b/recipes/llvm-core/all/test_package/test_package.cpp @@ -1,455 +1,38 @@ -// Kaleidoscope example from -// https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl02.html#full-code-listing +#include +#include +#include +#include +#include +#include +#include -#include "llvm/ADT/STLExtras.h" -#include "llvm/Support/raw_ostream.h" -#include -#include -#include -#include -#include #include -#include -#include -//===----------------------------------------------------------------------===// -// Lexer -//===----------------------------------------------------------------------===// -// The lexer returns tokens [0-255] if it is an unknown character, otherwise one -// of these for known things. -enum Token { - tok_eof = -1, - - // commands - tok_def = -2, - tok_extern = -3, - - // primary - tok_identifier = -4, - tok_number = -5 -}; - -static std::string IdentifierStr; // Filled in if tok_identifier -static double NumVal; // Filled in if tok_number - -/// gettok - Return the next token from standard input. -static int gettok() { - static int LastChar = ' '; - - // Skip any whitespace. - while (isspace(LastChar)) - LastChar = getchar(); - - if (isalpha(LastChar)) { // identifier: [a-zA-Z][a-zA-Z0-9]* - IdentifierStr = LastChar; - while (isalnum((LastChar = getchar()))) - IdentifierStr += LastChar; - - if (IdentifierStr == "def") - return tok_def; - if (IdentifierStr == "extern") - return tok_extern; - return tok_identifier; - } - - if (isdigit(LastChar) || LastChar == '.') { // Number: [0-9.]+ - std::string NumStr; - do { - NumStr += LastChar; - LastChar = getchar(); - } while (isdigit(LastChar) || LastChar == '.'); - - NumVal = strtod(NumStr.c_str(), nullptr); - return tok_number; - } - - if (LastChar == '#') { - // Comment until end of line. - do - LastChar = getchar(); - while (LastChar != EOF && LastChar != '\n' && LastChar != '\r'); - - if (LastChar != EOF) - return gettok(); - } - - // Check for end of file. Don't eat the EOF. - if (LastChar == EOF) - return tok_eof; - - // Otherwise, just return the character as its ascii value. - int ThisChar = LastChar; - LastChar = getchar(); - return ThisChar; -} - -//===----------------------------------------------------------------------===// -// Abstract Syntax Tree (aka Parse Tree) -//===----------------------------------------------------------------------===// - -namespace { - -/// ExprAST - Base class for all expression nodes. -class ExprAST { -public: - virtual ~ExprAST() = default; -}; - -/// NumberExprAST - Expression class for numeric literals like "1.0". -class NumberExprAST : public ExprAST { - double Val; - -public: - NumberExprAST(double Val) : Val(Val) {} -}; - -/// VariableExprAST - Expression class for referencing a variable, like "a". -class VariableExprAST : public ExprAST { - std::string Name; - -public: - VariableExprAST(const std::string &Name) : Name(Name) {} -}; - -/// BinaryExprAST - Expression class for a binary operator. -class BinaryExprAST : public ExprAST { - char Op; - std::unique_ptr LHS, RHS; - -public: - BinaryExprAST(char Op, std::unique_ptr LHS, - std::unique_ptr RHS) - : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {} -}; - -/// CallExprAST - Expression class for function calls. -class CallExprAST : public ExprAST { - std::string Callee; - std::vector> Args; - -public: - CallExprAST(const std::string &Callee, - std::vector> Args) - : Callee(Callee), Args(std::move(Args)) {} -}; - -/// PrototypeAST - This class represents the "prototype" for a function, -/// which captures its name, and its argument names (thus implicitly the number -/// of arguments the function takes). -class PrototypeAST { - std::string Name; - std::vector Args; - -public: - PrototypeAST(const std::string &Name, std::vector Args) - : Name(Name), Args(std::move(Args)) {} - - const std::string &getName() const { return Name; } -}; - -/// FunctionAST - This class represents a function definition itself. -class FunctionAST { - std::unique_ptr Proto; - std::unique_ptr Body; - -public: - FunctionAST(std::unique_ptr Proto, - std::unique_ptr Body) - : Proto(std::move(Proto)), Body(std::move(Body)) {} -}; - -} // end anonymous namespace - -//===----------------------------------------------------------------------===// -// Parser -//===----------------------------------------------------------------------===// - -/// CurTok/getNextToken - Provide a simple token buffer. CurTok is the current -/// token the parser is looking at. getNextToken reads another token from the -/// lexer and updates CurTok with its results. -static int CurTok; -static int getNextToken() { return CurTok = gettok(); } - -/// BinopPrecedence - This holds the precedence for each binary operator that is -/// defined. -static std::map BinopPrecedence; - -/// GetTokPrecedence - Get the precedence of the pending binary operator token. -static int GetTokPrecedence() { - if (!isascii(CurTok)) - return -1; - - // Make sure it's a declared binop. - int TokPrec = BinopPrecedence[CurTok]; - if (TokPrec <= 0) - return -1; - return TokPrec; -} - -/// LogError* - These are little helper functions for error handling. -std::unique_ptr LogError(const char *Str) { - fprintf(stderr, "Error: %s\n", Str); - return nullptr; -} -std::unique_ptr LogErrorP(const char *Str) { - LogError(Str); - return nullptr; -} - -static std::unique_ptr ParseExpression(); - -/// numberexpr ::= number -static std::unique_ptr ParseNumberExpr() { - auto Result = std::make_unique(NumVal); - getNextToken(); // consume the number - return std::move(Result); -} - -/// parenexpr ::= '(' expression ')' -static std::unique_ptr ParseParenExpr() { - getNextToken(); // eat (. - auto V = ParseExpression(); - if (!V) - return nullptr; - - if (CurTok != ')') - return LogError("expected ')'"); - getNextToken(); // eat ). - return V; -} - -/// identifierexpr -/// ::= identifier -/// ::= identifier '(' expression* ')' -static std::unique_ptr ParseIdentifierExpr() { - std::string IdName = IdentifierStr; - - getNextToken(); // eat identifier. - - if (CurTok != '(') // Simple variable ref. - return std::make_unique(IdName); - - // Call. - getNextToken(); // eat ( - std::vector> Args; - if (CurTok != ')') { - while (true) { - if (auto Arg = ParseExpression()) - Args.push_back(std::move(Arg)); - else - return nullptr; - - if (CurTok == ')') - break; - - if (CurTok != ',') - return LogError("Expected ')' or ',' in argument list"); - getNextToken(); - } - } - - // Eat the ')'. - getNextToken(); - - return std::make_unique(IdName, std::move(Args)); -} - -/// primary -/// ::= identifierexpr -/// ::= numberexpr -/// ::= parenexpr -static std::unique_ptr ParsePrimary() { - switch (CurTok) { - default: - return LogError("unknown token when expecting an expression"); - case tok_identifier: - return ParseIdentifierExpr(); - case tok_number: - return ParseNumberExpr(); - case '(': - return ParseParenExpr(); - } -} - -/// binoprhs -/// ::= ('+' primary)* -static std::unique_ptr ParseBinOpRHS(int ExprPrec, - std::unique_ptr LHS) { - // If this is a binop, find its precedence. - while (true) { - int TokPrec = GetTokPrecedence(); - - // If this is a binop that binds at least as tightly as the current binop, - // consume it, otherwise we are done. - if (TokPrec < ExprPrec) - return LHS; - - // Okay, we know this is a binop. - int BinOp = CurTok; - getNextToken(); // eat binop - - // Parse the primary expression after the binary operator. - auto RHS = ParsePrimary(); - if (!RHS) - return nullptr; - - // If BinOp binds less tightly with RHS than the operator after RHS, let - // the pending operator take RHS as its LHS. - int NextPrec = GetTokPrecedence(); - if (TokPrec < NextPrec) { - RHS = ParseBinOpRHS(TokPrec + 1, std::move(RHS)); - if (!RHS) - return nullptr; - } - - // Merge LHS/RHS. - LHS = - std::make_unique(BinOp, std::move(LHS), std::move(RHS)); - } -} - -/// expression -/// ::= primary binoprhs -/// -static std::unique_ptr ParseExpression() { - auto LHS = ParsePrimary(); - if (!LHS) - return nullptr; - - return ParseBinOpRHS(0, std::move(LHS)); -} - -/// prototype -/// ::= id '(' id* ')' -static std::unique_ptr ParsePrototype() { - if (CurTok != tok_identifier) - return LogErrorP("Expected function name in prototype"); - - std::string FnName = IdentifierStr; - getNextToken(); - - if (CurTok != '(') - return LogErrorP("Expected '(' in prototype"); - - std::vector ArgNames; - while (getNextToken() == tok_identifier) - ArgNames.push_back(IdentifierStr); - if (CurTok != ')') - return LogErrorP("Expected ')' in prototype"); - - // success. - getNextToken(); // eat ')'. - - return std::make_unique(FnName, std::move(ArgNames)); -} - -/// definition ::= 'def' prototype expression -static std::unique_ptr ParseDefinition() { - getNextToken(); // eat def. - auto Proto = ParsePrototype(); - if (!Proto) - return nullptr; - - if (auto E = ParseExpression()) - return std::make_unique(std::move(Proto), std::move(E)); - return nullptr; -} - -/// toplevelexpr ::= expression -static std::unique_ptr ParseTopLevelExpr() { - if (auto E = ParseExpression()) { - // Make an anonymous proto. - auto Proto = std::make_unique("__anon_expr", - std::vector()); - return std::make_unique(std::move(Proto), std::move(E)); - } - return nullptr; -} - -/// external ::= 'extern' prototype -static std::unique_ptr ParseExtern() { - getNextToken(); // eat extern. - return ParsePrototype(); -} - -//===----------------------------------------------------------------------===// -// Top-Level parsing -//===----------------------------------------------------------------------===// - -static void HandleDefinition() { - if (ParseDefinition()) { - fprintf(stderr, "Parsed a function definition.\n"); - } else { - // Skip token for error recovery. - getNextToken(); - } -} - -static void HandleExtern() { - if (ParseExtern()) { - fprintf(stderr, "Parsed an extern\n"); - } else { - // Skip token for error recovery. - getNextToken(); - } -} - -static void HandleTopLevelExpression() { - // Evaluate a top-level expression into an anonymous function. - if (ParseTopLevelExpr()) { - fprintf(stderr, "Parsed a top-level expr\n"); - } else { - // Skip token for error recovery. - getNextToken(); - } -} - -/// top ::= definition | external | expression | ';' -static void MainLoop() { - while (true) { - fprintf(stderr, "ready> "); - switch (CurTok) { - case tok_eof: - return; - case ';': // ignore top-level semicolons. - getNextToken(); - break; - case tok_def: - HandleDefinition(); - break; - case tok_extern: - HandleExtern(); - break; - default: - HandleTopLevelExpression(); - break; - } - } -} - -//===----------------------------------------------------------------------===// -// Main driver code. -//===----------------------------------------------------------------------===// - -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) - - // Install standard binary operators. - // 1 is lowest precedence. - BinopPrecedence['<'] = 10; - BinopPrecedence['+'] = 20; - BinopPrecedence['-'] = 20; - BinopPrecedence['*'] = 40; // highest. - - // Prime the first token. - fprintf(stderr, "ready> "); - getNextToken(); - - // Run the main "interpreter loop" now. - MainLoop(); - - return 0; +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(); } From 8562e9e1b8230c4530a016970192a21deb5db6e3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 18 Mar 2024 13:47:36 +0000 Subject: [PATCH 43/77] [llvm-core] do not package static libraries with shared build --- 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 e97974b909852..b9860c9e791a0 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -441,6 +441,8 @@ def package(self): rename(self, cmake_folder / "LLVM-Config.cmake", cmake_folder / "LLVM-ConfigInternal.cmake") replace_in_file(self, cmake_folder / "AddLLVM.cmake", "LLVM-Config", "LLVM-ConfigInternal") rmdir(self, package_folder / "share") + if self.options.shared: + rm(self, "*.a", package_folder / "lib") self._create_cmake_build_module( components.keys(), From d86e98752f9d3ef3a887ba4d5044b468d798d5d3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 18 Mar 2024 15:48:30 +0000 Subject: [PATCH 44/77] [llvm-core] fix test_package --- recipes/llvm-core/all/test_package/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index 9edc7e4401af4..f1ee7c7b23b19 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -15,8 +15,8 @@ if (LLVM_SHARED) find_package(LLVM REQUIRED) target_link_libraries(${PROJECT_NAME} PRIVATE LLVM) else() - find_package(LLVM REQUIRED COMPONENTS LLVMSupport LLVMCore LLVMIRReader) - llvm_map_components_to_libnames(llvm_libs support core irreader) + find_package(LLVM REQUIRED COMPONENTS LLVMInterpreter LLVMX86CodeGen LLVMIRReader) + llvm_map_components_to_libnames(llvm_libs interpreter x86codegen irreader) target_link_libraries(${PROJECT_NAME} PRIVATE ${llvm_libs}) endif() From 5b96fd22342c6da826c7e2d898cdb6fcdcd21c97 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 19 Mar 2024 09:28:39 +0000 Subject: [PATCH 45/77] [llvm-core] support linking in lib for native codegen --- recipes/llvm-core/all/conanfile.py | 77 +++++++++---------- .../llvm-core/all/test_package/CMakeLists.txt | 6 +- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index b9860c9e791a0..e58ae22b27404 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -314,26 +314,7 @@ def build(self): def _is_windows(self): return self.settings.os == "Windows" - def _llvm_components(self): - cmake_config = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") - - match_cmake_var = re.compile(r"""^set\(LLVM_AVAILABLE_LIBS (?P.*)\)$""", re.MULTILINE) - match = match_cmake_var.search(cmake_config) - if match is None: - self.output.warning("Could not find components in LLVMConfig.cmake") - return None - - components = match.groupdict()["components"] - for component in components.split(";"): - yield component - - def _component_dependencies(self): - """ - Returns a dictionary indexed by the LLVM component name (target) containing - the component dependencies and system libs. Parsed from the CMake files - generated by the LLVM project - """ - + def _update_component_dependencies(self, components): def _sanitized_components(deps_list): match_genex = re.compile(r"""\\\$""") replacements = { @@ -369,36 +350,54 @@ def _parse_deps(deps_list): match_dependencies = re.compile( r'''^set_target_properties\((\w+).*\n?\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) - components = {component: {} for component in self._llvm_components()} for llvm_lib, dependencies in match_dependencies.findall(cmake_exports): if llvm_lib in components: components[llvm_lib].update(_parse_deps(dependencies)) - return components + def _llvm_build_info(self): + cmake_config = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") - @property - def _components_data_file(self): - return Path(self.package_folder) / "lib" / "components.json" + match_cmake_var = re.compile(r"""^set\(LLVM_AVAILABLE_LIBS (?P.*)\)$""", re.MULTILINE) + match = match_cmake_var.search(cmake_config) + if match is None: + self.output.warning("Could not find components in LLVMConfig.cmake") + return None + + components = { component: {} for component in match.groupdict()["components"].split(";") } + self._update_component_dependencies(components) + + return { + "components": components, + "native_arch": re.search(r"""^set\(LLVM_NATIVE_ARCH (\S*)\)$""", cmake_config, re.MULTILINE).group(1) + } @property def _cmake_module_path(self): return Path("lib") / "cmake" / "llvm" + @property + def _build_info_file(self): + return Path(self.package_folder) / self._cmake_module_path / "conan_llvm_build_info.json" + @property def _build_module_file_rel_path(self): return self._cmake_module_path / f"conan-official-{self.name}-variables.cmake" - def _create_cmake_build_module(self, component_names, module_file): + def _create_cmake_build_module(self, build_info, module_file): package_folder = Path(self.package_folder) + targets_with_jit = ["X86", "PowerPC", "AArch64", "ARM", "Mips", "SystemZ"] content = textwrap.dedent(f"""\ set(LLVM_PACKAGE_VERSION "{self.version}") - set(LLVM_AVAILABLE_LIBS "{';'.join(component_names)}") + set(LLVM_AVAILABLE_LIBS "{';'.join(build_info['components'].keys())}") set(LLVM_BUILD_TYPE "{self.settings.build_type}") set(LLVM_CMAKE_DIR "{str(package_folder / "lib" / "cmake" / "llvm")}") set(LLVM_TOOLS_BINARY_DIR "{str(package_folder / "bin")}") set(LLVM_ALL_TARGETS "{self._all_targets}") set(LLVM_TARGETS_TO_BUILD "{self._targets_to_build}") + set(LLVM_TARGETS_WITH_JIT "{';'.join(targets_with_jit)}") + set(LLVM_NATIVE_ARCH "{build_info['native_arch']}") set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On) + set_property(GLOBAL PROPERTY LLVM_COMPONENT_LIBS ${{LLVM_AVAILABLE_LIBS}}) if (NOT TARGET intrinsics_gen) add_custom_target(intrinsics_gen) endif() @@ -411,15 +410,15 @@ def _create_cmake_build_module(self, component_names, module_file): """) save(self, module_file, content) - def _write_components(self): - components = self._component_dependencies() - with open(self._components_data_file, "w", encoding="utf-8") as fp: - json.dump(components, fp, indent=2) + def _write_build_info(self): + build_info = self._llvm_build_info() + with open(self._build_info_file, "w", encoding="utf-8") as fp: + json.dump(build_info, fp, indent=2) - return components + return build_info - def _read_components(self) -> dict: - with open(self._components_data_file, encoding="utf-8") as fp: + def _read_build_info(self) -> dict: + with open(self._build_info_file, encoding="utf-8") as fp: return json.load(fp) def package(self): @@ -427,9 +426,7 @@ def package(self): cmake = CMake(self) cmake.install() - components = {} - if not self.options.shared: - components = self._write_components() + build_info = self._write_build_info() package_folder = Path(self.package_folder) cmake_folder = package_folder / "lib" / "cmake" / "llvm" @@ -445,7 +442,7 @@ def package(self): rm(self, "*.a", package_folder / "lib") self._create_cmake_build_module( - components.keys(), + build_info, package_folder / self._build_module_file_rel_path ) @@ -462,7 +459,8 @@ def package_info(self): self.cpp_info.builddirs.append(self._cmake_module_path) if not self.options.shared: - components = self._read_components() + build_info = self._read_build_info() + components = build_info["components"] for component_name, data in components.items(): self.cpp_info.components[component_name].set_property("cmake_target_name", component_name) @@ -473,7 +471,6 @@ def package_info(self): system_libs = data.get("system_libs") if system_libs is not None: self.cpp_info.components[component_name].system_libs += system_libs - else: self.cpp_info.set_property("cmake_target_name", "LLVM") self.cpp_info.libs = collect_libs(self) diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index f1ee7c7b23b19..4de3810296f19 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -15,8 +15,8 @@ if (LLVM_SHARED) find_package(LLVM REQUIRED) target_link_libraries(${PROJECT_NAME} PRIVATE LLVM) else() - find_package(LLVM REQUIRED COMPONENTS LLVMInterpreter LLVMX86CodeGen LLVMIRReader) - llvm_map_components_to_libnames(llvm_libs interpreter x86codegen irreader) + find_package(LLVM REQUIRED) + llvm_map_components_to_libnames(llvm_libs interpreter nativecodegen irreader) target_link_libraries(${PROJECT_NAME} PRIVATE ${llvm_libs}) endif() @@ -27,3 +27,5 @@ test_llvm_cmake_variable(LLVM_CMAKE_DIR) test_llvm_cmake_variable(LLVM_TOOLS_BINARY_DIR) test_llvm_cmake_variable(LLVM_ALL_TARGETS) test_llvm_cmake_variable(LLVM_TARGETS_TO_BUILD) +test_llvm_cmake_variable(LLVM_TARGETS_WITH_JIT) +test_llvm_cmake_variable(LLVM_NATIVE_ARCH) From 0e05f9f319ed1a987e6552870d52bef0602a7c6a Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 20 Mar 2024 22:58:23 +0000 Subject: [PATCH 46/77] [llvm-core] add windows support --- recipes/llvm-core/all/conanfile.py | 46 +++++++++++++++---- .../patches/11x/0000-cmake-dependencies.patch | 32 +++++++++++-- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index e58ae22b27404..51cadf4bf64c4 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -12,7 +12,6 @@ save, copy, export_conandata_patches, - load, rm, rename, replace_in_file @@ -146,6 +145,7 @@ def _major_version(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + del self.options.with_libedit # not supported on windows if self._major_version < 14: del self.options.with_target_loongarch # experimental del self.options.with_target_ve # experimental @@ -160,7 +160,7 @@ def layout(self): def requirements(self): if self.options.with_ffi: self.requires("libffi/3.4.4") - if self.options.with_libedit: + if self.options.get_safe("with_libedit"): self.requires("editline/3.1") if self.options.with_zlib: self.requires("zlib/1.3.1") @@ -252,7 +252,7 @@ def generate(self): "LLVM_ENABLE_EXPENSIVE_CHECKS": self.options.expensive_checks, "LLVM_ENABLE_ASSERTIONS": self.settings.build_type, "LLVM_USE_PERF": self.options.use_perf, - "LLVM_ENABLE_LIBEDIT": self.options.with_libedit, + "LLVM_ENABLE_LIBEDIT": self.options.get_safe("with_libedit", False), "LLVM_ENABLE_Z3_SOLVER": self.options.with_z3, "LLVM_ENABLE_FFI": self.options.with_ffi, "LLVM_ENABLE_ZLIB": "FORCE_ON" if self.options.with_zlib else False, @@ -272,7 +272,17 @@ def generate(self): if is_msvc(self): build_type = str(self.settings.build_type).upper() - cmake_definitions[f"LLVM_USE_CRT_{build_type}"] = self.settings.compiler.runtime + if build_type in ["DEBUG", "RELWITHDEBINFO"]: + crt = { + "static": "MTd", + "dynamic": "MDd", + } + else: + crt = { + "static": "MT", + "dynamic": "MD", + } + cmake_definitions[f"LLVM_USE_CRT_{build_type}"] = crt[str(self.settings.compiler.runtime)] if not self.options.shared: cmake_definitions.update({ @@ -314,6 +324,12 @@ def build(self): def _is_windows(self): return self.settings.os == "Windows" + @staticmethod + def load(filename): + # regex fails on Windows when using conan's built in 'load' method + with open(filename, "r", encoding="utf-8")as fp: + return fp.read() + def _update_component_dependencies(self, components): def _sanitized_components(deps_list): match_genex = re.compile(r"""\\\$""") @@ -339,14 +355,26 @@ def _parse_deps(deps_list): "requires": [], "system_libs": [] } + windows_system_libs=[ + "ole32", + "delayimp", + "shell32", + "advapi32", + "-delayload:shell32.dll", + "uuid", + "psapi", + "-delayload:ole32.dll" + ] for component in _sanitized_components(deps_list): + if component in windows_system_libs: + continue if component in ["rt", "m", "dl", "pthread"]: data["system_libs"].append(component) else: data["requires"].append(component) return data - cmake_exports = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMExports.cmake") + cmake_exports = self.load(Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMExports.cmake") match_dependencies = re.compile( r'''^set_target_properties\((\w+).*\n?\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) @@ -355,7 +383,7 @@ def _parse_deps(deps_list): components[llvm_lib].update(_parse_deps(dependencies)) def _llvm_build_info(self): - cmake_config = load(self, Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") + cmake_config = self.load(Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") match_cmake_var = re.compile(r"""^set\(LLVM_AVAILABLE_LIBS (?P.*)\)$""", re.MULTILINE) match = match_cmake_var.search(cmake_config) @@ -384,14 +412,14 @@ def _build_module_file_rel_path(self): return self._cmake_module_path / f"conan-official-{self.name}-variables.cmake" def _create_cmake_build_module(self, build_info, module_file): - package_folder = Path(self.package_folder) targets_with_jit = ["X86", "PowerPC", "AArch64", "ARM", "Mips", "SystemZ"] content = textwrap.dedent(f"""\ + set(LLVM_TOOLS_BINARY_DIR "${{CMAKE_CURRENT_LIST_DIR}}/../../../bin") + cmake_path(NORMAL_PATH LLVM_TOOLS_BINARY_DIR) set(LLVM_PACKAGE_VERSION "{self.version}") set(LLVM_AVAILABLE_LIBS "{';'.join(build_info['components'].keys())}") set(LLVM_BUILD_TYPE "{self.settings.build_type}") - set(LLVM_CMAKE_DIR "{str(package_folder / "lib" / "cmake" / "llvm")}") - set(LLVM_TOOLS_BINARY_DIR "{str(package_folder / "bin")}") + set(LLVM_CMAKE_DIR "${{CMAKE_CURRENT_LIST_DIR}}") set(LLVM_ALL_TARGETS "{self._all_targets}") set(LLVM_TARGETS_TO_BUILD "{self._targets_to_build}") set(LLVM_TARGETS_WITH_JIT "{';'.join(targets_with_jit)}") diff --git a/recipes/llvm-core/all/patches/11x/0000-cmake-dependencies.patch b/recipes/llvm-core/all/patches/11x/0000-cmake-dependencies.patch index 5ea442b9e4926..3da6ed6f9b317 100644 --- a/recipes/llvm-core/all/patches/11x/0000-cmake-dependencies.patch +++ b/recipes/llvm-core/all/patches/11x/0000-cmake-dependencies.patch @@ -1,5 +1,5 @@ diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake -index 90e5d327c75..618b19b6a2d 100644 +index 90e5d327c75..c8bcb1afb76 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -5,6 +5,7 @@ endif() @@ -40,7 +40,7 @@ index 90e5d327c75..618b19b6a2d 100644 check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H) if(APPLE) include(CheckCSourceCompiles) -@@ -118,24 +133,23 @@ endif() +@@ -118,24 +133,21 @@ endif() # Don't look for these libraries if we're using MSan, since uninstrumented third # party code may call MSan interceptors like strlen, leading to false positives. if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") @@ -62,8 +62,8 @@ index 90e5d327c75..618b19b6a2d 100644 + cmake_pop_check_state() endif() - # Don't look for these libraries on Windows. - if (NOT PURE_WINDOWS) +- # Don't look for these libraries on Windows. +- if (NOT PURE_WINDOWS) # Skip libedit if using ASan as it contains memory leaks. if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*") + cmake_push_check_state() @@ -74,7 +74,29 @@ index 90e5d327c75..618b19b6a2d 100644 else() set(HAVE_LIBEDIT 0) endif() -@@ -517,7 +531,7 @@ else( LLVM_ENABLE_THREADS ) +@@ -157,19 +169,11 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + find_library(ICONV_LIBRARY_PATH NAMES iconv libiconv libiconv-2 c) + set(LLVM_LIBXML2_ENABLED 0) + set(LIBXML2_FOUND 0) +- if((LLVM_ENABLE_LIBXML2) AND ((CMAKE_SYSTEM_NAME MATCHES "Linux") AND (ICONV_LIBRARY_PATH) OR APPLE)) +- find_package(LibXml2) +- if (LIBXML2_FOUND) ++ if(LLVM_ENABLE_LIBXML2) ++ find_package(LibXml2 REQUIRED) + set(LLVM_LIBXML2_ENABLED 1) +- if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})) +- include_directories(${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}) +- else() +- include_directories(${LIBXML2_INCLUDE_DIR}) +- endif() +- endif() + endif() + endif() +-endif() + + if (LLVM_ENABLE_LIBXML2 STREQUAL "FORCE_ON" AND NOT LLVM_LIBXML2_ENABLED) + message(FATAL_ERROR "Failed to congifure libxml2") +@@ -517,7 +521,7 @@ else( LLVM_ENABLE_THREADS ) message(STATUS "Threads disabled.") endif() From 59caae7e425a49776d84423c9e41afff6d19793b Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 20 Mar 2024 23:53:32 +0000 Subject: [PATCH 47/77] [llvm-core] remove pdb files --- 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 51cadf4bf64c4..9b68e14267d47 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -461,6 +461,8 @@ def package(self): rm(self, "LLVMConfig.cmake", cmake_folder) rm(self, "LLVMExports*", cmake_folder) rm(self, "Find*", cmake_folder) + rm(self, "*.pdb", package_folder / "lib") + rm(self, "*.pdb", package_folder / "bin") # need to rename this as Conan will flag it, but it's not actually a Config file and is needed by # downstream packages rename(self, cmake_folder / "LLVM-Config.cmake", cmake_folder / "LLVM-ConfigInternal.cmake") From f5f03ec902ce2d6e564b9d00bf4e8c94cba51053 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 21 Mar 2024 08:51:28 +0000 Subject: [PATCH 48/77] [llvm-core] require cmake_path support in test package --- recipes/llvm-core/all/test_package/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/llvm-core/all/test_package/conanfile.py b/recipes/llvm-core/all/test_package/conanfile.py index acf43d80c5932..5ae2ff91c80a2 100644 --- a/recipes/llvm-core/all/test_package/conanfile.py +++ b/recipes/llvm-core/all/test_package/conanfile.py @@ -15,6 +15,10 @@ def layout(self): def requirements(self): self.requires(self.tested_reference_str) + def build_requirements(self): + # required for cmake_path support + self.tool_requires("cmake/[>=3.20 <4]") + def generate(self): deps = CMakeDeps(self) deps.check_components_exist = True From 5af042a64b99b844c8b60783b3f38c60b579800e Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 21 Mar 2024 22:27:37 +0000 Subject: [PATCH 49/77] [llvm-core] handle legacy conan msvcrt setting --- recipes/llvm-core/all/conanfile.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 9b68e14267d47..38409095fa157 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -228,6 +228,20 @@ def _all_targets(self): return ";".join( target for target in LLVM_TARGETS if self.options.get_safe(f"with_target_{target.lower()}") is not None) + @property + def _msvcrt(self): + msvcrt = str(self.settings.compiler.runtime) + # handle conan legacy setting + if msvcrt in ["MDd", "MTd", "MD", "MT"]: + return msvcrt + + if self.settings.build_type in ["Debug", "RelWithDebInfo"]: + crt = {"static": "MTd", "dynamic": "MDd"} + else: + crt = {"static": "MT", "dynamic": "MD"} + + return crt[msvcrt] + def generate(self): tc = CMakeToolchain(self, generator="Ninja") # https://releases.llvm.org/12.0.0/docs/CMake.html @@ -272,17 +286,7 @@ def generate(self): if is_msvc(self): build_type = str(self.settings.build_type).upper() - if build_type in ["DEBUG", "RELWITHDEBINFO"]: - crt = { - "static": "MTd", - "dynamic": "MDd", - } - else: - crt = { - "static": "MT", - "dynamic": "MD", - } - cmake_definitions[f"LLVM_USE_CRT_{build_type}"] = crt[str(self.settings.compiler.runtime)] + cmake_definitions[f"LLVM_USE_CRT_{build_type}"] = self._msvcrt if not self.options.shared: cmake_definitions.update({ From 3ce579f978712fccba461c2ee08cac1ef52694d5 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 22 Mar 2024 09:21:54 +0000 Subject: [PATCH 50/77] [llvm-core] missing patch type --- recipes/llvm-core/all/conandata.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 3fe429548be3c..5c0540ecd3a67 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -24,6 +24,7 @@ patches: - patch_file: patches/13x/0003-split-dwarf.patch patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 + patch_type: bugfix - patch_file: patches/13x/0004-no-build-with-install-rpath.patch patch_description: do not build shared libs with install rpath patch_type: conan From d445f230777b6a68ad1aa1b3ab4fb794e11a38e5 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 25 May 2024 18:05:12 +0100 Subject: [PATCH 51/77] Apply suggestions from code review Co-authored-by: Michael Keck --- 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 38409095fa157..1b02d628a2912 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -163,14 +163,14 @@ def requirements(self): if self.options.get_safe("with_libedit"): self.requires("editline/3.1") if self.options.with_zlib: - self.requires("zlib/1.3.1") + self.requires("zlib/[>=1.2.11 <2]") if self.options.with_xml2: - self.requires("libxml2/2.12.4") + self.requires("libxml2/[>=2.12.5 <3]") if self.options.with_z3: - self.requires("z3/4.12.4") + self.requires("z3/4.13.0") def build_requirements(self): - self.tool_requires("ninja/1.11.1") + self.tool_requires("ninja/1.12.1") def validate(self): if self.settings.compiler.cppstd: From 83e44ce3e3501f7393ebf4f61cb41ac213b15ccc Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 26 May 2024 20:31:57 +0100 Subject: [PATCH 52/77] [llvm-core] revert changes to license --- 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 1b02d628a2912..120be3e15e459 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -60,7 +60,7 @@ class LLVMCoreConan(ConanFile): "A toolkit for the construction of highly optimized compilers," "optimizers, and runtime environments." ) - license = "LLVM-exception" + license = "Apache-2.0 WITH LLVM-exception" topics = ("llvm", "compiler") homepage = "https://llvm.org" url = "https://github.com/conan-io/conan-center-index" From 4c50124dc6d0d84b364e22fbf286363e12cf66e4 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 28 May 2024 16:33:11 +0100 Subject: [PATCH 53/77] [llvm-core] apply review suggestions --- recipes/llvm-core/all/conanfile.py | 44 ++++++++++-------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 120be3e15e459..5c11de3471ffb 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -16,7 +16,7 @@ rename, replace_in_file ) -from conan.tools.microsoft import is_msvc +from conan.tools.microsoft import is_msvc, msvc_runtime_flag from conan.tools.scm import Version import json @@ -28,7 +28,7 @@ required_conan_version = ">=1.62.0" -# LLVM's default config is enable all targets, but end users can significantly reduce +# LLVM's default config is to enable all targets, but end users can significantly reduce # build times for the package by disabling the ones they don't need with the corresponding option # `-o llvm-core/*:with_target_=False` LLVM_TARGETS = [ @@ -145,7 +145,7 @@ def _major_version(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - del self.options.with_libedit # not supported on windows + del self.options.with_libedit # not supported on windows if self._major_version < 14: del self.options.with_target_loongarch # experimental del self.options.with_target_ve # experimental @@ -183,7 +183,7 @@ def validate(self): if self.options.shared: if self._is_windows: - raise ConanInvalidConfiguration("Shared builds not currently supported on Windows") + raise ConanInvalidConfiguration("Shared builds are currently not supported on Windows") if os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug": raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") if is_apple_os(self): @@ -200,7 +200,7 @@ def validate(self): if cross_building(self): # FIXME support cross compilation, at least for common cases like Apple Silicon -> X86 # requires a host-compiled version of llvm-tablegen - raise ConanInvalidConfiguration("Cross compilation is not supported") + raise ConanInvalidConfiguration("Cross compilation is not supported. Contributions are welcome!") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -228,25 +228,11 @@ def _all_targets(self): return ";".join( target for target in LLVM_TARGETS if self.options.get_safe(f"with_target_{target.lower()}") is not None) - @property - def _msvcrt(self): - msvcrt = str(self.settings.compiler.runtime) - # handle conan legacy setting - if msvcrt in ["MDd", "MTd", "MD", "MT"]: - return msvcrt - - if self.settings.build_type in ["Debug", "RelWithDebInfo"]: - crt = {"static": "MTd", "dynamic": "MDd"} - else: - crt = {"static": "MT", "dynamic": "MD"} - - return crt[msvcrt] - def generate(self): tc = CMakeToolchain(self, generator="Ninja") # https://releases.llvm.org/12.0.0/docs/CMake.html # https://releases.llvm.org/13.0.0/docs/CMake.html - cmake_definitions = { + cmake_variables = { "LLVM_TARGETS_TO_BUILD": self._targets_to_build, # See comment below on LLVM shared library builds "LLVM_BUILD_LLVM_DYLIB": self.options.shared, @@ -274,7 +260,7 @@ def generate(self): "LLVM_ENABLE_TERMINFO": self.options.with_terminfo } - self._apply_resource_limits(cmake_definitions) + self._apply_resource_limits(cmake_variables) # this capability is back-ported from LLVM 14.x is_platform_ELF_based = self.settings.os in [ @@ -282,24 +268,24 @@ def generate(self): ] if is_platform_ELF_based: self.output.info("ELF Platform Detected, optimizing memory usage during debug build linking.") - cmake_definitions["LLVM_USE_SPLIT_DWARF"] = True + cmake_variables["LLVM_USE_SPLIT_DWARF"] = True if is_msvc(self): build_type = str(self.settings.build_type).upper() - cmake_definitions[f"LLVM_USE_CRT_{build_type}"] = self._msvcrt + cmake_variables[f"LLVM_USE_CRT_{build_type}"] = msvc_runtime_flag(self) if not self.options.shared: - cmake_definitions.update({ + cmake_variables.update({ "DISABLE_LLVM_LINK_LLVM_DYLIB": True, "LLVM_ENABLE_PIC": self.options.get_safe("fPIC", default=False) }) if self.options.use_sanitizer == "None": - cmake_definitions["LLVM_USE_SANITIZER"] = "" + cmake_variables["LLVM_USE_SANITIZER"] = "" else: - cmake_definitions["LLVM_USE_SANITIZER"] = self.options.use_sanitizer + cmake_variables["LLVM_USE_SANITIZER"] = self.options.use_sanitizer - tc.variables.update(cmake_definitions) + tc.variables.update(cmake_variables) tc.cache_variables.update({ # Enables LLVM to find conan libraries during try_compile "CMAKE_TRY_COMPILE_CONFIGURATION": str(self.settings.build_type), @@ -359,7 +345,7 @@ def _parse_deps(deps_list): "requires": [], "system_libs": [] } - windows_system_libs=[ + windows_system_libs = [ "ole32", "delayimp", "shell32", @@ -395,7 +381,7 @@ def _llvm_build_info(self): self.output.warning("Could not find components in LLVMConfig.cmake") return None - components = { component: {} for component in match.groupdict()["components"].split(";") } + components = {component: {} for component in match.groupdict()["components"].split(";")} self._update_component_dependencies(components) return { From 53833109f1e91c330b076ce672f12577217b8274 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 8 Aug 2024 19:26:39 +0100 Subject: [PATCH 54/77] [llvm-core] add patch source for include file fix --- recipes/llvm-core/all/conandata.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 5c0540ecd3a67..aaca1f397cecb 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -21,6 +21,7 @@ patches: - patch_file: patches/13x/0002-missing-includes.patch patch_description: fix missing header files patch_type: portability + patch_source: https://github.com/llvm/llvm-project-release-prs/pull/3 - patch_file: patches/13x/0003-split-dwarf.patch patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 @@ -39,6 +40,7 @@ patches: - patch_file: patches/12x/0002-missing-includes.patch patch_description: fix missing header files patch_type: portability + patch_source: https://github.com/llvm/llvm-project-release-prs/pull/3 - patch_file: patches/12x/0003-split-dwarf.patch patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 @@ -57,6 +59,7 @@ patches: - patch_file: patches/11x/0002-missing-includes.patch patch_description: fix missing header files patch_type: portability + patch_source: https://github.com/llvm/llvm-project-release-prs/pull/3 - patch_file: patches/11x/0003-split-dwarf.patch patch_description: enable split dwarf option from 14.x patch_source: https://reviews.llvm.org/D108776 From 1402f418a18a21d5e6ade8411641d0d4bbe92930 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 8 Aug 2024 19:42:26 +0100 Subject: [PATCH 55/77] [llvm-core] use user-config for compiler resource settings --- recipes/llvm-core/all/conanfile.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 5c11de3471ffb..b0437ed9c921b 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -93,8 +93,6 @@ class LLVMCoreConan(ConanFile): "with_zlib": [True, False], "with_xml2": [True, False], "with_z3": [True, False], - "ram_per_compile_job": ["ANY"], - "ram_per_link_job": ["ANY"], } options.update({f"with_target_{target.lower()}": [True, False] for target in LLVM_TARGETS}) default_options = { @@ -116,8 +114,6 @@ class LLVMCoreConan(ConanFile): "with_xml2": True, "with_z3": True, "with_zlib": True, - "ram_per_compile_job": "auto", - "ram_per_link_job": "auto" } default_options.update({f"with_target_{target.lower()}": True for target in LLVM_TARGETS}) @@ -213,10 +209,13 @@ def _apply_resource_limits(self, cmake_definitions): "LLVM_RAM_PER_COMPILE_JOB": "2048" }) else: - if self.options.ram_per_compile_job != "auto": - cmake_definitions["LLVM_RAM_PER_COMPILE_JOB"] = self.options.ram_per_compile_job - if self.options.ram_per_link_job != "auto": - cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = self.options.ram_per_link_job + ram_per_compile_job = self.conf.get("user.llvm-core:ram_per_compile_job") + if ram_per_compile_job: + cmake_definitions["LLVM_RAM_PER_COMPILE_JOB"] = ram_per_compile_job + + ram_per_link_job = self.conf.get("user.llvm-core:ram_per_link_job") + if ram_per_link_job: + cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = ram_per_link_job @property def _targets_to_build(self): @@ -466,10 +465,6 @@ def package(self): package_folder / self._build_module_file_rel_path ) - def package_id(self): - del self.info.options.ram_per_compile_job - del self.info.options.ram_per_link_job - def package_info(self): self.cpp_info.set_property("cmake_file_name", "LLVM") self.cpp_info.set_property("cmake_build_modules", From 9135932bf5009a63601051cc6127349eb0dfc81f Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 8 Aug 2024 19:46:04 +0100 Subject: [PATCH 56/77] [llvm-core] add link for further info on cross compilation --- recipes/llvm-core/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index b0437ed9c921b..11abae06a44b2 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -195,7 +195,8 @@ def validate(self): if cross_building(self): # FIXME support cross compilation, at least for common cases like Apple Silicon -> X86 - # requires a host-compiled version of llvm-tablegen + # requires a host-compiled version of llvm-tablegen. + # see also https://llvm.org/docs/HowToCrossCompileLLVM.html raise ConanInvalidConfiguration("Cross compilation is not supported. Contributions are welcome!") def source(self): From 41a9cd9faeb8eda78f1746aac8459f821c2533cf Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 8 Aug 2024 19:54:36 +0100 Subject: [PATCH 57/77] [llvm-core] use PurePosixPath only --- recipes/llvm-core/all/conanfile.py | 34 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 11abae06a44b2..ce8253df73d35 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -9,6 +9,7 @@ collect_libs, get, rmdir, + load, save, copy, export_conandata_patches, @@ -21,7 +22,7 @@ import json import os -from pathlib import Path +from pathlib import PurePosixPath import re import textwrap @@ -314,11 +315,9 @@ def build(self): def _is_windows(self): return self.settings.os == "Windows" - @staticmethod - def load(filename): - # regex fails on Windows when using conan's built in 'load' method - with open(filename, "r", encoding="utf-8")as fp: - return fp.read() + @property + def _package_folder_path(self): + return PurePosixPath(self.package_folder) def _update_component_dependencies(self, components): def _sanitized_components(deps_list): @@ -364,7 +363,7 @@ def _parse_deps(deps_list): data["requires"].append(component) return data - cmake_exports = self.load(Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMExports.cmake") + cmake_exports = load(self, self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMExports.cmake") match_dependencies = re.compile( r'''^set_target_properties\((\w+).*\n?\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) @@ -373,7 +372,7 @@ def _parse_deps(deps_list): components[llvm_lib].update(_parse_deps(dependencies)) def _llvm_build_info(self): - cmake_config = self.load(Path(self.package_folder) / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") + cmake_config = load(self, self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") match_cmake_var = re.compile(r"""^set\(LLVM_AVAILABLE_LIBS (?P.*)\)$""", re.MULTILINE) match = match_cmake_var.search(cmake_config) @@ -391,11 +390,11 @@ def _llvm_build_info(self): @property def _cmake_module_path(self): - return Path("lib") / "cmake" / "llvm" + return PurePosixPath("lib") / "cmake" / "llvm" @property def _build_info_file(self): - return Path(self.package_folder) / self._cmake_module_path / "conan_llvm_build_info.json" + return self._package_folder_path / self._cmake_module_path / "conan_llvm_build_info.json" @property def _build_module_file_rel_path(self): @@ -440,30 +439,29 @@ def _read_build_info(self) -> dict: return json.load(fp) def package(self): - copy(self, "LICENSE.TXT", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy(self, "LICENSE.TXT", self.source_folder, self._package_folder_path / "licences") cmake = CMake(self) cmake.install() build_info = self._write_build_info() - package_folder = Path(self.package_folder) - cmake_folder = package_folder / "lib" / "cmake" / "llvm" + cmake_folder = self._package_folder_path / "lib" / "cmake" / "llvm" rm(self, "LLVMConfig.cmake", cmake_folder) rm(self, "LLVMExports*", cmake_folder) rm(self, "Find*", cmake_folder) - rm(self, "*.pdb", package_folder / "lib") - rm(self, "*.pdb", package_folder / "bin") + rm(self, "*.pdb", self._package_folder_path / "lib") + rm(self, "*.pdb", self._package_folder_path / "bin") # need to rename this as Conan will flag it, but it's not actually a Config file and is needed by # downstream packages rename(self, cmake_folder / "LLVM-Config.cmake", cmake_folder / "LLVM-ConfigInternal.cmake") replace_in_file(self, cmake_folder / "AddLLVM.cmake", "LLVM-Config", "LLVM-ConfigInternal") - rmdir(self, package_folder / "share") + rmdir(self, self._package_folder_path / "share") if self.options.shared: - rm(self, "*.a", package_folder / "lib") + rm(self, "*.a", self._package_folder_path / "lib") self._create_cmake_build_module( build_info, - package_folder / self._build_module_file_rel_path + self._package_folder_path / self._build_module_file_rel_path ) def package_info(self): From 2ed5ee9101f2f986930d93014ae9ad12bb8fe358 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Mon, 19 Aug 2024 07:11:03 +0200 Subject: [PATCH 58/77] Trying 'as_posix()' function --- recipes/llvm-core/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index ce8253df73d35..7a79de4baa24f 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -363,7 +363,7 @@ def _parse_deps(deps_list): data["requires"].append(component) return data - cmake_exports = load(self, self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMExports.cmake") + cmake_exports = load(self, (self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMExports.cmake").as_posix()) match_dependencies = re.compile( r'''^set_target_properties\((\w+).*\n?\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) @@ -372,7 +372,7 @@ def _parse_deps(deps_list): components[llvm_lib].update(_parse_deps(dependencies)) def _llvm_build_info(self): - cmake_config = load(self, self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake") + cmake_config = load(self, (self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake").as_posix()) match_cmake_var = re.compile(r"""^set\(LLVM_AVAILABLE_LIBS (?P.*)\)$""", re.MULTILINE) match = match_cmake_var.search(cmake_config) From 6f8a4e284adf53104ae52e3985d91544520dbf8e Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Mon, 19 Aug 2024 11:37:49 +0200 Subject: [PATCH 59/77] More 'as_posix()' function --- recipes/llvm-core/all/conanfile.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 7a79de4baa24f..c60872eeb55f6 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -439,36 +439,37 @@ def _read_build_info(self) -> dict: return json.load(fp) def package(self): - copy(self, "LICENSE.TXT", self.source_folder, self._package_folder_path / "licences") + copy(self, "LICENSE.TXT", self.source_folder, (self._package_folder_path / "licences").as_posix()) cmake = CMake(self) cmake.install() build_info = self._write_build_info() cmake_folder = self._package_folder_path / "lib" / "cmake" / "llvm" - rm(self, "LLVMConfig.cmake", cmake_folder) - rm(self, "LLVMExports*", cmake_folder) - rm(self, "Find*", cmake_folder) - rm(self, "*.pdb", self._package_folder_path / "lib") - rm(self, "*.pdb", self._package_folder_path / "bin") + cmake_folder_posix = cmake_folder.as_posix() + rm(self, "LLVMConfig.cmake", cmake_folder_posix) + rm(self, "LLVMExports*", cmake_folder_posix) + rm(self, "Find*", cmake_folder_posix) + rm(self, "*.pdb", (self._package_folder_path / "lib").as_posix()) + rm(self, "*.pdb", (self._package_folder_path / "bin").as_posix()) # need to rename this as Conan will flag it, but it's not actually a Config file and is needed by # downstream packages - rename(self, cmake_folder / "LLVM-Config.cmake", cmake_folder / "LLVM-ConfigInternal.cmake") - replace_in_file(self, cmake_folder / "AddLLVM.cmake", "LLVM-Config", "LLVM-ConfigInternal") - rmdir(self, self._package_folder_path / "share") + rename(self, (cmake_folder / "LLVM-Config.cmake").as_posix(), (cmake_folder / "LLVM-ConfigInternal.cmake").as_posix()) + replace_in_file(self, (cmake_folder / "AddLLVM.cmake").as_posix(), "LLVM-Config", "LLVM-ConfigInternal") + rmdir(self, (self._package_folder_path / "share").as_posix()) if self.options.shared: - rm(self, "*.a", self._package_folder_path / "lib") + rm(self, "*.a", (self._package_folder_path / "lib").as_posix()) self._create_cmake_build_module( build_info, - self._package_folder_path / self._build_module_file_rel_path + (self._package_folder_path / self._build_module_file_rel_path).as_posix() ) def package_info(self): self.cpp_info.set_property("cmake_file_name", "LLVM") self.cpp_info.set_property("cmake_build_modules", [self._build_module_file_rel_path, - self._cmake_module_path / "LLVM-ConfigInternal.cmake"] + (self._cmake_module_path / "LLVM-ConfigInternal.cmake").as_posix()] ) self.cpp_info.builddirs.append(self._cmake_module_path) From 9d8bf0ccb1b964c8bebe34526fabe18856d97ffd Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Tue, 20 Aug 2024 08:39:22 +0200 Subject: [PATCH 60/77] Typo --- 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 c60872eeb55f6..1aeb246d9d96c 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -439,7 +439,7 @@ def _read_build_info(self) -> dict: return json.load(fp) def package(self): - copy(self, "LICENSE.TXT", self.source_folder, (self._package_folder_path / "licences").as_posix()) + copy(self, "LICENSE.TXT", self.source_folder, (self._package_folder_path / "licenses").as_posix()) cmake = CMake(self) cmake.install() From 9f54096b130d78aaaaab6764c2c360d8675e66df Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 27 Aug 2024 08:40:44 +0100 Subject: [PATCH 61/77] [llvm-core] revert usage of 'load' to workaround regex error --- recipes/llvm-core/all/conanfile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 1aeb246d9d96c..abd62d46c8398 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -9,7 +9,6 @@ collect_libs, get, rmdir, - load, save, copy, export_conandata_patches, @@ -22,7 +21,7 @@ import json import os -from pathlib import PurePosixPath +from pathlib import Path import re import textwrap @@ -317,7 +316,7 @@ def _is_windows(self): @property def _package_folder_path(self): - return PurePosixPath(self.package_folder) + return Path(self.package_folder) def _update_component_dependencies(self, components): def _sanitized_components(deps_list): @@ -363,7 +362,8 @@ def _parse_deps(deps_list): data["requires"].append(component) return data - cmake_exports = load(self, (self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMExports.cmake").as_posix()) + # Can't use tools.files.load due to CRLF endings on Windows causing issues with Regular Expressions + cmake_exports = (self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMExports.cmake").read_text("utf-8") match_dependencies = re.compile( r'''^set_target_properties\((\w+).*\n?\s*INTERFACE_LINK_LIBRARIES\s+"(\S+)"''', re.MULTILINE) @@ -372,7 +372,7 @@ def _parse_deps(deps_list): components[llvm_lib].update(_parse_deps(dependencies)) def _llvm_build_info(self): - cmake_config = load(self, (self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake").as_posix()) + cmake_config = (self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake").read_text("utf-8") match_cmake_var = re.compile(r"""^set\(LLVM_AVAILABLE_LIBS (?P.*)\)$""", re.MULTILINE) match = match_cmake_var.search(cmake_config) @@ -390,7 +390,7 @@ def _llvm_build_info(self): @property def _cmake_module_path(self): - return PurePosixPath("lib") / "cmake" / "llvm" + return Path("lib") / "cmake" / "llvm" @property def _build_info_file(self): From 7b2e085e572c3a6517d8af7e1cd66e2fa0a5dfc8 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 27 Aug 2024 08:42:02 +0100 Subject: [PATCH 62/77] [llvm-core] try relaxing restrictions on cross-building --- recipes/llvm-core/all/conanfile.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index abd62d46c8398..bd6d6b0d13b24 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os -from conan.tools.build import check_min_cppstd, can_run, cross_building +from conan.tools.build import check_min_cppstd, can_run from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.env import VirtualRunEnv from conan.tools.files import ( @@ -193,12 +193,6 @@ def validate(self): if self.options.exceptions and not self.options.rtti: raise ConanInvalidConfiguration("Cannot enable exceptions without rtti support") - if cross_building(self): - # FIXME support cross compilation, at least for common cases like Apple Silicon -> X86 - # requires a host-compiled version of llvm-tablegen. - # see also https://llvm.org/docs/HowToCrossCompileLLVM.html - raise ConanInvalidConfiguration("Cross compilation is not supported. Contributions are welcome!") - def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) From 0b1581669f6fd6dcf5b04bdbfd3b75c8647c6894 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 27 Aug 2024 09:03:48 +0100 Subject: [PATCH 63/77] [llvm-core] use semi-colon separated string for targets instead of individual options --- recipes/llvm-core/all/conanfile.py | 48 ++++++++++++------------------ 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index bd6d6b0d13b24..58c8412506957 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -29,9 +29,9 @@ required_conan_version = ">=1.62.0" # LLVM's default config is to enable all targets, but end users can significantly reduce -# build times for the package by disabling the ones they don't need with the corresponding option -# `-o llvm-core/*:with_target_=False` -LLVM_TARGETS = [ +# build times for the package by specifying only the targets they need as a +# semi-colon delimited string in the value of the 'targets' option +LLVM_TARGETS = { "AArch64", "AMDGPU", "ARM", @@ -51,7 +51,7 @@ "WebAssembly", "X86", "XCore" -] +} class LLVMCoreConan(ConanFile): @@ -69,6 +69,7 @@ class LLVMCoreConan(ConanFile): "shared": [True, False], "fPIC": [True, False], "components": ["ANY"], + "targets": ["ANY"], "exceptions": [True, False], "rtti": [True, False], "threads": [True, False], @@ -94,11 +95,11 @@ class LLVMCoreConan(ConanFile): "with_xml2": [True, False], "with_z3": [True, False], } - options.update({f"with_target_{target.lower()}": [True, False] for target in LLVM_TARGETS}) default_options = { "shared": False, "fPIC": True, "components": "all", + "targets": "all", "exceptions": True, "rtti": True, "threads": True, @@ -115,7 +116,6 @@ class LLVMCoreConan(ConanFile): "with_z3": True, "with_zlib": True, } - default_options.update({f"with_target_{target.lower()}": True for target in LLVM_TARGETS}) @property def _min_cppstd(self): @@ -134,17 +134,10 @@ def _compilers_minimum_version(self): def export_sources(self): export_conandata_patches(self) - @property - def _major_version(self): - return Version(self.version).major - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC del self.options.with_libedit # not supported on windows - if self._major_version < 14: - del self.options.with_target_loongarch # experimental - del self.options.with_target_ve # experimental def configure(self): if self.options.shared: @@ -214,21 +207,25 @@ def _apply_resource_limits(self, cmake_definitions): @property def _targets_to_build(self): - return ";".join(target for target in LLVM_TARGETS if self.options.get_safe(f"with_target_{target.lower()}")) + return self.options.targets if self.options.targets != "all" else self._all_targets @property def _all_targets(self): - # This is not just LLVM_TARGETS as it is version specific - return ";".join( - target for target in LLVM_TARGETS if self.options.get_safe(f"with_target_{target.lower()}") is not None) + targets = LLVM_TARGETS if Version(self.version) >= "14" else LLVM_TARGETS - {"LoongArch", "VE"} + return ";".join(targets) def generate(self): tc = CMakeToolchain(self, generator="Ninja") # https://releases.llvm.org/12.0.0/docs/CMake.html # https://releases.llvm.org/13.0.0/docs/CMake.html cmake_variables = { - "LLVM_TARGETS_TO_BUILD": self._targets_to_build, - # See comment below on LLVM shared library builds + # Enables LLVM to find conan libraries during try_compile + "CMAKE_TRY_COMPILE_CONFIGURATION": str(self.settings.build_type), + # LLVM has two separate concepts of a "shared library build". + # "BUILD_SHARED_LIBS" builds shared versions of all the static components + # "LLVM_BUILD_LLVM_DYLIB" builds a single shared library containing all components. + # It is likely the latter that the user expects by a "shared library" build. + "BUILD_SHARED_LIBS": False, "LLVM_BUILD_LLVM_DYLIB": self.options.shared, "LLVM_LINK_LLVM_DYLIB": self.options.shared, "LLVM_DYLIB_COMPONENTS": self.options.components, @@ -253,6 +250,8 @@ def generate(self): "LLVM_ENABLE_LIBXML2": "FORCE_ON" if self.options.with_xml2 else False, "LLVM_ENABLE_TERMINFO": self.options.with_terminfo } + if self.options.targets != "all": + cmake_variables["LLVM_TARGETS_TO_BUILD"] = self.options.targets self._apply_resource_limits(cmake_variables) @@ -279,16 +278,7 @@ def generate(self): else: cmake_variables["LLVM_USE_SANITIZER"] = self.options.use_sanitizer - tc.variables.update(cmake_variables) - tc.cache_variables.update({ - # Enables LLVM to find conan libraries during try_compile - "CMAKE_TRY_COMPILE_CONFIGURATION": str(self.settings.build_type), - # LLVM has two separate concepts of a "shared library build". - # "BUILD_SHARED_LIBS" builds shared versions of all the static components - # "LLVM_BUILD_LLVM_DYLIB" builds a single shared library containing all components. - # It is likely the latter that the user expects by a "shared library" build. - "BUILD_SHARED_LIBS": False - }) + tc.cache_variables.update(cmake_variables) tc.generate() tc = CMakeDeps(self) From 145f2f0f812dd96f00ca2d27e7c4affaa4fbba80 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 27 Aug 2024 09:04:53 +0100 Subject: [PATCH 64/77] [llvm-core] set default fPIC fallback to 'True' --- 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 58c8412506957..855a326d659a9 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -270,7 +270,7 @@ def generate(self): if not self.options.shared: cmake_variables.update({ "DISABLE_LLVM_LINK_LLVM_DYLIB": True, - "LLVM_ENABLE_PIC": self.options.get_safe("fPIC", default=False) + "LLVM_ENABLE_PIC": self.options.get_safe("fPIC", default=True) }) if self.options.use_sanitizer == "None": From 33d3fcf37687515a3f381f9404169eb83b45060b Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 27 Aug 2024 09:08:17 +0100 Subject: [PATCH 65/77] [llvm-core] use version range for ninja --- recipes/llvm-core/all/conanfile.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 855a326d659a9..109c3447874b1 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -159,7 +159,7 @@ def requirements(self): self.requires("z3/4.13.0") def build_requirements(self): - self.tool_requires("ninja/1.12.1") + self.tool_requires("ninja/[>=1.10.2 <2]") def validate(self): if self.settings.compiler.cppstd: @@ -171,7 +171,7 @@ def validate(self): ) if self.options.shared: - if self._is_windows: + if self.settings.os == "Windows": raise ConanInvalidConfiguration("Shared builds are currently not supported on Windows") if os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug": raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") @@ -211,7 +211,7 @@ def _targets_to_build(self): @property def _all_targets(self): - targets = LLVM_TARGETS if Version(self.version) >= "14" else LLVM_TARGETS - {"LoongArch", "VE"} + targets = LLVM_TARGETS if Version(self.version) >= 14 else LLVM_TARGETS - {"LoongArch", "VE"} return ";".join(targets) def generate(self): @@ -294,10 +294,6 @@ def build(self): cmake.configure() cmake.build() - @property - def _is_windows(self): - return self.settings.os == "Windows" - @property def _package_folder_path(self): return Path(self.package_folder) From af433da69ba5b5b6471bbf49f0b17db1c3e36f69 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 27 Aug 2024 09:10:05 +0100 Subject: [PATCH 66/77] [llvm-core] move cci check to 'validate_build' --- 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 109c3447874b1..b5f42d30b4c7a 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -173,8 +173,6 @@ def validate(self): if self.options.shared: if self.settings.os == "Windows": raise ConanInvalidConfiguration("Shared builds are currently not supported on Windows") - if os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug": - raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") if is_apple_os(self): # FIXME iconv contains duplicate symbols in the libiconv and libcharset libraries (both of which are # provided by libiconv). This may be an issue with how conan packages libiconv @@ -186,6 +184,10 @@ def validate(self): if self.options.exceptions and not self.options.rtti: raise ConanInvalidConfiguration("Cannot enable exceptions without rtti support") + def validate_build(self): + if self.options.shared and os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug": + raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) From e01fc0f8c347b5445a513bb8f7cb111c79ef7143 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 27 Aug 2024 09:20:30 +0100 Subject: [PATCH 67/77] [llvm-core] allow CCI to use llvm-core user config for resource limits --- recipes/llvm-core/all/conanfile.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index b5f42d30b4c7a..296d72b9e2021 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -194,18 +194,19 @@ def source(self): def _apply_resource_limits(self, cmake_definitions): if os.getenv("CONAN_CENTER_BUILD_SERVICE"): self.output.info("Applying CCI Resource Limits") - cmake_definitions.update({ - "LLVM_RAM_PER_LINK_JOB": "16384", - "LLVM_RAM_PER_COMPILE_JOB": "2048" - }) + default_ram_per_compile_job = 16384 + default_ram_per_link_job = 2048 else: - ram_per_compile_job = self.conf.get("user.llvm-core:ram_per_compile_job") - if ram_per_compile_job: - cmake_definitions["LLVM_RAM_PER_COMPILE_JOB"] = ram_per_compile_job + default_ram_per_compile_job = None + default_ram_per_link_job = None + + ram_per_compile_job = self.conf.get("user.llvm-core:ram_per_compile_job", default_ram_per_compile_job) + if ram_per_compile_job: + cmake_definitions["LLVM_RAM_PER_COMPILE_JOB"] = ram_per_compile_job - ram_per_link_job = self.conf.get("user.llvm-core:ram_per_link_job") - if ram_per_link_job: - cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = ram_per_link_job + ram_per_link_job = self.conf.get("user.llvm-core:ram_per_link_job", default_ram_per_link_job) + if ram_per_link_job: + cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = ram_per_link_job @property def _targets_to_build(self): From 49b1cc846d8b9b50193076c13977eab3a0154fc9 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 27 Aug 2024 09:21:32 +0100 Subject: [PATCH 68/77] [llvm-core] dont activate build environment for llvm-tblgen --- recipes/llvm-core/all/conanfile.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 296d72b9e2021..2b76cfc0039e0 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -244,7 +244,7 @@ def generate(self): "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, + "LLVM_ENABLE_ASSERTIONS": str(self.settings.build_type), "LLVM_USE_PERF": self.options.use_perf, "LLVM_ENABLE_LIBEDIT": self.options.get_safe("with_libedit", False), "LLVM_ENABLE_Z3_SOLVER": self.options.with_z3, @@ -281,16 +281,13 @@ def generate(self): else: cmake_variables["LLVM_USE_SANITIZER"] = self.options.use_sanitizer + self.output.info(cmake_variables) tc.cache_variables.update(cmake_variables) tc.generate() tc = CMakeDeps(self) tc.generate() - if can_run(self): - # For running llvm-tblgen during the build - VirtualRunEnv(self).generate(scope="build") - def build(self): apply_conandata_patches(self) cmake = CMake(self) From 149c9a992675b55d60d36cd1ebe1d675e74cb06a Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 1 Sep 2024 20:19:47 +0100 Subject: [PATCH 69/77] [llvm-core] add patch for link failure with lld --- recipes/llvm-core/all/conandata.yml | 12 +++++++ .../patches/11x/0005-remove-lto-exports.patch | 32 +++++++++++++++++++ .../patches/12x/0005-remove-lto-exports.patch | 32 +++++++++++++++++++ .../patches/13x/0005-remove-lto-exports.patch | 32 +++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 recipes/llvm-core/all/patches/11x/0005-remove-lto-exports.patch create mode 100644 recipes/llvm-core/all/patches/12x/0005-remove-lto-exports.patch create mode 100644 recipes/llvm-core/all/patches/13x/0005-remove-lto-exports.patch diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index aaca1f397cecb..8b85563961401 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -29,6 +29,10 @@ patches: - patch_file: patches/13x/0004-no-build-with-install-rpath.patch patch_description: do not build shared libs with install rpath patch_type: conan + - patch_file: patches/13x/0005-remove-lto-exports.patch + patch_description: remove LTO exports causing link error with lld + patch_source: https://github.com/llvm/llvm-project-release-prs/pull/279 + patch_type: portability "12.0.0": - patch_file: patches/12x/0000-cmake-dependencies.patch patch_description: fix references to third party libs to match conan variables and targets @@ -48,6 +52,10 @@ patches: - patch_file: patches/12x/0004-no-build-with-install-rpath.patch patch_description: do not build shared libs with install rpath patch_type: conan + - patch_file: patches/12x/0005-remove-lto-exports.patch + patch_description: remove LTO exports causing link error with lld + patch_source: https://github.com/llvm/llvm-project-release-prs/pull/279 + patch_type: portability "11.1.0": - patch_file: patches/11x/0000-cmake-dependencies.patch patch_description: fix references to third party libs to match conan variables and targets @@ -67,3 +75,7 @@ patches: - patch_file: patches/11x/0004-no-build-with-install-rpath.patch patch_description: do not build shared libs with install rpath patch_type: conan + - patch_file: patches/11x/0005-remove-lto-exports.patch + patch_description: remove LTO exports causing link error with lld + patch_source: https://github.com/llvm/llvm-project-release-prs/pull/279 + patch_type: portability diff --git a/recipes/llvm-core/all/patches/11x/0005-remove-lto-exports.patch b/recipes/llvm-core/all/patches/11x/0005-remove-lto-exports.patch new file mode 100644 index 0000000000000..6dea8a2419a11 --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/0005-remove-lto-exports.patch @@ -0,0 +1,32 @@ +diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports +index 1f0a6b23d3fd..2871abd34e40 100644 +--- a/tools/lto/lto.exports ++++ b/tools/lto/lto.exports +@@ -43,12 +43,6 @@ lto_codegen_optimize + lto_codegen_compile_optimized + lto_codegen_set_should_internalize + lto_codegen_set_should_embed_uselists +-LLVMCreateDisasm +-LLVMCreateDisasmCPU +-LLVMDisasmDispose +-LLVMDisasmInstruction +-LLVMSetDisasmOptions +-LLVMCreateDisasmCPUFeatures + thinlto_create_codegen + thinlto_codegen_dispose + thinlto_codegen_add_module +diff --git a/tools/remarks-shlib/CMakeLists.txt b/tools/remarks-shlib/CMakeLists.txt +index e948496c603a..97bc45e110dc 100644 +--- a/tools/remarks-shlib/CMakeLists.txt ++++ b/tools/remarks-shlib/CMakeLists.txt +@@ -6,7 +6,9 @@ set(SOURCES + libremarks.cpp + ) + +-set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports) ++if (NOT (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB)) ++ set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports) ++endif() + + add_llvm_library(Remarks SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES}) + diff --git a/recipes/llvm-core/all/patches/12x/0005-remove-lto-exports.patch b/recipes/llvm-core/all/patches/12x/0005-remove-lto-exports.patch new file mode 100644 index 0000000000000..60db5a636b646 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/0005-remove-lto-exports.patch @@ -0,0 +1,32 @@ +diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports +index 1f0a6b23d3fd..2871abd34e40 100644 +--- a/tools/lto/lto.exports ++++ b/tools/lto/lto.exports +@@ -43,12 +43,6 @@ lto_codegen_optimize + lto_codegen_compile_optimized + lto_codegen_set_should_internalize + lto_codegen_set_should_embed_uselists +-LLVMCreateDisasm +-LLVMCreateDisasmCPU +-LLVMDisasmDispose +-LLVMDisasmInstruction +-LLVMSetDisasmOptions +-LLVMCreateDisasmCPUFeatures + thinlto_create_codegen + thinlto_codegen_dispose + thinlto_codegen_add_module +diff --git a/tools/remarks-shlib/CMakeLists.txt b/tools/remarks-shlib/CMakeLists.txt +index 865436247270..aa11669d9a75 100644 +--- a/tools/remarks-shlib/CMakeLists.txt ++++ b/tools/remarks-shlib/CMakeLists.txt +@@ -9,7 +9,9 @@ if(LLVM_ENABLE_PIC) + libremarks.cpp + ) + +- set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports) ++ if (NOT (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB)) ++ set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports) ++ endif() + + add_llvm_library(Remarks SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES}) + diff --git a/recipes/llvm-core/all/patches/13x/0005-remove-lto-exports.patch b/recipes/llvm-core/all/patches/13x/0005-remove-lto-exports.patch new file mode 100644 index 0000000000000..46cb2cbbecf38 --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/0005-remove-lto-exports.patch @@ -0,0 +1,32 @@ +diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports +index 1948bba29b67..8fdbd3522b9b 100644 +--- a/tools/lto/lto.exports ++++ b/tools/lto/lto.exports +@@ -44,12 +44,6 @@ lto_codegen_compile_optimized + lto_codegen_set_should_internalize + lto_codegen_set_should_embed_uselists + lto_set_debug_options +-LLVMCreateDisasm +-LLVMCreateDisasmCPU +-LLVMDisasmDispose +-LLVMDisasmInstruction +-LLVMSetDisasmOptions +-LLVMCreateDisasmCPUFeatures + thinlto_create_codegen + thinlto_codegen_dispose + thinlto_codegen_add_module +diff --git a/tools/remarks-shlib/CMakeLists.txt b/tools/remarks-shlib/CMakeLists.txt +index 865436247270..aa11669d9a75 100644 +--- a/tools/remarks-shlib/CMakeLists.txt ++++ b/tools/remarks-shlib/CMakeLists.txt +@@ -9,7 +9,9 @@ if(LLVM_ENABLE_PIC) + libremarks.cpp + ) + +- set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports) ++ if (NOT (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB)) ++ set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports) ++ endif() + + add_llvm_library(Remarks SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES}) + From edaf401ad81e7efb61482db3354db12705d71ab0 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 1 Sep 2024 21:05:38 +0100 Subject: [PATCH 70/77] [llvm-core] explicitly list shared libraries --- recipes/llvm-core/all/conanfile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 2b76cfc0039e0..95588a659cabd 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -1,12 +1,10 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os -from conan.tools.build import check_min_cppstd, can_run +from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.env import VirtualRunEnv from conan.tools.files import ( apply_conandata_patches, - collect_libs, get, rmdir, save, @@ -468,4 +466,4 @@ def package_info(self): self.cpp_info.components[component_name].system_libs += system_libs else: self.cpp_info.set_property("cmake_target_name", "LLVM") - self.cpp_info.libs = collect_libs(self) + self.cpp_info.libs = [f"LLVM-{Version(self.version).major}", "LTO", "Remarks"] From 186645ef23e7fce9ccc66a27b2bcb95b7705712e Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 2 Sep 2024 09:13:33 +0100 Subject: [PATCH 71/77] [llvm-core] revert to using --- recipes/llvm-core/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 95588a659cabd..5b330e496dbb6 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -12,7 +12,7 @@ export_conandata_patches, rm, rename, - replace_in_file + replace_in_file, collect_libs ) from conan.tools.microsoft import is_msvc, msvc_runtime_flag from conan.tools.scm import Version @@ -466,4 +466,4 @@ def package_info(self): self.cpp_info.components[component_name].system_libs += system_libs else: self.cpp_info.set_property("cmake_target_name", "LLVM") - self.cpp_info.libs = [f"LLVM-{Version(self.version).major}", "LTO", "Remarks"] + self.cpp_info.libs = collect_libs(self) From 37eb80e3ae86ce82f6d46ed7f4f689b3511a099e Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 2 Sep 2024 13:18:46 +0100 Subject: [PATCH 72/77] Revert "[llvm-core] try relaxing restrictions on cross-building" This reverts commit 7b2e085e --- recipes/llvm-core/all/conanfile.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 5b330e496dbb6..4802abf7c22b2 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -1,10 +1,11 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os -from conan.tools.build import check_min_cppstd +from conan.tools.build import check_min_cppstd, cross_building from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import ( apply_conandata_patches, + collect_libs, get, rmdir, save, @@ -12,7 +13,7 @@ export_conandata_patches, rm, rename, - replace_in_file, collect_libs + replace_in_file ) from conan.tools.microsoft import is_msvc, msvc_runtime_flag from conan.tools.scm import Version @@ -182,9 +183,13 @@ def validate(self): if self.options.exceptions and not self.options.rtti: raise ConanInvalidConfiguration("Cannot enable exceptions without rtti support") - def validate_build(self): - if self.options.shared and os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug": - raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") + if cross_building(self): + # FIXME support cross compilation + # For Cross Building, LLVM builds a "native" toolchain in a subdirectory of the main build directory. + # This subdirectory would need to have the conan cmake configuration files for the build platform + # installed into it for a cross build to be successful. + # see also https://llvm.org/docs/HowToCrossCompileLLVM.html + raise ConanInvalidConfiguration("Cross compilation is not supported. Contributions are welcome!") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) From 37c3d7b492b7e089b1d39ff70d82821594a23040 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 3 Sep 2024 11:59:53 +0100 Subject: [PATCH 73/77] [llvm-core] workaround for #13560 --- recipes/llvm-core/all/conanfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 4802abf7c22b2..3ee4ce9a689e3 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -284,7 +284,11 @@ def generate(self): else: cmake_variables["LLVM_USE_SANITIZER"] = self.options.use_sanitizer - self.output.info(cmake_variables) + if self.settings.os == "Linux": + # Workaround for: https://github.com/conan-io/conan/issues/13560 + libdirs_host = [l for dependency in self.dependencies.host.values() for l in dependency.cpp_info.aggregated_components().libdirs] + tc.variables["CMAKE_BUILD_RPATH"] = ";".join(libdirs_host) + tc.cache_variables.update(cmake_variables) tc.generate() From 85c1e97fceed5c2e51580f3e4cef4fa35c4f6f0a Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 3 Sep 2024 12:32:34 +0100 Subject: [PATCH 74/77] [llvm-core] increase ram available for link jobs in CCI --- 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 3ee4ce9a689e3..7aa569a9ef782 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -198,7 +198,7 @@ def _apply_resource_limits(self, cmake_definitions): if os.getenv("CONAN_CENTER_BUILD_SERVICE"): self.output.info("Applying CCI Resource Limits") default_ram_per_compile_job = 16384 - default_ram_per_link_job = 2048 + default_ram_per_link_job = 4096 else: default_ram_per_compile_job = None default_ram_per_link_job = None From 3d6d309d140f0f39170c917b6d31f17d8721bdf7 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 4 Sep 2024 11:54:44 +0100 Subject: [PATCH 75/77] [llvm-core] remove the split-dwarf patch --- recipes/llvm-core/all/conandata.yml | 24 ++---- ...=> 0003-no-build-with-install-rpath.patch} | 0 .../all/patches/11x/0003-split-dwarf.patch | 73 ------------------- ...ts.patch => 0004-remove-lto-exports.patch} | 0 ...=> 0003-no-build-with-install-rpath.patch} | 0 .../all/patches/12x/0003-split-dwarf.patch | 66 ----------------- ...ts.patch => 0004-remove-lto-exports.patch} | 0 ...=> 0003-no-build-with-install-rpath.patch} | 0 .../all/patches/13x/0003-split-dwarf.patch | 63 ---------------- ...ts.patch => 0004-remove-lto-exports.patch} | 0 10 files changed, 6 insertions(+), 220 deletions(-) rename recipes/llvm-core/all/patches/11x/{0004-no-build-with-install-rpath.patch => 0003-no-build-with-install-rpath.patch} (100%) delete mode 100644 recipes/llvm-core/all/patches/11x/0003-split-dwarf.patch rename recipes/llvm-core/all/patches/11x/{0005-remove-lto-exports.patch => 0004-remove-lto-exports.patch} (100%) rename recipes/llvm-core/all/patches/12x/{0004-no-build-with-install-rpath.patch => 0003-no-build-with-install-rpath.patch} (100%) delete mode 100644 recipes/llvm-core/all/patches/12x/0003-split-dwarf.patch rename recipes/llvm-core/all/patches/12x/{0005-remove-lto-exports.patch => 0004-remove-lto-exports.patch} (100%) rename recipes/llvm-core/all/patches/13x/{0004-no-build-with-install-rpath.patch => 0003-no-build-with-install-rpath.patch} (100%) delete mode 100644 recipes/llvm-core/all/patches/13x/0003-split-dwarf.patch rename recipes/llvm-core/all/patches/13x/{0005-remove-lto-exports.patch => 0004-remove-lto-exports.patch} (100%) diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index 8b85563961401..763714460b800 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -22,14 +22,10 @@ patches: patch_description: fix missing header files patch_type: portability patch_source: https://github.com/llvm/llvm-project-release-prs/pull/3 - - patch_file: patches/13x/0003-split-dwarf.patch - patch_description: enable split dwarf option from 14.x - patch_source: https://reviews.llvm.org/D108776 - patch_type: bugfix - - patch_file: patches/13x/0004-no-build-with-install-rpath.patch + - patch_file: patches/13x/0003-no-build-with-install-rpath.patch patch_description: do not build shared libs with install rpath patch_type: conan - - patch_file: patches/13x/0005-remove-lto-exports.patch + - patch_file: patches/13x/0004-remove-lto-exports.patch patch_description: remove LTO exports causing link error with lld patch_source: https://github.com/llvm/llvm-project-release-prs/pull/279 patch_type: portability @@ -45,14 +41,10 @@ patches: patch_description: fix missing header files patch_type: portability patch_source: https://github.com/llvm/llvm-project-release-prs/pull/3 - - patch_file: patches/12x/0003-split-dwarf.patch - patch_description: enable split dwarf option from 14.x - patch_source: https://reviews.llvm.org/D108776 - patch_type: bugfix - - patch_file: patches/12x/0004-no-build-with-install-rpath.patch + - patch_file: patches/12x/0003-no-build-with-install-rpath.patch patch_description: do not build shared libs with install rpath patch_type: conan - - patch_file: patches/12x/0005-remove-lto-exports.patch + - patch_file: patches/12x/0004-remove-lto-exports.patch patch_description: remove LTO exports causing link error with lld patch_source: https://github.com/llvm/llvm-project-release-prs/pull/279 patch_type: portability @@ -68,14 +60,10 @@ patches: patch_description: fix missing header files patch_type: portability patch_source: https://github.com/llvm/llvm-project-release-prs/pull/3 - - patch_file: patches/11x/0003-split-dwarf.patch - patch_description: enable split dwarf option from 14.x - patch_source: https://reviews.llvm.org/D108776 - patch_type: bugfix - - patch_file: patches/11x/0004-no-build-with-install-rpath.patch + - patch_file: patches/11x/0003-no-build-with-install-rpath.patch patch_description: do not build shared libs with install rpath patch_type: conan - - patch_file: patches/11x/0005-remove-lto-exports.patch + - patch_file: patches/11x/0004-remove-lto-exports.patch patch_description: remove LTO exports causing link error with lld patch_source: https://github.com/llvm/llvm-project-release-prs/pull/279 patch_type: portability diff --git a/recipes/llvm-core/all/patches/11x/0004-no-build-with-install-rpath.patch b/recipes/llvm-core/all/patches/11x/0003-no-build-with-install-rpath.patch similarity index 100% rename from recipes/llvm-core/all/patches/11x/0004-no-build-with-install-rpath.patch rename to recipes/llvm-core/all/patches/11x/0003-no-build-with-install-rpath.patch diff --git a/recipes/llvm-core/all/patches/11x/0003-split-dwarf.patch b/recipes/llvm-core/all/patches/11x/0003-split-dwarf.patch deleted file mode 100644 index 46d1594239c0f..0000000000000 --- a/recipes/llvm-core/all/patches/11x/0003-split-dwarf.patch +++ /dev/null @@ -1,73 +0,0 @@ -diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake -index 3478c7ef6eb..85e141a1a75 100644 ---- a/cmake/modules/HandleLLVMOptions.cmake -+++ b/cmake/modules/HandleLLVMOptions.cmake -@@ -14,6 +14,14 @@ include(CheckSymbolExists) - include(CMakeDependentOption) - include(LLVMProcessSources) - -+function(append_if condition value) -+ if (${condition}) -+ foreach(variable ${ARGN}) -+ set(${variable} "${${variable}} ${value}" PARENT_SCOPE) -+ endforeach(variable) -+ endif() -+endfunction() -+ - if(CMAKE_LINKER MATCHES "lld-link" OR (MSVC AND (LLVM_USE_LINKER STREQUAL "lld" OR LLVM_ENABLE_LLD))) - set(LINKER_IS_LLD_LINK TRUE) - else() -@@ -75,6 +83,21 @@ elseif(LLVM_PARALLEL_LINK_JOBS) - message(WARNING "Job pooling is only available with Ninja generators.") - endif() - -+# Turn on -gsplit-dwarf if requested in debug builds. -+if (LLVM_USE_SPLIT_DWARF AND -+ ((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR -+ (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO"))) -+ # Limit to clang and gcc so far. Add compilers supporting this option. -+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR -+ CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -+ add_compile_options(-gsplit-dwarf) -+ include(LLVMCheckLinkerFlag) -+ llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX) -+ append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index" -+ CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) -+ endif() -+endif() -+ - if( LLVM_ENABLE_ASSERTIONS ) - # MSVC doesn't like _DEBUG on release builds. See PR 4379. - if( NOT MSVC ) -diff --git a/cmake/modules/LLVMCheckLinkerFlag.cmake b/cmake/modules/LLVMCheckLinkerFlag.cmake -new file mode 100644 -index 00000000000..79c4e2cb4c2 ---- /dev/null -+++ b/cmake/modules/LLVMCheckLinkerFlag.cmake -@@ -0,0 +1,26 @@ -+include(CheckLinkerFlag OPTIONAL) -+ -+if (COMMAND check_linker_flag) -+ macro(llvm_check_linker_flag) -+ check_linker_flag(${ARGN}) -+ endmacro() -+else() -+ # Until the minimum CMAKE version is 3.18 -+ -+ include(CheckCXXCompilerFlag) -+ include(CMakePushCheckState) -+ -+ # cmake builtin compatible, except we assume lang is C or CXX -+ function(llvm_check_linker_flag lang flag out_var) -+ cmake_push_check_state() -+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}") -+ if("${lang}" STREQUAL "C") -+ check_c_compiler_flag("" ${out_var}) -+ elseif("${lang}" STREQUAL "CXX") -+ check_cxx_compiler_flag("" ${out_var}) -+ else() -+ message(FATAL_ERROR "\"${lang}\" is not C or CXX") -+ endif() -+ cmake_pop_check_state() -+ endfunction() -+endif() diff --git a/recipes/llvm-core/all/patches/11x/0005-remove-lto-exports.patch b/recipes/llvm-core/all/patches/11x/0004-remove-lto-exports.patch similarity index 100% rename from recipes/llvm-core/all/patches/11x/0005-remove-lto-exports.patch rename to recipes/llvm-core/all/patches/11x/0004-remove-lto-exports.patch diff --git a/recipes/llvm-core/all/patches/12x/0004-no-build-with-install-rpath.patch b/recipes/llvm-core/all/patches/12x/0003-no-build-with-install-rpath.patch similarity index 100% rename from recipes/llvm-core/all/patches/12x/0004-no-build-with-install-rpath.patch rename to recipes/llvm-core/all/patches/12x/0003-no-build-with-install-rpath.patch diff --git a/recipes/llvm-core/all/patches/12x/0003-split-dwarf.patch b/recipes/llvm-core/all/patches/12x/0003-split-dwarf.patch deleted file mode 100644 index 0acc280e5826b..0000000000000 --- a/recipes/llvm-core/all/patches/12x/0003-split-dwarf.patch +++ /dev/null @@ -1,66 +0,0 @@ -diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake -index 5776a85b747..9e1d1641146 100644 ---- a/cmake/modules/HandleLLVMOptions.cmake -+++ b/cmake/modules/HandleLLVMOptions.cmake -@@ -75,6 +75,29 @@ elseif(LLVM_PARALLEL_LINK_JOBS) - message(WARNING "Job pooling is only available with Ninja generators.") - endif() - -+function(append_if condition value) -+ if (${condition}) -+ foreach(variable ${ARGN}) -+ set(${variable} "${${variable}} ${value}" PARENT_SCOPE) -+ endforeach(variable) -+ endif() -+endfunction() -+ -+# Turn on -gsplit-dwarf if requested in debug builds. -+if (LLVM_USE_SPLIT_DWARF AND -+ ((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR -+ (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO"))) -+ # Limit to clang and gcc so far. Add compilers supporting this option. -+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR -+ CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -+ add_compile_options(-gsplit-dwarf) -+ include(LLVMCheckLinkerFlag) -+ llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX) -+ append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index" -+ CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) -+ endif() -+endif() -+ - if( LLVM_ENABLE_ASSERTIONS ) - # MSVC doesn't like _DEBUG on release builds. See PR 4379. - if( NOT MSVC ) -diff --git a/cmake/modules/LLVMCheckLinkerFlag.cmake b/cmake/modules/LLVMCheckLinkerFlag.cmake -new file mode 100644 -index 00000000000..79c4e2cb4c2 ---- /dev/null -+++ b/cmake/modules/LLVMCheckLinkerFlag.cmake -@@ -0,0 +1,26 @@ -+include(CheckLinkerFlag OPTIONAL) -+ -+if (COMMAND check_linker_flag) -+ macro(llvm_check_linker_flag) -+ check_linker_flag(${ARGN}) -+ endmacro() -+else() -+ # Until the minimum CMAKE version is 3.18 -+ -+ include(CheckCXXCompilerFlag) -+ include(CMakePushCheckState) -+ -+ # cmake builtin compatible, except we assume lang is C or CXX -+ function(llvm_check_linker_flag lang flag out_var) -+ cmake_push_check_state() -+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}") -+ if("${lang}" STREQUAL "C") -+ check_c_compiler_flag("" ${out_var}) -+ elseif("${lang}" STREQUAL "CXX") -+ check_cxx_compiler_flag("" ${out_var}) -+ else() -+ message(FATAL_ERROR "\"${lang}\" is not C or CXX") -+ endif() -+ cmake_pop_check_state() -+ endfunction() -+endif() diff --git a/recipes/llvm-core/all/patches/12x/0005-remove-lto-exports.patch b/recipes/llvm-core/all/patches/12x/0004-remove-lto-exports.patch similarity index 100% rename from recipes/llvm-core/all/patches/12x/0005-remove-lto-exports.patch rename to recipes/llvm-core/all/patches/12x/0004-remove-lto-exports.patch diff --git a/recipes/llvm-core/all/patches/13x/0004-no-build-with-install-rpath.patch b/recipes/llvm-core/all/patches/13x/0003-no-build-with-install-rpath.patch similarity index 100% rename from recipes/llvm-core/all/patches/13x/0004-no-build-with-install-rpath.patch rename to recipes/llvm-core/all/patches/13x/0003-no-build-with-install-rpath.patch diff --git a/recipes/llvm-core/all/patches/13x/0003-split-dwarf.patch b/recipes/llvm-core/all/patches/13x/0003-split-dwarf.patch deleted file mode 100644 index 930add90aab96..0000000000000 --- a/recipes/llvm-core/all/patches/13x/0003-split-dwarf.patch +++ /dev/null @@ -1,63 +0,0 @@ -diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake -index eb234109e88..9a11f0efa49 100644 ---- a/cmake/modules/HandleLLVMOptions.cmake -+++ b/cmake/modules/HandleLLVMOptions.cmake -@@ -81,6 +81,29 @@ elseif(LLVM_PARALLEL_LINK_JOBS) - message(WARNING "Job pooling is only available with Ninja generators.") - endif() - -+function(append_if condition value) -+ if (${condition}) -+ foreach(variable ${ARGN}) -+ set(${variable} "${${variable}} ${value}" PARENT_SCOPE) -+ endforeach(variable) -+ endif() -+endfunction() -+ -+# Turn on -gsplit-dwarf if requested in debug builds. -+if (LLVM_USE_SPLIT_DWARF AND -+ ((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR -+ (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO"))) -+ # Limit to clang and gcc so far. Add compilers supporting this option. -+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR -+ CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -+ add_compile_options(-gsplit-dwarf) -+ include(LLVMCheckLinkerFlag) -+ llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX) -+ append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index" -+ CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS) -+ endif() -+endif() -+ - if( LLVM_ENABLE_ASSERTIONS ) - # MSVC doesn't like _DEBUG on release builds. See PR 4379. - if( NOT MSVC ) -diff --git a/cmake/modules/LLVMCheckLinkerFlag.cmake b/cmake/modules/LLVMCheckLinkerFlag.cmake -index 253dd768654..79c4e2cb4c2 100644 ---- a/cmake/modules/LLVMCheckLinkerFlag.cmake -+++ b/cmake/modules/LLVMCheckLinkerFlag.cmake -@@ -5,14 +5,22 @@ if (COMMAND check_linker_flag) - check_linker_flag(${ARGN}) - endmacro() - else() -+ # Until the minimum CMAKE version is 3.18 -+ - include(CheckCXXCompilerFlag) - include(CMakePushCheckState) - -- # cmake builtin compatible, except we assume lang is CXX -+ # cmake builtin compatible, except we assume lang is C or CXX - function(llvm_check_linker_flag lang flag out_var) - cmake_push_check_state() - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}") -- check_cxx_compiler_flag("" ${out_var}) -+ if("${lang}" STREQUAL "C") -+ check_c_compiler_flag("" ${out_var}) -+ elseif("${lang}" STREQUAL "CXX") -+ check_cxx_compiler_flag("" ${out_var}) -+ else() -+ message(FATAL_ERROR "\"${lang}\" is not C or CXX") -+ endif() - cmake_pop_check_state() - endfunction() - endif() diff --git a/recipes/llvm-core/all/patches/13x/0005-remove-lto-exports.patch b/recipes/llvm-core/all/patches/13x/0004-remove-lto-exports.patch similarity index 100% rename from recipes/llvm-core/all/patches/13x/0005-remove-lto-exports.patch rename to recipes/llvm-core/all/patches/13x/0004-remove-lto-exports.patch From 1aa8107461029dd694c6aecaa2f3530c3dd88f6a Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 4 Sep 2024 12:01:53 +0100 Subject: [PATCH 76/77] [llvm-core] disable shared debug builds entirely and debug builds for linux --- recipes/llvm-core/all/conanfile.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 7aa569a9ef782..8a2954c7a22da 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -191,6 +191,13 @@ def validate(self): # see also https://llvm.org/docs/HowToCrossCompileLLVM.html raise ConanInvalidConfiguration("Cross compilation is not supported. Contributions are welcome!") + def validate_build(self): + if os.getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug": + if self.settings.os == "Linux": + raise ConanInvalidConfiguration("Debug build is not supported on CCI due to resource limitations") + elif self.options.shared: + raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -198,7 +205,7 @@ def _apply_resource_limits(self, cmake_definitions): if os.getenv("CONAN_CENTER_BUILD_SERVICE"): self.output.info("Applying CCI Resource Limits") default_ram_per_compile_job = 16384 - default_ram_per_link_job = 4096 + default_ram_per_link_job = 2048 else: default_ram_per_compile_job = None default_ram_per_link_job = None From bd3f92f10901ca9fe5487ffaca59e3ed312454a9 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 5 Sep 2024 09:04:10 +0100 Subject: [PATCH 77/77] [llvm-core] remove remaining split-dwarf capability --- recipes/llvm-core/all/conanfile.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index 8a2954c7a22da..172f48102fc18 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -268,14 +268,6 @@ def generate(self): self._apply_resource_limits(cmake_variables) - # this capability is back-ported from LLVM 14.x - is_platform_ELF_based = self.settings.os in [ - "Linux", "Android", "FreeBSD", "SunOS", "AIX", "Neutrino", "VxWorks" - ] - if is_platform_ELF_based: - self.output.info("ELF Platform Detected, optimizing memory usage during debug build linking.") - cmake_variables["LLVM_USE_SPLIT_DWARF"] = True - if is_msvc(self): build_type = str(self.settings.build_type).upper() cmake_variables[f"LLVM_USE_CRT_{build_type}"] = msvc_runtime_flag(self)