Skip to content

[ci] Make building native llvm into reusable action #611

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
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
178 changes: 178 additions & 0 deletions .github/actions/Build_LLVM/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: 'Builds LLVM'
description: 'This action builds LLVM for native platforms'
inputs:
cache-hit:
required: true

runs:
using: composite
steps:
- name: Build LLVM/Cling if the cache is invalid
if: ${{ inputs.cache-hit != 'true' && runner.os != 'Windows' }}
shell: bash
run: |
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else # repl
git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git
fi
cd llvm-project
# Build
mkdir build
if [[ "${cling_on}" == "ON" ]]; then
cd build
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}" \
-DLLVM_EXTERNAL_PROJECTS=cling \
-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
-G Ninja \
../llvm
ninja clang -j ${{ env.ncpus }}
ninja LLVMOrcDebugging -j ${{ env.ncpus }}
ninja clingInterpreter -j ${{ env.ncpus }}
else
# Apply patches
llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]')
if [[ "${llvm_vers}" == "16" ]]||[[ "${llvm_vers}" == "17" ]]; then
git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:"
fi
cd build
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" \
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
-G Ninja \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
../llvm
ninja clang clangInterpreter clangStaticAnalyzerCore -j ${{ env.ncpus }}
cd ./tools/
rm -rf $(find . -maxdepth 1 ! -name "clang" ! -name ".")
cd ..
rm compile_commands.json build.ninja
fi
cd ../
rm -rf $(find . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".")
if [[ "${cling_on}" == "ON" ]]; then
cd ./llvm/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".")
cd ../clang/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".")
cd ../../cling/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
else # repl
cd ./llvm/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ../clang/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ../..
fi


- name: Build LLVM/Cling on Windows systems if the cache is invalid
if: ${{ inputs.cache-hit != 'true' && runner.os == 'Windows' }}
shell: powershell
run: |

if ( "${{ matrix.cling }}" -imatch "On" )
{
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
$env:PWD_DIR= $PWD.Path
$env:CLING_DIR="$env:PWD_DIR\cling"
echo "CLING_DIR=$env:CLING_DIR"
}
else
{
git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git
}

cd llvm-project
# Build
mkdir build
if ( "${{ matrix.cling }}" -imatch "On" )
{
cd build
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" `
-DLLVM_EXTERNAL_PROJECTS=cling `
-DLLVM_EXTERNAL_CLING_SOURCE_DIR="$env:CLING_DIR" `
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" `
-DCMAKE_BUILD_TYPE=Release `
-DLLVM_ENABLE_ASSERTIONS=ON `
-DCLANG_ENABLE_STATIC_ANALYZER=OFF `
-DCLANG_ENABLE_ARCMT=OFF `
-DCLANG_ENABLE_FORMAT=OFF `
-DCLANG_ENABLE_BOOTSTRAP=OFF `
..\llvm
cmake --build . --config Release --target clang --parallel ${{ env.ncpus }}
cmake --build . --config Release --target LLVMOrcDebugging --parallel ${{ env.ncpus }}
cmake --build . --config Release --target clingInterpreter --parallel ${{ env.ncpus }}
}
else
{
cp -r ..\patches\llvm\clang${{ matrix.clang-runtime }}*
#FIXME: Apply patches without hardcoding
if ( "${{ matrix.clang-runtime }}" -imatch "16" )
{
git apply -v clang16-1-Value.patch
git apply -v clang16-2-CUDA.patch
git apply -v clang16-3-WeakRef.patch
}
elseif ( "${{ matrix.clang-runtime }}" -imatch "17" )
{
git apply -v clang17-1-NewOperator.patch
}
cd build
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:"
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" `
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" `
-DCMAKE_BUILD_TYPE=Release `
-DLLVM_ENABLE_ASSERTIONS=ON `
-DCLANG_ENABLE_STATIC_ANALYZER=OFF `
-DCLANG_ENABLE_ARCMT=OFF `
-DCLANG_ENABLE_FORMAT=OFF `
-DCLANG_ENABLE_BOOTSTRAP=OFF `
..\llvm
cmake --build . --config Release --target clang clangInterpreter clangStaticAnalyzerCore --parallel ${{ env.ncpus }}
}
cd ..\
rm -r -force $(find.exe . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".")
if ( "${{ matrix.cling }}" -imatch "On" )
{
cd .\llvm\
rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".")
cd ..\clang\
rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".")
cd ..\..\cling\
rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
}
else
{
cd .\llvm\
rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ..\clang\
rm -r -force $(find.exe . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ..\..
}
80 changes: 3 additions & 77 deletions .github/workflows/MacOS-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,83 +158,9 @@ jobs:
brew upgrade
brew install ninja

- name: Build LLVM/Cling if the cache is invalid
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else # repl
git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git
fi
cd llvm-project
# Build
mkdir build
if [[ "${cling_on}" == "ON" ]]; then
cd build
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}" \
-DLLVM_EXTERNAL_PROJECTS=cling \
-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
-G Ninja \
../llvm
ninja clang -j ${{ env.ncpus }}
ninja LLVMOrcDebugging -j ${{ env.ncpus }}
ninja clingInterpreter -j ${{ env.ncpus }}
else
# Apply patches
llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]')
if [[ "${llvm_vers}" == "16" ]]||[[ "${llvm_vers}" == "17" ]]; then
git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:"
fi
cd build
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" \
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
-G Ninja \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
../llvm
ninja clang clangInterpreter clangStaticAnalyzerCore -j ${{ env.ncpus }}
cd ./tools/
rm -rf $(find . -maxdepth 1 ! -name "clang" ! -name ".")
cd ..
rm compile_commands.json build.ninja
fi
cd ../
rm -rf $(find . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".")
if [[ "${cling_on}" == "ON" ]]; then
cd ./llvm/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".")
cd ../clang/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".")
cd ../../cling/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
else # repl
cd ./llvm/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ../clang/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ../..
fi
- uses: ./.github/actions/Build_LLVM
with:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The use of an input for my reusable action seems a bit of hack, but I couldn't get the reusable action to have access to 'steps.cache.outputs.cache-hit' otherwise. Will fix in a later PR which refines the actions.

