Skip to content

Commit 22aed11

Browse files
committed
[ci] Consolidate the OOP-JIT and in-process LLVM caches.
Two OOP-JIT cells (`ubu24-x86-gcc12-llvm22-oop-vg`, `osx26-arm-clang-llvm22-oop`) used a dedicated `-oop`-suffixed cache slot. `Build_LLVM` baked `llvm-jitlink-executor` and `orc_rt-<arch>` into that slot under a `matrix.oop-jit == 'On'` gate, and the matrix rows additionally enabled `llvm_enable_projects: clang;compiler-rt` so the orc_rt target existed in the LLVM build. The whole arrangement existed because OOP-JIT used to require `clang20-1-out-of-process.patch` (a 966-line backport of `clang::Interpreter::JITConfig`), which genuinely changed the cached binary. That patch retired in fb595ac (#924) when OOP-JIT moved to upstream `release/22.x`'s `clang::IncrementalExecutorBuilder`. The OOP and in-process LLVM builds are now identical modulo the two runtime-only artifacts (`llvm-jitlink-executor` and `orc_rt`). Drop the dedicated cache slot and source the runtime parts from packages instead, so OOP rows free-ride the same cache as their in-process counterparts. Cache-side: - `main.yml`: drop the `${{ matrix.oop-jit == 'On' && '-oop' || '' }}` segment from the cache key. Every non-OOP key is bit-identical to before, so existing cache entries continue to hit -- no invalidation. The previously `-oop`-suffixed entries become orphaned (still in storage until eviction, just unreferenced). - `main.yml` matrix: drop `llvm_enable_projects: clang;compiler-rt` from both OOP rows so they share build config, and therefore cache content, with their non-OOP twins on the same axes. - `Build_LLVM/action.yml`: drop the `if oop-jit == On: ninja llvm-jitlink-executor orc_rt-<suffix>` block. The cache now contains a vanilla LLVM build regardless of `matrix.oop-jit`. Runtime-side, OOP coverage preserved: - `main.yml` adds an `Install OOP-JIT runtime` step gated on `matrix.oop-jit == 'On'`. It installs the runtime parts via apt.llvm.org (`llvm-${runtime}` for the executor binary, `libclang-rt-${runtime}-dev` for the orc_rt static archive) on Linux, or `brew install llvm@${runtime}` on macOS. The install step then symlinks both into the test binary's expected resource-dir layout (`<test-bin-dir>/lib/clang/<major>/{bin,lib/<triple>}/`). That path matters: at test time `clang::IncrementalExecutor Builder` derives the resource directory from `getMainExecutable()` (the test binary), and the upstream safety check refuses to use an `orc_rt` whose path isn't under that directory. Symlinking before `Build_and_Test_ CppInterOp` runs is fine -- CppInterOp's build doesn't overwrite those paths. - `Build_and_Test_CppInterOp/action.yml` keeps both the `-DLLVM_BUILT_WITH_OOP_JIT=${{ matrix.oop-jit }}` cmake flag and the OOP-specific Valgrind suppression branch. The OOP test fixtures from PR #717 still parameterize over both in-process and OOP modes on those rows. The cached LLVM stays `LLVM_ENABLE_ASSERTIONS=ON`, so the JIT compiler that runs in-process during CppInterOp's tests still fires its internal assertions -- which is the assertion signal worth keeping. `orc_rt` and `llvm-jitlink-executor` are runtime support code, not assertion-rich, so sourcing them from packages doesn't lose coverage. Two follow-ups out of scope for this commit: - Retire the `LLVM_BUILT_WITH_OOP_JIT` macro from CppInterOp source. The compile-time gate becomes an LLVM-version / platform check, and a runtime check decides whether to actually use OOP. After that, `Build_and_Test_CppInterOp` no longer needs the cmake flag and the matrix's `oop-jit` field becomes purely a Valgrind-mode hint. - Bundle `orc_rt` (and ship `llvm-jitlink-executor`) inside `libclangCppInterOp.so`'s distribution so the library is self-contained. Removes the install step entirely.
1 parent fb595ac commit 22aed11

3 files changed

Lines changed: 71 additions & 13 deletions

File tree

.github/actions/Build_LLVM/action.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ runs:
5555
-DLLVM_INCLUDE_TESTS=OFF \
5656
../llvm
5757
ninja clang clangInterpreter clangStaticAnalyzerCore
58-
if [[ "${{ matrix.oop-jit }}" == "On" ]]; then
59-
if [[ "${{ matrix.os }}" == macos* ]]; then
60-
SUFFIX="_osx"
61-
elif [[ "${{ matrix.os }}" == ubuntu* ]]; then
62-
SUFFIX="-x86_64"
63-
fi
64-
ninja llvm-jitlink-executor orc_rt${SUFFIX} -j ${{ env.ncpus }}
65-
fi
6658
cd ./tools/
6759
rm -rf $(find . -maxdepth 1 ! -name "clang" ! -name ".")
6860
cd ..

.github/actions/Build_and_Test_CppInterOp/action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,15 @@ runs:
2828
export CB_PYTHON_DIR="$PWD/cppyy-backend/python"
2929
export CPPINTEROP_DIR="$CB_PYTHON_DIR/cppyy_backend"
3030
31-
# Build CppInterOp next to cling and llvm-project.
32-
mkdir build && cd build
31+
# Build CppInterOp next to cling and llvm-project. `-p` so we
32+
# tolerate the directory pre-existing -- the OOP-JIT install
33+
# step in `main.yml` symlinks runtime parts under
34+
# `<workspace>/build/unittests/CppInterOp/bin/<config>/` before
35+
# this step runs, which implicitly creates the top-level
36+
# `build/`. Without `-p`, the bare `mkdir` would fail and the
37+
# `&& cd build` short-circuit would leave us in `<workspace>`
38+
# with `cmake ../` resolving one level too high.
39+
mkdir -p build && cd build
3340
export CPPINTEROP_BUILD_DIR=$PWD
3441
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
3542
if [[ "${cling_on}" == "ON" ]]; then

.github/workflows/main.yml

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ jobs:
9595
os: ubuntu-24.04
9696
compiler: gcc-12
9797
clang-runtime: '22'
98-
llvm_enable_projects: "clang;compiler-rt"
9998
oop-jit: On
10099
Valgrind: On
101100
# MacOS Arm
@@ -106,7 +105,6 @@ jobs:
106105
os: macos-26
107106
compiler: clang
108107
clang-runtime: '22'
109-
llvm_enable_projects: "clang;compiler-rt"
110108
llvm_targets_to_build: host
111109
oop-jit: On
112110
# MacOS X86
@@ -136,7 +134,7 @@ jobs:
136134
path: |
137135
llvm-project
138136
${{ matrix.cling=='On' && 'cling' || '' }}
139-
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}-${{ matrix.root-llvm-tag || 'none' }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }}${{ matrix.oop-jit == 'On' && '-oop' || '' }}${{ matrix.sanitizer || '' }}
137+
key: ${{ env.CLING_HASH }}-${{ runner.os }}-${{ matrix.os }}-${{ matrix.compiler }}-clang-${{ matrix.clang-runtime }}-${{ matrix.root-llvm-tag || 'none' }}.x-patch-${{ hashFiles(format('patches/llvm/clang{0}-*.patch', matrix.clang-runtime)) || 'none' }}${{ matrix.sanitizer || '' }}
140138
- name: Setup default Build Type
141139
uses: ./.github/actions/Miscellaneous/Select_Default_Build_Type
142140

