Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
5 changes: 5 additions & 0 deletions .github/actions/bolt-build-base/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ runs:
shell: bash
run: |
./scripts/install-bolt-deps.sh

- name: Override PR-modified Conan recipes
shell: bash
run: |
./.github/actions/bolt-build-base/override-changed-recipes.sh "${GITHUB_BASE_REF:-main}"
71 changes: 71 additions & 0 deletions .github/actions/bolt-build-base/override-changed-recipes.sh
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.

I think this script is too complex to be worth committing and maintaining. I would rather have the patch update the LLVM-core recipe version to 19.1.7-bolt instead, and then just have bolt's conanfile reference 19.1.7-bolt. No external conan remote will have that version, so it will be forced to get picked from the CCI local recipe index.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree with updating the version for the llvm-core recipe. However, without this script, changes to scripts/conan/patches or scripts/conan/recipes would not trigger a rebuild in CI unless the version is also updated. Since we always upload used conan recipes to the ci server, and it is always searched first, this overrides the CCI local recipe index and prevents us from picking up recipes from CCI local even we have a version that differs from official conan server.

- name: Upload packages to conan remote
env:
CONAN_LOGIN_USERNAME: ${{ secrets.CONAN_ADMIN_USERNAME }}
CONAN_PASSWORD: ${{ secrets.CONAN_ADMIN_PASSWORD }}
run: |
conan remote auth ci
conan upload -r ci --confirm "*"

If we remove this script, we would need to establish a convention that any modification to a recipe must be accompanied by a corresponding version update to ensure CI rebuilds the changed recipe.

Copy link
Copy Markdown
Collaborator

@ZacBlanco ZacBlanco Apr 17, 2026

Choose a reason for hiding this comment

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

I think having a convention where we update the recipe version is not a bad, but is somewhat tedious. I guess I am ok with this script for now then. If it presents issues in the future, we might want to look at other solutions.

Anyways, we can merge this then. Can you test on your other PR to make sure that this recipe works before merging though?

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# Copyright (c) ByteDance Ltd. and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Detect Conan recipes modified compared to a base branch and add them
# to an override remote at index 0. This ensures modified recipes
# rebuild from source while everything else reuses cached binaries
# from the CI remote.
#
# Two sources of recipe changes:
# 1. scripts/conan/patches/*.patch — CCI recipe patches
# 2. scripts/conan/recipes/<name>/ — bolt-local recipes
#
# Usage: ./scripts/override-changed-recipes.sh [base_ref]
# base_ref: git ref to diff against (default: main)
set -euo pipefail

BASE_REF="${1:-main}"
CCI_HOME="${CONAN_HOME:-$HOME/.conan2}/conan-center-index"
OVERRIDE_DIR="${CONAN_HOME:-$HOME/.conan2}/patched-recipes"

changed_files=$(git diff --name-only "origin/${BASE_REF}" -- scripts/conan/ 2> /dev/null || true)
if [ -z "$changed_files" ]; then
echo "ℹ️ No Conan recipe changes detected."
exit 0
fi

rm -rf "${OVERRIDE_DIR}"
mkdir -p "${OVERRIDE_DIR}/recipes"

override_recipes=""

# 1. CCI patches: extract recipe names from patch diff content
for patch_file in $(echo "$changed_files" | grep '^scripts/conan/patches/.*\.patch$' || true); do
if [ ! -f "$patch_file" ]; then
continue
fi
for recipe in $(sed -n 's|.*recipes/\([^/]*\)/.*|\1|p' "$patch_file" | sort -u); do
if [ -d "${CCI_HOME}/recipes/${recipe}" ] && [ ! -d "${OVERRIDE_DIR}/recipes/${recipe}" ]; then
cp -r "${CCI_HOME}/recipes/${recipe}" "${OVERRIDE_DIR}/recipes/${recipe}"
override_recipes="${override_recipes} ${recipe}"
fi
done
done

# 2. bolt-local recipes: extract recipe name from path
for recipe in $(echo "$changed_files" | sed -n 's|^scripts/conan/recipes/\([^/]*\)/.*|\1|p' | sort -u); do
if [ -d "scripts/conan/recipes/${recipe}" ] && [ ! -d "${OVERRIDE_DIR}/recipes/${recipe}" ]; then
cp -r "scripts/conan/recipes/${recipe}" "${OVERRIDE_DIR}/recipes/${recipe}"
override_recipes="${override_recipes} ${recipe}"
fi
done

if [ -z "$override_recipes" ]; then
echo "ℹ️ No recipe overrides needed."
exit 0
fi

conan remote add --index=0 -t "local-recipes-index" "bolt-patched" "${OVERRIDE_DIR}"
echo "✅ Override recipes:${override_recipes}"
10 changes: 10 additions & 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 Expand Up @@ -451,6 +452,15 @@ def generate(self):
tc.cache_variables["ENABLE_BOLT_JIT"] = "ON"
tc.preprocessor_definitions["ENABLE_BOLT_JIT"] = 1

# Verify clang exists in llvm-core package.
llvm_dep = self.dependencies["llvm-core"]
clang_path = os.path.join(str(llvm_dep.package_folder), "bin", "clang")
if not os.path.exists(clang_path):
raise Exception(
f"clang not found at {clang_path}. "
"Ensure llvm-core is built with -o llvm-core/*:with_clang=True"
)

# TODO: Refactor the IR codegen of expression evaluation
# Disable it right now
tc.cache_variables["ENABLE_BOLT_EXPR_JIT"] = "OFF"
Expand Down
64 changes: 64 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,64 @@
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..fb18c9dd 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)
2 changes: 1 addition & 1 deletion scripts/install-bolt-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
cd "${CUR_DIR}"

CONAN_CENTER_COMMIT_ID="bad5c95b810e859c1c31553b92584246fe436d69"
CCI_HOME="${CONAN_HOME:-~/.conan2}/conan-center-index"
CCI_HOME="${CONAN_HOME:-$HOME/.conan2}/conan-center-index"

if ! command -v conan &> /dev/null; then
echo "❌ Error: 'conan' command not found."
Expand Down