|
| 1 | +name: ROOT integration |
| 2 | + |
| 3 | +# Build ROOT (root-project/root master) against the CppInterOp tree |
| 4 | +# carried by the PR, by overwriting `interpreter/CppInterOp` in ROOT |
| 5 | +# with our checkout. Any breaking change CppInterOp introduces that |
| 6 | +# ROOT relies on shows up here as a configure or compile error. |
| 7 | +# |
| 8 | +# The job pins to the same axes as `main.yml`'s |
| 9 | +# ubu24-x86-gcc14-cling-llvm20-cppyy row so the LLVM/Cling cache key |
| 10 | +# resolves to the same string and the artifact is shared. |
| 11 | + |
| 12 | +on: |
| 13 | + pull_request: |
| 14 | + branches: [main] |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-root: |
| 23 | + name: ${{ matrix.name }} |
| 24 | + runs-on: ${{ matrix.os }} |
| 25 | + env: |
| 26 | + # Match main.yml's job-level CLING_VERSION so Save_PR_Info computes |
| 27 | + # CLING_HASH against the same git tag (refs/tags/v1.3) and the cache |
| 28 | + # key prefix matches. |
| 29 | + CLING_VERSION: '1.3' |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + # Mirror main.yml's `ubu24-x86-gcc14-cling-llvm20-cppyy` row's |
| 34 | + # cache-key inputs: same OS, compiler, clang-runtime, |
| 35 | + # root-llvm-tag. cppyy is set Off to keep the row's identity |
| 36 | + # distinct in CI logs while leaving the cache key bit-identical |
| 37 | + # to the cppyy variant (cppyy isn't in the cache key). |
| 38 | + include: |
| 39 | + # cling is quoted so YAML parsers that read `On` as a boolean |
| 40 | + # (e.g. nektos/act) still produce the string "On" that |
| 41 | + # Save_PR_Info compares against; without the quotes act takes |
| 42 | + # the else-branch and computes CLING_HASH=Repl, breaking the |
| 43 | + # cache-key alignment with main.yml's cling row. |
| 44 | + - { name: ubu24-x86-gcc14-cling-llvm20-root, os: ubuntu-24.04, compiler: gcc-14, clang-runtime: '20', cling: 'On', root-llvm-tag: 'cling-llvm20-20260119-01' } |
| 45 | + |
| 46 | + steps: |
| 47 | + - name: Checkout CppInterOp PR |
| 48 | + uses: actions/checkout@v6 |
| 49 | + with: |
| 50 | + path: cppinterop |
| 51 | + |
| 52 | + - name: Stage CppInterOp's patches at workspace root |
| 53 | + shell: bash |
| 54 | + run: | |
| 55 | + # main.yml's cache key uses `hashFiles('patches/llvm/clang{0}-*.patch')`, |
| 56 | + # which resolves relative to the workspace root. With the PR checked |
| 57 | + # out into `cppinterop/`, the symlink lets `hashFiles` find the same |
| 58 | + # files at the same path, keeping the cache key bit-identical to |
| 59 | + # the cling row in main.yml. Build_LLVM's cling-side `git apply |
| 60 | + # ../patches/llvm/cling1.2-LookupHelper.patch` also resolves through |
| 61 | + # the symlink on cache-miss runs. |
| 62 | + ln -s cppinterop/patches patches |
| 63 | +
|
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v6 |
| 66 | + with: |
| 67 | + python-version: '3.14' |
| 68 | + |
| 69 | + - name: Save PR Info |
| 70 | + uses: ./cppinterop/.github/actions/Miscellaneous/Save_PR_Info |
| 71 | + |
| 72 | + - name: Restore cached LLVM-${{ matrix.clang-runtime }} and Cling build |
| 73 | + uses: actions/cache/restore@v4 |
| 74 | + id: cache |
| 75 | + with: |
| 76 | + path: | |
| 77 | + llvm-project |
| 78 | + cling |
| 79 | + # Verbatim copy of main.yml's cache key so this job hits the cache |
| 80 | + # the cppyy cling row populates. |
| 81 | + 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 || '' }} |
| 82 | + |
| 83 | + - name: Setup default Build Type |
| 84 | + uses: ./cppinterop/.github/actions/Miscellaneous/Select_Default_Build_Type |
| 85 | + |
| 86 | + - name: Setup compiler |
| 87 | + uses: ./cppinterop/.github/actions/Miscellaneous/Setup_Compiler |
| 88 | + |
| 89 | + - name: Install dependencies |
| 90 | + uses: ./cppinterop/.github/actions/Miscellaneous/Install_Dependencies |
| 91 | + |
| 92 | + - name: Build LLVM-${{ matrix.clang-runtime }} and Cling on cache miss |
| 93 | + uses: ./cppinterop/.github/actions/Build_LLVM |
| 94 | + with: |
| 95 | + cache-hit: ${{ steps.cache.outputs.cache-hit }} |
| 96 | + |
| 97 | + - name: Cache LLVM-${{ matrix.clang-runtime }} and Cling build |
| 98 | + uses: actions/cache/save@v4 |
| 99 | + if: ${{ steps.cache.outputs.cache-hit != 'true' }} |
| 100 | + with: |
| 101 | + path: | |
| 102 | + llvm-project |
| 103 | + cling |
| 104 | + key: ${{ steps.cache.outputs.cache-primary-key }} |
| 105 | + |
| 106 | + - name: Verify cached LLVM/Clang layout |
| 107 | + shell: bash |
| 108 | + run: | |
| 109 | + # Sanity-check the artifact ROOT will consume. Whether we hit the |
| 110 | + # cache or rebuilt via Build_LLVM, both `LLVMConfig.cmake` and |
| 111 | + # `ClangConfig.cmake` must be in place at the expected build-tree |
| 112 | + # locations or the ROOT configure step will silently fall back to |
| 113 | + # system paths (which is how we previously got `Found LLVM 17`). |
| 114 | + # Also assert that `lib/clang/<version>` exists -- ROOT's |
| 115 | + # `core/clingutils/CMakeLists.txt:95` globs that directory and |
| 116 | + # expects exactly one entry. |
| 117 | + BUILD="$GITHUB_WORKSPACE/llvm-project/build" |
| 118 | + fail=0 |
| 119 | + for f in \ |
| 120 | + "$BUILD/lib/cmake/llvm/LLVMConfig.cmake" \ |
| 121 | + "$BUILD/lib/cmake/clang/ClangConfig.cmake"; do |
| 122 | + if [[ ! -f "$f" ]]; then |
| 123 | + echo "::error::missing $f" |
| 124 | + fail=1 |
| 125 | + else |
| 126 | + echo "ok: $f" |
| 127 | + fi |
| 128 | + done |
| 129 | + if [[ ! -d "$BUILD/lib/clang" ]]; then |
| 130 | + echo "::error::missing $BUILD/lib/clang" |
| 131 | + fail=1 |
| 132 | + else |
| 133 | + versions=$(ls "$BUILD/lib/clang" 2>/dev/null | tr '\n' ' ') |
| 134 | + echo "lib/clang/ entries: ${versions:-<empty>}" |
| 135 | + # ROOT requires exactly one entry in this directory. |
| 136 | + count=$(ls "$BUILD/lib/clang" 2>/dev/null | wc -l) |
| 137 | + if [[ "$count" -ne 1 ]]; then |
| 138 | + echo "::error::expected exactly 1 entry under $BUILD/lib/clang, found $count" |
| 139 | + fail=1 |
| 140 | + fi |
| 141 | + fi |
| 142 | + exit $fail |
| 143 | +
|
| 144 | + - name: Install ROOT system dependencies |
| 145 | + shell: bash |
| 146 | + run: | |
| 147 | + # Per https://root.cern/install/build_from_source/. Even with |
| 148 | + # `-Dminimal=ON`, ROOT still requires LibLZMA, libssl, X11 dev |
| 149 | + # headers, etc. Install the documented Ubuntu set rather than |
| 150 | + # opting in to ROOT's `-Dbuiltin_*` fallbacks (slower build). |
| 151 | + sudo apt-get update |
| 152 | + sudo apt-get install -y --no-install-recommends \ |
| 153 | + dpkg-dev binutils \ |
| 154 | + libx11-dev libxpm-dev libxft-dev libxext-dev \ |
| 155 | + libssl-dev liblzma-dev libpcre3-dev libpcre2-dev \ |
| 156 | + libxxhash-dev libzstd-dev libtbb-dev libxml2-dev \ |
| 157 | + nlohmann-json3-dev |
| 158 | + # The ubuntu-24.04 runner image ships llvm-17 dev packages, |
| 159 | + # whose `/usr/lib/llvm-17/lib/cmake/llvm` is found by ROOT's |
| 160 | + # `find_package(LLVM)` before our `-DLLVM_DIR` hint takes |
| 161 | + # effect (ROOT's interpreter subtree re-invokes find_package |
| 162 | + # in nested scopes). Purge them so only our cached LLVM 20 |
| 163 | + # remains visible. |
| 164 | + sudo apt-get purge -y 'llvm-17*' 'clang-17*' 'libclang-17*' 'libllvm17*' || true |
| 165 | + sudo apt-get autoremove -y |
| 166 | +
|
| 167 | + - name: Substitute the PR's CppInterOp into ROOT |
| 168 | + shell: bash |
| 169 | + run: | |
| 170 | + git clone --depth=1 --branch master https://github.com/root-project/root.git |
| 171 | + # ROOT bundles a copy of CppInterOp under interpreter/CppInterOp. |
| 172 | + # Replace it with the PR's tree so the integration build exercises |
| 173 | + # this PR's headers, sources, and CMake glue. |
| 174 | + rm -rf root/interpreter/CppInterOp |
| 175 | + cp -a cppinterop root/interpreter/CppInterOp |
| 176 | + # Strip the nested `.git` so ROOT's CMake doesn't get confused by |
| 177 | + # a sub-repository inside its own source tree. |
| 178 | + rm -rf root/interpreter/CppInterOp/.git |
| 179 | +
|
| 180 | + - name: Configure ROOT |
| 181 | + shell: bash |
| 182 | + run: | |
| 183 | + mkdir root-build |
| 184 | + cd root-build |
| 185 | + # ROOT uses our cached external LLVM and Clang (builtin_llvm / |
| 186 | + # builtin_clang off) but rebuilds cling from its own bundled |
| 187 | + # sources under interpreter/cling -- the bundled sources are |
| 188 | + # what ROOT's own version of CppInterOp is wired against, so |
| 189 | + # letting ROOT do that rebuild keeps the integration honest. |
| 190 | + # `-DLLVM_DIR` would be wiped by `interpreter/CMakeLists.txt:63` |
| 191 | + # (`set(LLVM_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm-project/llvm")`) |
| 192 | + # before ROOT's `find_package(LLVM REQUIRED CONFIG)` runs, so we |
| 193 | + # don't pass it. Resolution happens via CMAKE_PREFIX_PATH instead. |
| 194 | + # `fail-on-missing=ON` mirrors the nixpkgs ROOT recipe so any |
| 195 | + # silently-disabled feature surfaces as a configure-time error. |
| 196 | + # `-DCLANG_INSTALL_PREFIX` is required because our cached LLVM |
| 197 | + # ships its build-tree `ClangConfig.cmake`, whose @CLANG_CONFIG_CODE@ |
| 198 | + # substitution is empty (only the install-tree variant emits the |
| 199 | + # `find_prefix_from_config` snippet). Without this, ROOT's |
| 200 | + # `core/clingutils/CMakeLists.txt:87` resolves |
| 201 | + # `${CLANG_INSTALL_PREFIX}/lib/clang` to `/lib/clang` and globs the |
| 202 | + # runner's residual system clangs at `/usr/lib/clang/*`. |
| 203 | + cmake -G Ninja \ |
| 204 | + -DCMAKE_BUILD_TYPE=Release \ |
| 205 | + -Dminimal=ON \ |
| 206 | + -Dtesting=OFF \ |
| 207 | + -Dfail-on-missing=ON \ |
| 208 | + -Dbuiltin_llvm=OFF \ |
| 209 | + -Dbuiltin_clang=OFF \ |
| 210 | + -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/llvm-project/build" \ |
| 211 | + -DClang_DIR="$GITHUB_WORKSPACE/llvm-project/build/lib/cmake/clang" \ |
| 212 | + -DCLANG_INSTALL_PREFIX="$GITHUB_WORKSPACE/llvm-project/build" \ |
| 213 | + ../root |
| 214 | +
|
| 215 | + - name: Build ROOT |
| 216 | + shell: bash |
| 217 | + run: | |
| 218 | + cmake --build root-build --parallel ${{ env.ncpus }} |
0 commit comments