@@ -171,6 +169,67 @@ jobs:
171169
${{ matrix.cling=='On' && 'cling' || '' }}
172170
key: ${{ steps.cache.outputs.cache-primary-key }}
173171

172+
- name: Install OOP-JIT runtime
173+
# OOP rows used to bake `llvm-jitlink-executor` and
174+
# `orc_rt-<arch>` into the cached LLVM build (under a
175+
# `-oop`-suffixed cache slot). The cache slot is gone, so the
176+
# runtime parts are layered on top from system packages
177+
# instead. Symlinks point at the test binary's expected
178+
# resource-dir layout (`<test-bin-dir>/lib/clang/<major>/lib/
179+
# <triple>/`) -- that's where clang::IncrementalExecutorBuilder
180+
# looks at runtime, computed from getMainExecutable(). The
181+
# cached LLVM keeps `LLVM_ENABLE_ASSERTIONS=ON`, so the
182+
# in-process JIT compiler still fires its assertions during
183+
# tests; orc_rt and the executor are runtime support, not the
184+
# assertion-rich JIT, so sourcing them from packages doesn't
185+
# change the assertion signal.
186+
if: ${{ matrix.oop-jit == 'On' && runner.environment != 'self-hosted' }}
187+
shell: bash
188+
run: |
189+
set -eu
190+
BIN_DIR="${GITHUB_WORKSPACE}/build/unittests/CppInterOp/bin/${{ env.BUILD_TYPE }}"
191+
# Pre-create the resource-dir layout so symlinks land in
192+
# place before CppInterOp builds the test binary into the
193+
# same directory.
194+
mkdir -p "${BIN_DIR}"
195+
if [[ "${{ runner.os }}" == "Linux" ]]; then
196+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \
197+
| sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc > /dev/null
198+
codename="$(. /etc/os-release && echo $UBUNTU_CODENAME)"
199+
echo "deb http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-${{ matrix.clang-runtime }} main" \
200+
| sudo tee /etc/apt/sources.list.d/llvm.list > /dev/null
201+
sudo apt-get update
202+
sudo apt-get install -y \
203+
llvm-${{ matrix.clang-runtime }} \
204+
libclang-rt-${{ matrix.clang-runtime }}-dev
205+
PFX=/usr/lib/llvm-${{ matrix.clang-runtime }}
206+
mkdir -p "${BIN_DIR}/bin"
207+
ln -sf "${PFX}/bin/llvm-jitlink-executor" "${BIN_DIR}/bin/llvm-jitlink-executor"
208+
RT_SRC="${PFX}/lib/clang/${{ matrix.clang-runtime }}/lib"
209+
RT_DST="${BIN_DIR}/lib/clang/${{ matrix.clang-runtime }}/lib"
210+
for triple_dir in "${RT_SRC}"/*/; do
211+
[[ -d "${triple_dir}" ]] || continue
212+
triple=$(basename "${triple_dir}")
213+
mkdir -p "${RT_DST}/${triple}"
214+
for archive in "${triple_dir}"liborc_rt*.a; do
215+
[[ -f "${archive}" ]] || continue
216+
ln -sf "${archive}" "${RT_DST}/${triple}/$(basename "${archive}")"
217+
done
218+
done
219+
elif [[ "${{ runner.os }}" == "macOS" ]]; then
220+
brew install "llvm@${{ matrix.clang-runtime }}" || brew install llvm
221+
PFX="$(brew --prefix llvm@${{ matrix.clang-runtime }} 2>/dev/null || brew --prefix llvm)"
222+
mkdir -p "${BIN_DIR}/bin"
223+
ln -sf "${PFX}/bin/llvm-jitlink-executor" "${BIN_DIR}/bin/llvm-jitlink-executor"
224+
RT_SRC="${PFX}/lib/clang/${{ matrix.clang-runtime }}/lib/darwin"
225+
RT_DST="${BIN_DIR}/lib/clang/${{ matrix.clang-runtime }}/lib/darwin"
226+
mkdir -p "${RT_DST}"
227+
for archive in "${RT_SRC}"/liborc_rt*.a; do
228+
[[ -f "${archive}" ]] || continue
229+
ln -sf "${archive}" "${RT_DST}/$(basename "${archive}")"
230+
done
231+
fi
232+
174233
- name: Setup code coverage
175234
if: ${{ success() && (matrix.coverage == true) }}
176235
run: |

0 commit comments

Comments
 (0)