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..763714460b800 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -10,18 +10,60 @@ 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/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 + 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/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-no-build-with-install-rpath.patch + patch_description: do not build shared libs with install rpath + patch_type: conan + - 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 + "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 + patch_type: conan + - 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/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-no-build-with-install-rpath.patch + patch_description: do not build shared libs with install rpath + patch_type: conan + - 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 + "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 + patch_type: conan + - 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/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-no-build-with-install-rpath.patch + patch_description: do not build shared libs with install rpath + patch_type: conan + - 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/conanfile.py b/recipes/llvm-core/all/conanfile.py index 263cb7360506c..172f48102fc18 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -1,429 +1,477 @@ -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.apple import is_apple_os +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, + copy, + export_conandata_patches, + rm, + rename, + replace_in_file +) +from conan.tools.microsoft import is_msvc, msvc_runtime_flag from conan.tools.scm import Version -from conans import CMake -from collections import defaultdict + import json -import re -import os.path import os +from pathlib import Path +import re import textwrap -required_conan_version = ">=1.50.2" # Due to conan.tools.scm.Version + +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 specifying only the targets they need as a +# semi-colon delimited string in the value of the 'targets' option +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' + 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' - - settings = ('os', 'arch', 'compiler', 'build_type') + 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" 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_zlib': [True, False], - 'with_xml2': [True, False], - 'use_llvm_cmake_files': [True, False], + "with_ffi": [True, False], + "with_libedit": [True, False], + "with_terminfo": [True, False], + "with_zlib": [True, False], + "with_xml2": [True, False], + "with_z3": [True, False], } default_options = { - 'shared': False, - 'fPIC': True, - 'components': 'all', - 'targets': 'all', - 'exceptions': True, - 'rtti': True, - 'threads': True, - 'lto': 'Off', - 'static_stdlib': False, - 'unwind_tables': True, - 'expensive_checks': False, - 'use_perf': False, - 'use_sanitizer': 'None', - 'with_ffi': False, - 'with_zlib': True, - 'with_xml2': True, - 'use_llvm_cmake_files': False, + "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_libedit": True, + "with_ffi": False, + "with_terminfo": False, # differs from LLVM default + "with_xml2": True, + "with_z3": True, + "with_zlib": True, } - # 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 _min_cppstd(self): + return 14 - 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 - - 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 + del self.options.with_libedit # not supported on windows + + 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') - - def package_id(self): - del self.info.options.use_llvm_cmake_files + self.requires("libffi/3.4.4") + if self.options.get_safe("with_libedit"): + self.requires("editline/3.1") + if self.options.with_zlib: + self.requires("zlib/[>=1.2.11 <2]") + if self.options.with_xml2: + self.requires("libxml2/[>=2.12.5 <3]") + if self.options.with_z3: + self.requires("z3/4.13.0") + + def build_requirements(self): + self.tool_requires("ninja/[>=1.10.2 <2]") 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.options.shared: + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Shared builds are currently not supported on Windows") + 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: - 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") + + 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 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, - destination=self._source_subfolder) - self._patch_sources() + get(self, **self.conan_data["sources"][self.version], strip_root=True) - def build(self): - self._patch_build() - cmake = self._configure_cmake() - cmake.configure() - cmake.build() + 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 + else: + default_ram_per_compile_job = None + default_ram_per_link_job = None - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake", "llvm") + 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", default_ram_per_link_job) + if ram_per_link_job: + cmake_definitions["LLVM_RAM_PER_LINK_JOB"] = ram_per_link_job @property - def _alias_module_file_rel_path(self): - return os.path.join(self._module_subfolder, "conan-official-{}-targets.cmake".format(self.name)) + def _targets_to_build(self): + return self.options.targets if self.options.targets != "all" else self._all_targets @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 _all_targets(self): + 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 = { + # 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, + "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": 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, + "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.targets != "all": + cmake_variables["LLVM_TARGETS_TO_BUILD"] = self.options.targets - def package(self): - self.copy('LICENSE.TXT', dst='licenses', src=self._source_subfolder) - lib_path = os.path.join(self.package_folder, 'lib') + self._apply_resource_limits(cmake_variables) - cmake = self._configure_cmake() - cmake.install() + if is_msvc(self): + build_type = str(self.settings.build_type).upper() + cmake_variables[f"LLVM_USE_CRT_{build_type}"] = msvc_runtime_flag(self) 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' - } + cmake_variables.update({ + "DISABLE_LLVM_LINK_LLVM_DYLIB": True, + "LLVM_ENABLE_PIC": self.options.get_safe("fPIC", default=True) + }) - components = defaultdict(list) - for lib, dep in deps: - if not lib.startswith('LLVM'): - continue - elif dep.startswith('-delayload:'): + if self.options.use_sanitizer == "None": + cmake_variables["LLVM_USE_SANITIZER"] = "" + else: + cmake_variables["LLVM_USE_SANITIZER"] = self.options.use_sanitizer + + 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() + + tc = CMakeDeps(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + @property + def _package_folder_path(self): + return Path(self.package_folder) + + def _update_component_dependencies(self, components): + 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) + else: + replacement = replacements.get(dep) + if replacement: + yield replacement + elif dep.startswith("-l"): + yield dep[2:] + else: + yield dep + + def _parse_deps(deps_list): + data = { + "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 - 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])) + if component in ["rt", "m", "dl", "pthread"]: + data["system_libs"].append(component) 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 - ) + data["requires"].append(component) + return data - self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._old_alias_module_file_rel_path), - old_alias_targets - ) + # 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) - rmdir(self, os.path.join(self.package_folder, 'share')) + for llvm_lib, dependencies in match_dependencies.findall(cmake_exports): + if llvm_lib in components: + components[llvm_lib].update(_parse_deps(dependencies)) - 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')) + def _llvm_build_info(self): + cmake_config = (self._package_folder_path / "lib" / "cmake" / "llvm" / "LLVMConfig.cmake").read_text("utf-8") - 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") + 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 - for mask in ["Find*.cmake", "*Config.cmake", "*-config.cmake"]: - rm(self, mask, self.package_folder, recursive=True) + components = {component: {} for component in match.groupdict()["components"].split(";")} + self._update_component_dependencies(components) - 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) + return { + "components": components, + "native_arch": re.search(r"""^set\(LLVM_NATIVE_ARCH (\S*)\)$""", cmake_config, re.MULTILINE).group(1) + } - 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)) + @property + def _cmake_module_path(self): + return Path("lib") / "cmake" / "llvm" - def package_info(self): - self.cpp_info.set_property("cmake_file_name", "LLVM") + @property + def _build_info_file(self): + return self._package_folder_path / self._cmake_module_path / "conan_llvm_build_info.json" - if self.options.shared: - 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' - } + @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, build_info, module_file): + 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 "${{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)}") + 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() + 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) - 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')) + 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) - for lib, target in targets.items(): - if lib in deps: - self.cpp_info.components[component].requires.append(target) + return build_info - self.cpp_info.components[component].system_libs = [ - dep for dep in deps - if not dep.startswith('LLVM') and dep not in dependencies - ] + def _read_build_info(self) -> dict: + with open(self._build_info_file, encoding="utf-8") as fp: + return json.load(fp) - 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" + def package(self): + copy(self, "LICENSE.TXT", self.source_folder, (self._package_folder_path / "licenses").as_posix()) + cmake = CMake(self) + cmake.install() + + build_info = self._write_build_info() + + cmake_folder = self._package_folder_path / "lib" / "cmake" / "llvm" + 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").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").as_posix()) + + self._create_cmake_build_module( + build_info, + (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").as_posix()] + ) + self.cpp_info.builddirs.append(self._cmake_module_path) + + if not self.options.shared: + 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) + 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 + 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/patches/11x/0000-cmake-dependencies.patch b/recipes/llvm-core/all/patches/11x/0000-cmake-dependencies.patch new file mode 100644 index 0000000000000..3da6ed6f9b317 --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/0000-cmake-dependencies.patch @@ -0,0 +1,118 @@ +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +index 90e5d327c75..c8bcb1afb76 100644 +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake +@@ -5,6 +5,7 @@ endif() + + include(CheckIncludeFile) + include(CheckLibraryExists) ++include(CMakePushCheckState) + include(CheckSymbolExists) + include(CheckFunctionExists) + include(CheckStructHasMember) +@@ -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) +-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) + + 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,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.*") +- 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. +- 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() +@@ -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() + +-if (LLVM_ENABLE_ZLIB ) ++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) +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/0001-calculate-job-pools.patch b/recipes/llvm-core/all/patches/11x/0001-calculate-job-pools.patch new file mode 100644 index 0000000000000..b00101aa4e526 --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/0001-calculate-job-pools.patch @@ -0,0 +1,42 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 5ef22eb493b..3478c7ef6eb 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -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. + 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.") +@@ -38,6 +51,17 @@ 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/11x/0002-missing-includes.patch b/recipes/llvm-core/all/patches/11x/0002-missing-includes.patch new file mode 100644 index 0000000000000..929a539e77369 --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/0002-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/11x/0003-no-build-with-install-rpath.patch b/recipes/llvm-core/all/patches/11x/0003-no-build-with-install-rpath.patch new file mode 100644 index 0000000000000..e56177aab947f --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/0003-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-remove-lto-exports.patch b/recipes/llvm-core/all/patches/11x/0004-remove-lto-exports.patch new file mode 100644 index 0000000000000..6dea8a2419a11 --- /dev/null +++ b/recipes/llvm-core/all/patches/11x/0004-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/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/0000-cmake-dependencies.patch b/recipes/llvm-core/all/patches/12x/0000-cmake-dependencies.patch new file mode 100644 index 0000000000000..319d08bc1921c --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/0000-cmake-dependencies.patch @@ -0,0 +1,92 @@ +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +index 818fafbce14..8ef381257b6 100644 +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake +@@ -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}) +- 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) +@@ -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 ++++ 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/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt +index 8134ac8c815..652062f7fb9 100644 +--- 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. + 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() ++ 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}) + endif() diff --git a/recipes/llvm-core/all/patches/12x/0001-calculate-job-pools.patch b/recipes/llvm-core/all/patches/12x/0001-calculate-job-pools.patch new file mode 100644 index 0000000000000..ab29c3a894ccd --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/0001-calculate-job-pools.patch @@ -0,0 +1,42 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 5d4d692a70a..5776a85b747 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -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. + 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.") +@@ -38,6 +51,17 @@ 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/0002-missing-includes.patch b/recipes/llvm-core/all/patches/12x/0002-missing-includes.patch new file mode 100644 index 0000000000000..c7cfb90318b49 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/0002-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/12x/0003-no-build-with-install-rpath.patch b/recipes/llvm-core/all/patches/12x/0003-no-build-with-install-rpath.patch new file mode 100644 index 0000000000000..df143f02d6491 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/0003-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-remove-lto-exports.patch b/recipes/llvm-core/all/patches/12x/0004-remove-lto-exports.patch new file mode 100644 index 0000000000000..60db5a636b646 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/0004-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/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/0000-cmake-dependencies.patch b/recipes/llvm-core/all/patches/13x/0000-cmake-dependencies.patch new file mode 100644 index 0000000000000..a49abd15efa6c --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/0000-cmake-dependencies.patch @@ -0,0 +1,84 @@ +diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake +index dd0aaadb47c..790a0b27a49 100644 +--- a/cmake/config-ix.cmake ++++ b/cmake/config-ix.cmake +@@ -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}) +- 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) +@@ -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 ++++ 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..ccd772f6176 100644 +--- 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. + 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) +- 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/0001-calculate-job-pools.patch b/recipes/llvm-core/all/patches/13x/0001-calculate-job-pools.patch new file mode 100644 index 0000000000000..ec100e4785349 --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/0001-calculate-job-pools.patch @@ -0,0 +1,42 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 0c3419390c2..eb234109e88 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -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. + 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.") +@@ -44,6 +57,17 @@ 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/0002-missing-includes.patch b/recipes/llvm-core/all/patches/13x/0002-missing-includes.patch new file mode 100644 index 0000000000000..c7cfb90318b49 --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/0002-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/0003-no-build-with-install-rpath.patch b/recipes/llvm-core/all/patches/13x/0003-no-build-with-install-rpath.patch new file mode 100644 index 0000000000000..05560e5a0c714 --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/0003-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-remove-lto-exports.patch b/recipes/llvm-core/all/patches/13x/0004-remove-lto-exports.patch new file mode 100644 index 0000000000000..46cb2cbbecf38 --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/0004-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}) + 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..4de3810296f19 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -1,20 +1,31 @@ -cmake_minimum_required(VERSION 3.13.4) -project(test_package) +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(LLVM REQUIRED) +macro(test_llvm_cmake_variable VARIABLE) + if(NOT DEFINED ${VARIABLE}) + message(FATAL_ERROR "${VARIABLE} is not defined") + endif() + message(STATUS "${VARIABLE}: ${${VARIABLE}}") +endmacro() +set(CMAKE_CXX_STANDARD 17) 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) + llvm_map_components_to_libnames(llvm_libs interpreter nativecodegen irreader) + target_link_libraries(${PROJECT_NAME} PRIVATE ${llvm_libs}) 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) +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) diff --git a/recipes/llvm-core/all/test_package/conanfile.py b/recipes/llvm-core/all/test_package/conanfile.py index e0ca8f6b664cb..5ae2ff91c80a2 100644 --- a/recipes/llvm-core/all/test_package/conanfile.py +++ b/recipes/llvm-core/all/test_package/conanfile.py @@ -1,39 +1,43 @@ -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 -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): + # required for cmake_path support + self.tool_requires("cmake/[>=3.20 <4]") + + 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 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): + 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")