cache-hit: ${{ steps.cache.outputs.cache-hit }}

- name: Save Cache LLVM/Clang runtime build directory
uses: actions/cache/save@v4
Expand Down
80 changes: 3 additions & 77 deletions .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,83 +142,9 @@ jobs:
brew upgrade
brew install ninja

- name: Build LLVM/Cling if the cache is invalid
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
git clone https://github.com/root-project/cling.git
cd ./cling
git checkout tags/v${{ matrix.cling-version }}
git apply -v ../patches/llvm/cling1.2-LookupHelper.patch
cd ..
git clone --depth=1 -b cling-llvm${{ matrix.clang-runtime }} https://github.com/root-project/llvm-project.git
else # repl
git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git
fi
cd llvm-project
# Build
mkdir build
if [[ "${cling_on}" == "ON" ]]; then
cd build
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}" \
-DLLVM_EXTERNAL_PROJECTS=cling \
-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling \
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
-G Ninja \
../llvm
ninja clang -j ${{ env.ncpus }}
ninja LLVMOrcDebugging -j ${{ env.ncpus }}
ninja clingInterpreter -j ${{ env.ncpus }}
else
# Apply patches
llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]')
if [[ "${llvm_vers}" == "16" ]]||[[ "${llvm_vers}" == "17" ]]; then
git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:"
fi
cd build
cmake -DLLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects}}" \
-DLLVM_TARGETS_TO_BUILD="${{ matrix.llvm_targets_to_build }}" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
-G Ninja \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
../llvm
ninja clang clangInterpreter clangStaticAnalyzerCore -j ${{ env.ncpus }}
cd ./tools/
rm -rf $(find . -maxdepth 1 ! -name "clang" ! -name ".")
cd ..
rm compile_commands.json build.ninja
fi
cd ../
rm -rf $(find . -maxdepth 1 ! -name "build" ! -name "llvm" ! -name "clang" ! -name ".")
if [[ "${cling_on}" == "ON" ]]; then
cd ./llvm/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".")
cd ../clang/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name "utils" ! -name ".")
cd ../../cling/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
else # repl
cd ./llvm/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ../clang/
rm -rf $(find . -maxdepth 1 ! -name "include" ! -name "lib" ! -name "cmake" ! -name ".")
cd ../..
fi
- uses: ./.github/actions/Build_LLVM
with:
cache-hit: ${{ steps.cache.outputs.cache-hit }}

- name: Save Cache LLVM/Clang runtime build directory
uses: actions/cache/save@v4
Expand Down
Loading
Loading