Skip to content

Commit f9e96b3

Browse files
jusitofabianbs96
andauthored
build: update conan to llvm 15 (#755)
Co-authored-by: Fabian Schiebel <52407375+fabianbs96@users.noreply.github.com>
1 parent 332509b commit f9e96b3

File tree

11 files changed

+277
-23
lines changed

11 files changed

+277
-23
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ For more information please consult our [PhASAR wiki pages](https://github.com/s
203203
## How to use with Conan v2 ?
204204

205205
To export the recipe and dependencies execute from repo root:
206-
- `conan export utils/conan/llvm-core/ --version 14.0.6 --user secure-software-engineering`
207-
- `conan export utils/conan/clang/ --version 14.0.6 --user secure-software-engineering`
206+
- `conan export utils/conan/llvm-core/ --version 15.0.7 --user secure-software-engineering`
207+
- `conan export utils/conan/clang/ --version 15.0.7 --user secure-software-engineering`
208208
- `conan export .`
209209
- View exported `conan list "phasar/*"`
210210
- [Consume the package](https://docs.conan.io/2/tutorial/consuming_packages.html)

conanfile.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ class PhasarRecipe(ConanFile):
121121
"shared": [True, False],
122122
"fPIC": [True, False],
123123
"tests": [True, False],
124+
"llvm_version": ["ANY"],
124125
}
125126
default_options = {
126127
"with_z3": True,
127128
"shared": False,
128129
"fPIC": True,
129130
"tests": False,
131+
"llvm_version": "15.0.7"
130132
}
131133

132134
def _parse_gitignore(self, folder, additional_exclusions = [], invert=False):
@@ -208,7 +210,7 @@ def set_version(self):
208210
git = Git(self, self.recipe_folder)
209211
# XXX consider git.coordinates_to_conandata()
210212
if git.is_dirty():
211-
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.")
213+
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\".")
212214
self.output.info("No version information set, retrieving from git.")
213215
calver = git.run("show -s --date=format:'%Y.%m.%d' --format='%cd'")
214216
short_hash = git.run("show -s --format='%h'")
@@ -228,7 +230,7 @@ def config_options(self):
228230
def requirements(self):
229231
self.requires("boost/[>1.72.0 <=1.86.0]")
230232
self.requires("sqlite3/[>=3 <4]")
231-
self.requires("clang/14.0.6@secure-software-engineering", transitive_libs=True, transitive_headers=True)
233+
self.requires(f"clang/{self.options.llvm_version}@secure-software-engineering", transitive_libs=True, transitive_headers=True)
232234
self.requires("nlohmann_json/3.11.3", transitive_headers=True)
233235
self.requires("json-schema-validator/2.3.0", transitive_libs=True, transitive_headers=True)
234236

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

243245
def build_requirements(self):
244246
self.tool_requires("cmake/[>=3.25.0 <4.0.0]") # find_program validator

utils/conan/clang/conandata.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ sources:
22
"18.1.7":
33
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.7/clang-18.1.7.src.tar.xz
44
sha256: c9191e4896e43425a8fbbb29e3b25b3a83050781809fbd4d0ad2382bc4a5c43d
5+
"15.0.7":
6+
"clang":
7+
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang-15.0.7.src.tar.xz
8+
sha256: a6b673ef15377fb46062d164e8ddc4d05c348ff8968f015f7f4af03f51000067
9+
"cmake":
10+
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/cmake-15.0.7.src.tar.xz
11+
sha256: 8986f29b634fdaa9862eedda78513969fe9788301c9f2d938f4c10a3e7a3e7ea
512
"14.0.6":
613
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/clang-14.0.6.src.tar.xz
714
sha256: 2b5847b6a63118b9efe5c85548363c81ffe096b66c3b3675e953e26342ae4031
815
patches:
16+
"15.0.7":
17+
- patch_file: patches/15x/0000-force-import-original-llvm-config.patch
18+
patch_description: Imports definitions from original LLVMConfig
19+
patch_type: conan
20+
base_path: clang
921
"14.0.6":
1022
- patch_file: patches/14x/0000-force-import-original-llvm-config.patch
1123
patch_description: Imports definitions from original LLVMConfig

utils/conan/clang/conanfile.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,17 @@ def validate(self):
9595
)
9696

