Skip to content

Commit

Permalink
Merge branch 'llvm-core-18.1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Sep 4, 2024
2 parents 74c03c2 + bda25f1 commit 898bb7c
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 37 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Conan build
on: [push]

defaults:
run:
shell: bash
working-directory: recipes/llvm-core/all

env:
LLVM_VERSION: 18.1.5
LLVM_OPTIONS: >-
-o "llvm-core/*:with_target_amdgpu=False"
-o "llvm-core/*:with_target_arm=False"
-o "llvm-core/*:with_target_avr=False"
-o "llvm-core/*:with_target_bpf=False"
-o "llvm-core/*:with_target_hexagon=False"
-o "llvm-core/*:with_target_lanai=False"
-o "llvm-core/*:with_target_loongarch=False"
-o "llvm-core/*:with_target_mips=False"
-o "llvm-core/*:with_target_msp430=False"
-o "llvm-core/*:with_target_nvptx=False"
-o "llvm-core/*:with_target_powerpc=False"
-o "llvm-core/*:with_target_riscv=False"
-o "llvm-core/*:with_target_sparc=False"
-o "llvm-core/*:with_target_systemz=False"
-o "llvm-core/*:with_target_ve=False"
-o "llvm-core/*:with_target_xcore=False"
-o "llvm-core/*:with_target_webassembly=False"
CONAN_SETTINGS: -s compiler.cppstd=17

jobs:
build:
name: ${{ matrix.runner-os }}

strategy:
matrix:
runner-os: [macos-14, windows-latest, ubuntu-22.04]

runs-on: ${{ matrix.runner-os }}
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: install conan
run: |
pip install conan
conan profile detect
- name: create package
run: |
conan create . \
--version ${{ env.LLVM_VERSION }} \
${{ env.LLVM_OPTIONS }} \
${{ env.CONAN_SETTINGS }} \
--build=missing
15 changes: 15 additions & 0 deletions recipes/llvm-core/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
sources:
"18.1.7":
"llvm":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.7/llvm-18.1.7.src.tar.xz
sha256: 17ba3d57c3db185722c36e736a189b2110e8cb842cc9e53dcc74e938bdadb97e
"cmake":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.7/cmake-18.1.7.src.tar.xz
sha256: f0b67599f51cddcdbe604c35b6de97f2d0a447e18b9c30df300c82bf1ee25bd7
"third-party":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.7/third-party-18.1.7.src.tar.xz
sha256: 8d8192598b251b44cf900109dc83dd9cde33bb465d7930a8cdadf5586d632320
"13.0.0":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/llvm-13.0.0.src.tar.xz
sha256: 408d11708643ea826f519ff79761fcdfc12d641a2510229eec459e72f8163020
Expand All @@ -10,6 +20,11 @@ sources:
sha256: ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5

patches:
"18.1.7":
- patch_file: patches/18x/0000-cmake-dependencies.patch
patch_description: fix references to third party libs to match conan variables and targets
patch_type: conan
base_path: llvm-main
"13.0.0":
- patch_file: patches/13x/0000-cmake-dependencies.patch
patch_description: fix references to third party libs to match conan variables and targets
Expand Down
76 changes: 39 additions & 37 deletions recipes/llvm-core/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_<target name in lower case>=False`
LLVM_TARGETS = [
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -93,6 +93,7 @@ class LLVMCoreConan(ConanFile):
"with_zlib": [True, False],
"with_xml2": [True, False],
"with_z3": [True, False],
"with_zstd": [True, False],
"ram_per_compile_job": ["ANY"],
"ram_per_link_job": ["ANY"],
}
Expand All @@ -101,8 +102,8 @@ class LLVMCoreConan(ConanFile):
"shared": False,
"fPIC": True,
"components": "all",
"exceptions": True,
"rtti": True,
"exceptions": False,
"rtti": False,
"threads": True,
"lto": "Off",
"static_stdlib": False,
Expand All @@ -116,6 +117,7 @@ class LLVMCoreConan(ConanFile):
"with_xml2": True,
"with_z3": True,
"with_zlib": True,
"with_zstd": True,
"ram_per_compile_job": "auto",
"ram_per_link_job": "auto"
}
Expand Down Expand Up @@ -145,7 +147,9 @@ 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 < 18:
del self.options.with_zstd
if self._major_version < 14:
del self.options.with_target_loongarch # experimental
del self.options.with_target_ve # experimental
Expand All @@ -163,14 +167,16 @@ 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")
if self.options.with_zstd:
self.requires("zstd/1.5.5")

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:
Expand All @@ -183,7 +189,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):
Expand All @@ -200,10 +206,16 @@ 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)
sources = self.conan_data["sources"][self.version]
if self._major_version < 18:
get(**sources, strip_root=True)
else:
get(self, **sources["llvm"], destination='llvm-main', strip_root=True)
get(self, **sources["cmake"], destination='cmake', strip_root=True)
get(self, **sources["third-party"], destination='third-party', strip_root=True)

def _apply_resource_limits(self, cmake_definitions):
if os.getenv("CONAN_CENTER_BUILD_SERVICE"):
Expand All @@ -228,25 +240,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,
Expand Down Expand Up @@ -274,32 +272,32 @@ 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 [
"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_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),
Expand All @@ -321,7 +319,10 @@ def generate(self):
def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
if self._major_version < 18:
cmake.configure()
else:
cmake.configure(build_script_folder="llvm-main")
cmake.build()

@property
Expand All @@ -338,6 +339,7 @@ def _update_component_dependencies(self, components):
def _sanitized_components(deps_list):
match_genex = re.compile(r"""\\\$<LINK_ONLY:(.+)>""")
replacements = {
"zstd::libzstd_static": "zstd::zstd",
"LibXml2::LibXml2": "libxml2::libxml2",
"ZLIB::ZLIB": "zlib::zlib"
}
Expand All @@ -359,7 +361,7 @@ def _parse_deps(deps_list):
"requires": [],
"system_libs": []
}
windows_system_libs=[
windows_system_libs = [
"ole32",
"delayimp",
"shell32",
Expand Down Expand Up @@ -395,7 +397,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 {
Expand Down
93 changes: 93 additions & 0 deletions recipes/llvm-core/all/patches/18x/0000-cmake-dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index bf1b110245b..f3f59734870 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -137,7 +137,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)
@@ -232,11 +232,11 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
# Skip libedit if using ASan as it contains memory leaks.
if (LLVM_ENABLE_LIBEDIT AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
if(LLVM_ENABLE_LIBEDIT STREQUAL FORCE_ON)
- find_package(LibEdit REQUIRED)
+ find_package(editline REQUIRED)
else()
- find_package(LibEdit)
+ find_package(editline)
endif()
- set(HAVE_LIBEDIT "${LibEdit_FOUND}")
+ set(HAVE_LIBEDIT "${editline_FOUND}")
else()
set(HAVE_LIBEDIT 0)
endif()
diff --git a/lib/LineEditor/CMakeLists.txt b/lib/LineEditor/CMakeLists.txt
index c4cd91cbb0c..b95d073d972 100644
--- a/lib/LineEditor/CMakeLists.txt
+++ b/lib/LineEditor/CMakeLists.txt
@@ -1,5 +1,5 @@
if(HAVE_LIBEDIT)
- set(link_libs LibEdit::LibEdit)
+ set(link_libs editline::editline)
endif()

add_llvm_component_library(LLVMLineEditor
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()
Loading

0 comments on commit 898bb7c

Please sign in to comment.