Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ For more information please consult our [PhASAR wiki pages](https://github.com/s
## How to use with Conan v2 ?

To export the recipe and dependencies execute from repo root:
- `conan export utils/conan/llvm-core/ --version 14.0.6 --user secure-software-engineering`
- `conan export utils/conan/clang/ --version 14.0.6 --user secure-software-engineering`
- `conan export utils/conan/llvm-core/ --version 15.0.7 --user secure-software-engineering`
- `conan export utils/conan/clang/ --version 15.0.7 --user secure-software-engineering`
- `conan export .`
- View exported `conan list "phasar/*"`
- [Consume the package](https://docs.conan.io/2/tutorial/consuming_packages.html)
Expand Down
8 changes: 5 additions & 3 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ class PhasarRecipe(ConanFile):
"shared": [True, False],
"fPIC": [True, False],
"tests": [True, False],
"llvm_version": ["ANY"],
}
default_options = {
"with_z3": True,
"shared": False,
"fPIC": True,
"tests": False,
"llvm_version": "15.0.7"
}

def _parse_gitignore(self, folder, additional_exclusions = [], invert=False):
Expand Down Expand Up @@ -208,7 +210,7 @@ def set_version(self):
git = Git(self, self.recipe_folder)
# XXX consider git.coordinates_to_conandata()
if git.is_dirty():
raise ConanException("Repository is dirty. I can't calculate a correct version and this is a potential leak because all files visible to git will be exported. Please stash or commit.")
raise ConanException("Repository is dirty. I can't calculate a correct version and this is a potential leak because all files visible to git will be exported. Please stash or commit, to skip this for local testing use \"--version dev\".")
self.output.info("No version information set, retrieving from git.")
calver = git.run("show -s --date=format:'%Y.%m.%d' --format='%cd'")
short_hash = git.run("show -s --format='%h'")
Expand All @@ -228,7 +230,7 @@ def config_options(self):
def requirements(self):
self.requires("boost/[>1.72.0 <=1.86.0]")
self.requires("sqlite3/[>=3 <4]")
self.requires("clang/14.0.6@secure-software-engineering", transitive_libs=True, transitive_headers=True)
self.requires(f"clang/{self.options.llvm_version}@secure-software-engineering", transitive_libs=True, transitive_headers=True)
self.requires("nlohmann_json/3.11.3", transitive_headers=True)
self.requires("json-schema-validator/2.3.0", transitive_libs=True, transitive_headers=True)

Expand All @@ -238,7 +240,7 @@ def requirements(self):
if self.options.with_z3:
self.requires("z3/[>=4.7.1 <5]")
llvm_options["with_z3"] = True
self.requires("llvm-core/14.0.6@secure-software-engineering", transitive_libs=True, transitive_headers=True, options=llvm_options)
self.requires(f"llvm-core/{self.options.llvm_version}@secure-software-engineering", transitive_libs=True, transitive_headers=True, options=llvm_options)

def build_requirements(self):
self.tool_requires("cmake/[>=3.25.0 <4.0.0]") # find_program validator
Expand Down
12 changes: 12 additions & 0 deletions utils/conan/clang/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ sources:
"18.1.7":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.7/clang-18.1.7.src.tar.xz
sha256: c9191e4896e43425a8fbbb29e3b25b3a83050781809fbd4d0ad2382bc4a5c43d
"15.0.7":
"clang":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang-15.0.7.src.tar.xz
sha256: a6b673ef15377fb46062d164e8ddc4d05c348ff8968f015f7f4af03f51000067
"cmake":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/cmake-15.0.7.src.tar.xz
sha256: 8986f29b634fdaa9862eedda78513969fe9788301c9f2d938f4c10a3e7a3e7ea
"14.0.6":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/clang-14.0.6.src.tar.xz
sha256: 2b5847b6a63118b9efe5c85548363c81ffe096b66c3b3675e953e26342ae4031
patches:
"15.0.7":
- patch_file: patches/15x/0000-force-import-original-llvm-config.patch
patch_description: Imports definitions from original LLVMConfig
patch_type: conan
base_path: clang
"14.0.6":
- patch_file: patches/14x/0000-force-import-original-llvm-config.patch
patch_description: Imports definitions from original LLVMConfig
Expand Down
22 changes: 15 additions & 7 deletions utils/conan/clang/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,17 @@ def validate(self):
)

def source(self):
get(self, **self.conan_data["sources"][self.version])

clang_folder=f"clang-{self.version}.src"
rename(self, "cmake/Modules", "cmake/modules")
copy(self, pattern="*", src=clang_folder, dst=".")
rmdir(self, clang_folder)
if Version(self.version) >= 15:
sources = self.conan_data["sources"][self.version]
get(self, **sources["clang"], destination='clang', strip_root=True)
get(self, **sources["cmake"], destination='cmake', strip_root=True)
else:
get(self, **self.conan_data["sources"][self.version])
clang_folder=f"clang-{self.version}.src"
if Path("cmake/Modules").exists():
rename(self, "cmake/Modules", "cmake/modules")
copy(self, pattern="*", src=clang_folder, dst=".")
rmdir(self, clang_folder)