9797
def source(self):
98-
get(self, **self.conan_data["sources"][self.version])
99-
100-
clang_folder=f"clang-{self.version}.src"
101-
rename(self, "cmake/Modules", "cmake/modules")
102-
copy(self, pattern="*", src=clang_folder, dst=".")
103-
rmdir(self, clang_folder)
98+
if Version(self.version) >= 15:
99+
sources = self.conan_data["sources"][self.version]
100+
get(self, **sources["clang"], destination='clang', strip_root=True)
101+
get(self, **sources["cmake"], destination='cmake', strip_root=True)
102+
else:
103+
get(self, **self.conan_data["sources"][self.version])
104+
clang_folder=f"clang-{self.version}.src"
105+
if Path("cmake/Modules").exists():
106+
rename(self, "cmake/Modules", "cmake/modules")
107+
copy(self, pattern="*", src=clang_folder, dst=".")
108+
rmdir(self, clang_folder)
104109

105110
@property
106111
def _get_llvm_path(self):
@@ -123,7 +128,10 @@ def generate(self):
123128
def build(self):
124129
apply_conandata_patches(self)
125130
cmake = CMake(self)
126-
cmake.configure(cli_args=['--graphviz=graph/clang.dot'])
131+
if Version(self.version) >= 15:
132+
cmake.configure(build_script_folder="clang", cli_args=['--graphviz=graph/clang.dot'])
133+
else:
134+
cmake.configure(cli_args=['--graphviz=graph/clang.dot'])
127135
cmake.build()
128136

129137
def _clang_build_info(self):
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index e3bc4b468fb6..cf7a094ebb6e 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -70,6 +70,7 @@ if(CLANG_BUILT_STANDALONE)
6+
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
7+
endif()
8+
9+
+ include(LLVMConfig.original)
10+
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
11+
list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
12+

utils/conan/llvm-core/conandata.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
sources:
2+
"15.0.7":
3+
"llvm":
4+
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/llvm-15.0.7.src.tar.xz
5+
sha256: 4ad8b2cc8003c86d0078d15d987d84e3a739f24aae9033865c027abae93ee7a4
6+
"cmake":
7+
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/cmake-15.0.7.src.tar.xz
8+
sha256: 8986f29b634fdaa9862eedda78513969fe9788301c9f2d938f4c10a3e7a3e7ea
9+
210
"14.0.6":
311
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/llvm-14.0.6.src.tar.xz
412
sha256: 050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a
513

614
patches:
15+
"15.0.7":
16+
- patch_file: patches/15x/0000-cmake-dependencies.patch
17+
patch_description: fix references to third party libs to match conan variables and targets
18+
patch_type: conan
19+
base_path: llvm-main
20+
- patch_file: patches/15x/0001-calculate-job-pools.patch
21+
patch_description: calculate resource limits for compiling LLVM
22+
patch_type: portability
23+
patch_source: https://github.com/llvm/llvm-project/pull/65274
24+
base_path: llvm-main
25+
- patch_file: patches/15x/0003-no-build-with-install-rpath.patch
26+
patch_description: do not build shared libs with install rpath
27+
patch_type: conan
28+
base_path: llvm-main
29+
- patch_file: patches/15x/0004-remove-lto-exports.patch
30+
patch_description: remove LTO exports causing link error with lld
31+
patch_source: https://github.com/llvm/llvm-project-release-prs/pull/279
32+
patch_type: portability
33+
base_path: llvm-main
734
"14.0.6":
835
- patch_file: patches/14x/0000-cmake-dependencies.patch
936
patch_description: fix references to third party libs to match conan variables and targets

utils/conan/llvm-core/conanfile.py

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"BPF",
4141
"Hexagon",
4242
"Lanai",
43-
"Mips",
4443
"MSP430",
44+
"Mips",
4545
"NVPTX",
4646
"PowerPC",
4747
"RISCV",
@@ -94,6 +94,8 @@ class LLVMCoreConan(ConanFile):
9494
"with_zlib": [True, False],
9595
"with_xml2": [True, False],
9696
"with_z3": [True, False],
97+
'with_zstd': [True, False],
98+
'with_httplib': [True, False],
9799
}
98100
default_options = {
99101
"shared": False,
@@ -116,6 +118,8 @@ class LLVMCoreConan(ConanFile):
116118
"with_xml2": True,
117119
"with_z3": True, # not default
118120
"with_zlib": True,
121+
'with_zstd': True,
122+
'with_httplib': False,
119123
}
120124

