Skip to content
1 change: 1 addition & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def configure(self):
self.options[llvm_core].with_z3 = False
self.options[llvm_core].with_zstd = False
self.options[llvm_core].with_ffi = False
self.options[llvm_core].with_clang = True

if self.options.get_safe("enable_hdfs") and self.options.get_safe(
"use_arrow_hdfs"
Expand Down
72 changes: 72 additions & 0 deletions scripts/conan/patches/llvm-core-add-clang-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml
index dd26cdba..bc4c16a9 100644
--- a/recipes/llvm-core/all/conandata.yml
+++ b/recipes/llvm-core/all/conandata.yml
@@ -6,6 +6,9 @@ sources:
"cmake":
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.7/cmake-19.1.7.src.tar.xz
sha256: 11c5a28f90053b0c43d0dec3d0ad579347fc277199c005206b963c19aae514e3
+ "clang":
+ url: https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.7/clang-19.1.7.src.tar.xz
+ sha256: 11e5e4ecab5338b9914de3b83a4622cb200de466b7c56ba675afb72fa7d64675
"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
diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py
index e8290099..c6d1e93d 100644
--- a/recipes/llvm-core/all/conanfile.py
+++ b/recipes/llvm-core/all/conanfile.py
@@ -171,6 +171,7 @@ class LLVMCoreConan(ConanFile):
"with_xml2": [True, False],
"with_z3": [True, False],
"with_zstd": [True, False],
+ "with_clang": [True, False],
}
default_options = {
"shared": False,
@@ -193,6 +194,7 @@ class LLVMCoreConan(ConanFile):
"with_z3": True,
"with_zlib": True,
"with_zstd": True,
+ "with_clang": False,
}

@property
@@ -301,6 +303,8 @@ class LLVMCoreConan(ConanFile):
# LLVM >=15 split up several components in its release, including cmake
get(self, **sources["llvm"], destination='llvm-main', strip_root=True)
get(self, **sources["cmake"], destination='cmake', strip_root=True)
+ if "clang" in sources:
+ get(self, **sources["clang"], destination='clang', strip_root=True)

def _apply_resource_limits(self, cmake_definitions):
if os.getenv("CONAN_CENTER_BUILD_SERVICE"):
@@ -373,6 +377,9 @@ class LLVMCoreConan(ConanFile):
if self.options.targets != "all":
cmake_variables["LLVM_TARGETS_TO_BUILD"] = self.options.targets

+ if self.options.with_clang:
+ cmake_variables["LLVM_ENABLE_PROJECTS"] = "clang"
+
self._apply_resource_limits(cmake_variables)

if is_msvc(self):
@@ -415,7 +422,9 @@ class LLVMCoreConan(ConanFile):
"LLVMTableGenGlobalISel.*",
"CONAN_LIB.*",
"LLVMExegesis.*",
- "LLVMCFIVerify.*"
+ "LLVMCFIVerify.*",
+ "clang.*",
+ "libclang.*",
]
graphviz_options = textwrap.dedent(f"""
set(GRAPHVIZ_EXECUTABLES OFF)
@@ -547,3 +556,7 @@ class LLVMCoreConan(ConanFile):
else:
self.cpp_info.set_property("cmake_target_name", "LLVM")
self.cpp_info.libs = collect_libs(self)
+
+ if self.options.with_clang:
+ bindir = os.path.join(self.package_folder, "bin")
+ self.buildenv_info.prepend_path("PATH", bindir)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the conan documentation at https://docs.conan.io/2/reference/conanfile/methods/package_info.html

It is not necessary to add bindirs to the PATH environment variable, this will be automatically done by the consumer VirtualBuildEnv and VirtualRunEnv generators. Likewise, it is not necessary to add includedirs, libdirs or any other dirs to environment variables, as this information will be typically managed by other generators.

It looks like this is not necessary?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I am mistaken as bindir here is just the variable. But maybe LLVM should export it's bindir to the conan package so that the binaries are propagated?

On the same page, the example is

self.cpp_info.bindirs = ['bin']  # Directories where executables and shared libs can be found