@property
def _get_llvm_path(self):
Expand All @@ -123,7 +128,10 @@ def generate(self):
def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure(cli_args=['--graphviz=graph/clang.dot'])
if Version(self.version) >= 15:
cmake.configure(build_script_folder="clang", cli_args=['--graphviz=graph/clang.dot'])
else:
cmake.configure(cli_args=['--graphviz=graph/clang.dot'])
cmake.build()

def _clang_build_info(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3bc4b468fb6..cf7a094ebb6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,6 +70,7 @@ if(CLANG_BUILT_STANDALONE)
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
endif()

+ include(LLVMConfig.original)
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")

27 changes: 27 additions & 0 deletions utils/conan/llvm-core/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
sources:
"15.0.7":
"llvm":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/llvm-15.0.7.src.tar.xz
sha256: 4ad8b2cc8003c86d0078d15d987d84e3a739f24aae9033865c027abae93ee7a4
"cmake":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/cmake-15.0.7.src.tar.xz
sha256: 8986f29b634fdaa9862eedda78513969fe9788301c9f2d938f4c10a3e7a3e7ea

"14.0.6":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/llvm-14.0.6.src.tar.xz
sha256: 050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a

patches:
"15.0.7":
- patch_file: patches/15x/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
- patch_file: patches/15x/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
base_path: llvm-main
- patch_file: patches/15x/0003-no-build-with-install-rpath.patch
patch_description: do not build shared libs with install rpath
patch_type: conan
base_path: llvm-main
- patch_file: patches/15x/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
base_path: llvm-main
"14.0.6":
- patch_file: patches/14x/0000-cmake-dependencies.patch
patch_description: fix references to third party libs to match conan variables and targets
Expand Down
56 changes: 45 additions & 11 deletions utils/conan/llvm-core/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"BPF",
"Hexagon",
"Lanai",
"Mips",
"MSP430",
"Mips",
"NVPTX",
"PowerPC",
"RISCV",
Expand Down Expand Up @@ -94,6 +94,8 @@ class LLVMCoreConan(ConanFile):
"with_zlib": [True, False],
"with_xml2": [True, False],
"with_z3": [True, False],
'with_zstd': [True, False],
'with_httplib': [True, False],
}
default_options = {
"shared": False,
Expand All @@ -116,6 +118,8 @@ class LLVMCoreConan(ConanFile):
"with_xml2": True,
"with_z3": True, # not default
"with_zlib": True,
'with_zstd': True,
'with_httplib': False,
}

@property
Expand Down Expand Up @@ -143,6 +147,9 @@ def config_options(self):
release = Version(self.version).major
if release < 14:
del self.options.with_curl
if release < 15:
del self.options.with_zstd
del self.options.with_httplib

def configure(self):
if self.options.shared:
Expand All @@ -167,6 +174,9 @@ def requirements(self):
self.requires('libcurl/[>=7.78.0 <9]') # no version requirement in llvm 14-19
if self.options.get_safe("with_zstd"):
self.requires("zstd/[>=1.4.3 <2]") # no version required llvm 15-19, <1.4.3 doesn't work
if self.options.get_safe('with_httplib'):
# no version number in llvm 15-17
self.requires('cpp-httplib/[>=0.5.4 <1.0.0]')

def build_requirements(self):
self.tool_requires("ninja/[>=1.10.2 <2]")
Expand Down Expand Up @@ -202,6 +212,9 @@ def validate(self):
# see also https://llvm.org/docs/HowToCrossCompileLLVM.html
raise ConanInvalidConfiguration("Cross compilation is not supported. Contributions are welcome!")

if self.options.get_safe("with_libedit") and self.options.use_sanitizer != 'None':
raise ConanInvalidConfiguration("libedit can't be used with sanitizers")

def validate_build(self):
if getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug":
if self.settings.os == "Linux":
Expand All @@ -210,12 +223,17 @@ def validate_build(self):
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])

llvm_folder=f"llvm-{self.version}.src"
rename(self, "cmake/Modules", "cmake/modules")
copy(self, pattern="*", src=llvm_folder, dst=".")
rmdir(self, llvm_folder)
if Version(self.version) >= 15:
sources = self.conan_data["sources"][self.version]
get(self, **sources["llvm"], destination='llvm-main', strip_root=True)
get(self, **sources["cmake"], destination='cmake', strip_root=True)
else:
get(self, **self.conan_data["sources"][self.version])
llvm_folder=f"llvm-{self.version}.src"
if Path("cmake/Modules").exists():
rename(self, "cmake/Modules", "cmake/modules")
copy(self, pattern="*", src=llvm_folder, dst=".")
rmdir(self, llvm_folder)