121125
@property
@@ -143,6 +147,9 @@ def config_options(self):
143147
release = Version(self.version).major
144148
if release < 14:
145149
del self.options.with_curl
150+
if release < 15:
151+
del self.options.with_zstd
152+
del self.options.with_httplib
146153

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

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

215+
if self.options.get_safe("with_libedit") and self.options.use_sanitizer != 'None':
216+
raise ConanInvalidConfiguration("libedit can't be used with sanitizers")
217+
205218
def validate_build(self):
206219
if getenv("CONAN_CENTER_BUILD_SERVICE") and self.settings.build_type == "Debug":
207220
if self.settings.os == "Linux":
@@ -210,12 +223,17 @@ def validate_build(self):
210223
raise ConanInvalidConfiguration("Shared Debug build is not supported on CCI due to resource limitations")
211224

212225
def source(self):
213-
get(self, **self.conan_data["sources"][self.version])
214-
215-
llvm_folder=f"llvm-{self.version}.src"
216-
rename(self, "cmake/Modules", "cmake/modules")
217-
copy(self, pattern="*", src=llvm_folder, dst=".")
218-
rmdir(self, llvm_folder)
226+
if Version(self.version) >= 15:
227+
sources = self.conan_data["sources"][self.version]
228+
get(self, **sources["llvm"], destination='llvm-main', strip_root=True)
229+
get(self, **sources["cmake"], destination='cmake', strip_root=True)
230+
else:
231+
get(self, **self.conan_data["sources"][self.version])
232+
llvm_folder=f"llvm-{self.version}.src"
233+
if Path("cmake/Modules").exists():
234+
rename(self, "cmake/Modules", "cmake/modules")
235+
copy(self, pattern="*", src=llvm_folder, dst=".")
236+
rmdir(self, llvm_folder)
219237

220238
def _apply_resource_limits(self, cmake_definitions):
221239
if getenv("CONAN_CENTER_BUILD_SERVICE"):
@@ -244,12 +262,17 @@ def _all_targets(self):
244262
ver = Version(self.version).major
245263
if ver >= 14:
246264
targets.add("VE")
247-
if ver >= 15:
265+
if ver >= 16: # its available in 15 but not by default with "all"
248266
targets.add("LoongArch")
249267
return ";".join(targets)
250268

251269
def generate(self):
252270
tc = CMakeToolchain(self, generator="Ninja")
271+
272+
is_zstd_static = False
273+
if self.options.get_safe('with_zstd', False):
274+
is_zstd_static = not self.dependencies["zstd"].options.shared
275+
253276
# https://releases.llvm.org/12.0.0/docs/CMake.html
254277
# https://releases.llvm.org/13.0.0/docs/CMake.html
255278
# https://releases.llvm.org/14.0.0/docs/CMake.html
@@ -285,7 +308,10 @@ def generate(self):
285308
"LLVM_ENABLE_FFI": self.options.with_ffi,
286309
"LLVM_ENABLE_ZLIB": "FORCE_ON" if self.options.with_zlib else False,
287310
"LLVM_ENABLE_LIBXML2": "FORCE_ON" if self.options.with_xml2 else False,
288-
"LLVM_ENABLE_TERMINFO": self.options.with_terminfo
311+
"LLVM_ENABLE_TERMINFO": self.options.with_terminfo,
312+
'LLVM_ENABLE_ZSTD': 'FORCE_ON' if self.options.get_safe('with_zstd', False) else False,
313+
'LLVM_USE_STATIC_ZSTD': is_zstd_static,
314+
'LLVM_ENABLE_HTTPLIB': 'FORCE_ON' if self.options.get_safe('with_httplib', False) else False,
289315
}
290316
if self.options.targets != "all":
291317
cmake_variables["LLVM_TARGETS_TO_BUILD"] = self.options.targets
@@ -316,12 +342,17 @@ def generate(self):
316342
tc.generate()
317343

318344
tc = CMakeDeps(self)
345+
tc.set_property("editline", "cmake_file_name", "LibEdit")
346+
tc.set_property("editline", "cmake_target_name", "LibEdit::LibEdit")
319347
tc.generate()
320348

321349
def build(self):
322350
apply_conandata_patches(self)
323351
cmake = CMake(self)
324-
cmake.configure()
352+
if Version(self.version) >= 15:
353+
cmake.configure(build_script_folder="llvm-main")
354+
else:
355+
cmake.configure()
325356
cmake.build()
326357

