-
Notifications
You must be signed in to change notification settings - Fork 70
feat: add clang support to llvm-core Conan recipe #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zhangxffff
merged 8 commits into
bytedance:main
from
zhangxffff:feat/add_clang_to_llvm_recipe
Apr 19, 2026
+102
−2
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ff1fce0
feat: add clang support to llvm-core Conan recipe
zhangxffff 6083afd
fix: remove redundant buildenv_info PATH for clang
zhangxffff 4ed463b
fix: prioritize local recipe remotes over CI remote
zhangxffff af374cb
Revert "fix: prioritize local recipe remotes over CI remote"
zhangxffff e1bd370
feat: override only PR-modified Conan recipes in CI
zhangxffff a870387
fix: use $HOME instead of ~ for conan path expansion
zhangxffff ede552d
feat: verify clang exists in llvm-core package during conan install
zhangxffff 58f69d8
refactor: rename llvm-core patched version to 19.1.7-bolt
zhangxffff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
.github/actions/bolt-build-base/override-changed-recipes.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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-boltinstead, and then just have bolt's conanfile reference19.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.There was a problem hiding this comment.
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-corerecipe. However, without this script, changes toscripts/conan/patchesorscripts/conan/recipeswould not trigger a rebuild in CI unless the version is also updated. Since we always upload used conan recipes to theciserver, 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.bolt/.github/workflows/conan-upload.yml
Lines 75 to 81 in 17a2d9b
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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?