def _apply_resource_limits(self, cmake_definitions):
if getenv("CONAN_CENTER_BUILD_SERVICE"):
Expand Down Expand Up @@ -244,12 +262,17 @@ def _all_targets(self):
ver = Version(self.version).major
if ver >= 14:
targets.add("VE")
if ver >= 15:
if ver >= 16: # its available in 15 but not by default with "all"
targets.add("LoongArch")
return ";".join(targets)

def generate(self):
tc = CMakeToolchain(self, generator="Ninja")

is_zstd_static = False
if self.options.get_safe('with_zstd', False):
is_zstd_static = not self.dependencies["zstd"].options.shared

# https://releases.llvm.org/12.0.0/docs/CMake.html
# https://releases.llvm.org/13.0.0/docs/CMake.html
# https://releases.llvm.org/14.0.0/docs/CMake.html
Expand Down Expand Up @@ -285,7 +308,10 @@ def generate(self):
"LLVM_ENABLE_FFI": self.options.with_ffi,
"LLVM_ENABLE_ZLIB": "FORCE_ON" if self.options.with_zlib else False,
"LLVM_ENABLE_LIBXML2": "FORCE_ON" if self.options.with_xml2 else False,
"LLVM_ENABLE_TERMINFO": self.options.with_terminfo
"LLVM_ENABLE_TERMINFO": self.options.with_terminfo,
'LLVM_ENABLE_ZSTD': 'FORCE_ON' if self.options.get_safe('with_zstd', False) else False,
'LLVM_USE_STATIC_ZSTD': is_zstd_static,
'LLVM_ENABLE_HTTPLIB': 'FORCE_ON' if self.options.get_safe('with_httplib', False) else False,
}
if self.options.targets != "all":
cmake_variables["LLVM_TARGETS_TO_BUILD"] = self.options.targets
Expand Down Expand Up @@ -316,12 +342,17 @@ def generate(self):
tc.generate()

tc = CMakeDeps(self)
tc.set_property("editline", "cmake_file_name", "LibEdit")
tc.set_property("editline", "cmake_target_name", "LibEdit::LibEdit")
tc.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
if Version(self.version) >= 15:
cmake.configure(build_script_folder="llvm-main")
else:
cmake.configure()
cmake.build()

@property
Expand All @@ -335,7 +366,10 @@ def _sanitized_components(deps_list):
replacements = {
"LibXml2::LibXml2": "libxml2::libxml2",
"ZLIB::ZLIB": "zlib::zlib",
"CURL::libcurl": "libcurl::libcurl"
"CURL::libcurl": "libcurl::libcurl",
"LibEdit::LibEdit": "editline::editline",
"httplib::httplib": "cpp-httplib::cpp-httplib",
"zstd::libzstd_static": "zstd::zstd",
}
for dep in deps_list.split(";"):
match = match_genex.search(dep)
Expand Down
70 changes: 70 additions & 0 deletions utils/conan/llvm-core/patches/15x/0000-cmake-dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index 7e657fd1532d..29f524927b30 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -126,7 +126,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)
@@ -203,7 +203,7 @@ if(LLVM_ENABLE_HTTPLIB)
# Check if the "httplib" we found is usable; for example there may be another
# library with the same name.
cmake_push_check_state()
- list(APPEND CMAKE_REQUIRED_LIBRARIES ${HTTPLIB_LIBRARY})
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${HTTPLIB_LIBRARIES})
check_cxx_symbol_exists(CPPHTTPLIB_HTTPLIB_H ${HTTPLIB_HEADER_PATH} HAVE_HTTPLIB)
cmake_pop_check_state()
if(LLVM_ENABLE_HTTPLIB STREQUAL FORCE_ON AND NOT HAVE_HTTPLIB)
@@ -220,7 +220,7 @@ 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 NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
- find_package(LibEdit)
+ find_package(LibEdit REQUIRED)
set(HAVE_LIBEDIT ${LibEdit_FOUND})
else()
set(HAVE_LIBEDIT 0)
diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt
index ff23ec74df96..213605ebdea6 100644
--- a/lib/Support/CMakeLists.txt
+++ b/lib/Support/CMakeLists.txt
@@ -293,7 +293,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)
@@ -306,7 +306,7 @@ 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})
+ set(zstd_library ${zstd_LIBRARIES})
endif()
if(NOT zstd_library)
get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION)
diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt
index 910132a4c7de..266d3b7faaa9 100644
--- a/lib/WindowsManifest/CMakeLists.txt
+++ b/lib/WindowsManifest/CMakeLists.txt
@@ -21,10 +21,11 @@ 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 libxml2_library)
get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION)
Loading
Loading