327358
@property
@@ -335,7 +366,10 @@ def _sanitized_components(deps_list):
335366
replacements = {
336367
"LibXml2::LibXml2": "libxml2::libxml2",
337368
"ZLIB::ZLIB": "zlib::zlib",
338-
"CURL::libcurl": "libcurl::libcurl"
369+
"CURL::libcurl": "libcurl::libcurl",
370+
"LibEdit::LibEdit": "editline::editline",
371+
"httplib::httplib": "cpp-httplib::cpp-httplib",
372+
"zstd::libzstd_static": "zstd::zstd",
339373
}
340374
for dep in deps_list.split(";"):
341375
match = match_genex.search(dep)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
2+
index 7e657fd1532d..29f524927b30 100644
3+
--- a/cmake/config-ix.cmake
4+
+++ b/cmake/config-ix.cmake
5+
@@ -126,7 +126,7 @@ if(LLVM_ENABLE_ZLIB)
6+
# library on a 64-bit system which would result in a link-time failure.
7+
cmake_push_check_state()
8+
list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
9+
- list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARY})
10+
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES})
11+
check_symbol_exists(compress2 zlib.h HAVE_ZLIB)
12+
cmake_pop_check_state()
13+
if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB)
14+
@@ -203,7 +203,7 @@ if(LLVM_ENABLE_HTTPLIB)
15+
# Check if the "httplib" we found is usable; for example there may be another
16+
# library with the same name.
17+
cmake_push_check_state()
18+
- list(APPEND CMAKE_REQUIRED_LIBRARIES ${HTTPLIB_LIBRARY})
19+
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${HTTPLIB_LIBRARIES})
20+
check_cxx_symbol_exists(CPPHTTPLIB_HTTPLIB_H ${HTTPLIB_HEADER_PATH} HAVE_HTTPLIB)
21+
cmake_pop_check_state()
22+
if(LLVM_ENABLE_HTTPLIB STREQUAL FORCE_ON AND NOT HAVE_HTTPLIB)
23+
@@ -220,7 +220,7 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
24+
if (NOT PURE_WINDOWS)
25+
# Skip libedit if using ASan as it contains memory leaks.
26+
if (LLVM_ENABLE_LIBEDIT AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
27+
- find_package(LibEdit)
28+
+ find_package(LibEdit REQUIRED)
29+
set(HAVE_LIBEDIT ${LibEdit_FOUND})
30+
else()
31+
set(HAVE_LIBEDIT 0)
32+
diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt
33+
index ff23ec74df96..213605ebdea6 100644
34+
--- a/lib/Support/CMakeLists.txt
35+
+++ b/lib/Support/CMakeLists.txt
36+
@@ -293,7 +293,7 @@ if(LLVM_ENABLE_ZLIB)
37+
# CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
38+
if(CMAKE_BUILD_TYPE)
39+
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
40+
- get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type})
41+
+ set(zlib_library ${ZLIB_LIBRARIES})
42+
endif()
43+
if(NOT zlib_library)
44+
get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
45+
@@ -306,7 +306,7 @@ if(LLVM_ENABLE_ZSTD)
46+
# CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
47+
if(CMAKE_BUILD_TYPE)
48+
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
49+
- get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION_${build_type})
50+
+ set(zstd_library ${zstd_LIBRARIES})
51+
endif()
52+
if(NOT zstd_library)
53+
get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION)
54+
diff --git a/lib/WindowsManifest/CMakeLists.txt b/lib/WindowsManifest/CMakeLists.txt
55+
index 910132a4c7de..266d3b7faaa9 100644
56+
--- a/lib/WindowsManifest/CMakeLists.txt
57+
+++ b/lib/WindowsManifest/CMakeLists.txt
58+
@@ -21,10 +21,11 @@ add_llvm_component_library(LLVMWindowsManifest
59+
# This block is only needed for llvm-config. When we deprecate llvm-config and
60+
# move to using CMake export, this block can be removed.
61+
if(LLVM_ENABLE_LIBXML2)
62+
+ find_package(libxml2 REQUIRED CONFIG)
63+
# CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
64+
if(CMAKE_BUILD_TYPE)
65+
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
66+
- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type})
67+
+ set(libxml2_library ${libxml2_LIBRARIES})
68+
endif()
69+
if(NOT libxml2_library)
70+
get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION)

0 commit comments

Comments
 (0)