Skip to content

Commit d9fa16e

Browse files
committed
Port to LLVM 22 and shift the support window to clang 12-22.
LLVM 22 reshaped clang's type and lookup machinery enough that the port needs real wrappers, not one-liners: NestedNameSpecifier became a uintptr value type, ElaboratedType folded into TagType, and the ASTContext::get* / TagDecl factories rotated through new signatures (llvm/llvm-project#147835). Compatibility.h grows the wrappers; lib/Differentiator call sites move onto them. Older matrix rows stay NFC -- the wrappers are no-ops there. CHECK lines in four test files loosen for clang 22's TypePrinter drift (spellings only, no behaviour). Build-side bits: CMake bounds to 22.x, PassPlugin.h moved (llvm/Passes -> llvm/Plugins), and -Wno-macro-redefined silences LLVM's duplicate _GLIBCXX_USE_CXX11_ABI define on 22+. Add an LLVM 22 row to CI so the new code path is actually exercised. clad's window covers the last 10 majors, so 11 falls off. Bump the CMake floor to 12.0, drop the runtime11 CI row, and delete every `#if CLANG_VERSION_MAJOR < 12` branch. Wrappers that collapsed to one-line passthroughs get inlined at the call site and removed -- Expr_EvaluateAsConstantExpr, CXXMemberCallExpr_Create, SwitchStmt_Create, Sema_ActOnStartOfSwitchStmt, and five CLAD_COMPAT_CLANG{8,12}_* macros. CallExpr_Create, CUDAKernelCallExpr_Create and IfStmt_Create stay (too many parameters to inline cleanly, or still version-branching for clang 14).
1 parent b67a241 commit d9fa16e

20 files changed

Lines changed: 614 additions & 404 deletions

.github/workflows/ci.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ jobs:
3131
matrix:
3232

3333
include:
34-
# --- LINUX: Last 10 Runtimes (12-21) ---
34+
# --- LINUX: Last 11 Runtimes (12-22) ---
3535
# Using Ubuntu 22.04 for older runtimes, 24.04 for newer ones
36-
- { name: ubu22-gcc10-runtime11, os: ubuntu-22.04, compiler: gcc-10, clang-runtime: '11' }
3736
- { name: ubu22-gcc11-runtime12, os: ubuntu-22.04, compiler: gcc-11, clang-runtime: '12' }
3837
- { name: ubu22-clang13-runtime13, os: ubuntu-22.04, compiler: clang-13, clang-runtime: '13' }
3938
- { name: ubu24-gcc13-runtime14, os: ubuntu-24.04, compiler: gcc-13, clang-runtime: '14' }
@@ -44,6 +43,7 @@ jobs:
4443
- { name: ubu24-clang17-runtime19, os: ubuntu-24.04, compiler: clang-17, clang-runtime: '19' }
4544
- { name: ubu24-clang19-runtime20, os: ubuntu-24.04, compiler: clang-19, clang-runtime: '20' }
4645
- { name: ubu24-clang20-runtime21, os: ubuntu-24.04, compiler: clang-20, clang-runtime: '21' }
46+
- { name: ubu24-clang20-runtime22, os: ubuntu-24.04, compiler: clang-20, clang-runtime: '22' }
4747
# --- MACOS: Last 5 Runtimes (17-21) ---
4848
# Using macOS ARM (standard) for all; Runtime 17 on Intel for x86 sanity
4949
- { name: osx-intel-runtime17, os: macos-15-intel, compiler: clang, clang-runtime: '17' }
@@ -181,25 +181,26 @@ jobs:
181181
fi
182182
fi
183183
echo "ncpus=$ncpus" >> $GITHUB_ENV
184-
- name: Setup LLVM ${{ matrix.clang-runtime }}
184+
- name: Setup LLVM ${{ matrix.clang-runtime }}${{ matrix.flavor && format(' [{0}]', matrix.flavor) || '' }}
185185
if: runner.os != 'Windows' && matrix.debug_build != true
186186
uses: compiler-research/ci-workflows/actions/setup-llvm@main
187187
with:
188188
version: ${{ matrix.clang-runtime }}
189189
os: ${{ matrix.self-hosted-os || matrix.os }}
190-
flavor: system
190+
flavor: ${{ matrix.flavor || 'system' }}
191191

192192
- name: Install extra Linux deps
193-
# debug_build rows skip setup-llvm and never get apt-llvm.org, so
194-
# libomp-N-dev past the noble archive cap is unreachable. OpenMP
195-
# lit tests then skip on the debug row; other rows still cover them.
196193
if: runner.os == 'Linux' && matrix.debug_build != true
197194
run: |
198-
# setup-llvm covers llvm-N-dev + clang-N + libclang-N-dev +
199-
# libclang-rt-N-dev. Pick up libomp and per-row extras here.
200195
# cmake is preinstalled on github-hosted ubuntu-24.04 but absent
201196
# from catthehacker/ubuntu:act-24.04; install it so bin/repro works.
202-
sudo apt install -y cmake libomp-${{ matrix.clang-runtime }}-dev ${{ matrix.extra_packages }}
197+
sudo apt install -y cmake ${{ matrix.extra_packages }}
198+
# libomp-N-dev: best-effort. apt-llvm.org lags on the latest
199+
# major; recipe-flavor rows get libomp from the recipe build,
200+
# not apt. When missing, OpenMP lit tests skip via REQUIRES.
201+
if apt-cache show "libomp-${{ matrix.clang-runtime }}-dev" >/dev/null 2>&1; then
202+
sudo apt install -y "libomp-${{ matrix.clang-runtime }}-dev"
203+
fi
203204
204205
- name: Setup compiler on Linux
205206
if: runner.os == 'Linux'
@@ -328,12 +329,13 @@ jobs:
328329
- name: Setup LLVM/Clang on Linux
329330
if: ${{ (runner.os == 'Linux') && (matrix.debug_build != true) }}
330331
run: |
331-
UNIX_DISTRO=$(lsb_release -rs)
332-
PATH_TO_LLVM_BUILD=/usr/lib/llvm-${{ matrix.clang-runtime }}/
333-
# Add -H to silence 'The directory '/home/..../pip/http' or its parent
334-
# directory is not owned by the current user and the cache has been disabled.
332+
# setup-llvm always lands the install at $GITHUB_WORKSPACE/install
333+
# (a symlink to /usr/lib/llvm-N for flavor=system, a real install
334+
# tree for the recipe flavors). Point clad's build prefix there so
335+
# the cmake configs and their .a references resolve regardless of
336+
# flavor.
337+
PATH_TO_LLVM_BUILD="$GITHUB_WORKSPACE/install"
335338
pip3 install lit # LLVM lit is not part of the llvm releases...
336-
# We need PATH_TO_LLVM_BUILD later
337339
echo "PATH_TO_LLVM_BUILD=$PATH_TO_LLVM_BUILD" >> $GITHUB_ENV
338340
- name: Setup LLVM/Clang on Windows
339341
if: ${{ runner.os == 'windows' }}

CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ set(CMAKE_MODULE_PATH
3737
)
3838

3939
# Define clad supported version of clang and llvm.
40-
set(CLANG_MIN_SUPPORTED 11.0)
41-
set(CLANG_MAX_SUPPORTED "21.2.x")
42-
set(CLANG_VERSION_UPPER_BOUND 21.2.0)
43-
set(LLVM_MIN_SUPPORTED 11.0)
44-
set(LLVM_MAX_SUPPORTED "21.2.x")
45-
set(LLVM_VERSION_UPPER_BOUND 21.2.0)
40+
set(CLANG_MIN_SUPPORTED 12.0)
41+
set(CLANG_MAX_SUPPORTED "22.2.x")
42+
set(CLANG_VERSION_UPPER_BOUND 22.2.0)
43+
set(LLVM_MIN_SUPPORTED 12.0)
44+
set(LLVM_MAX_SUPPORTED "22.2.x")
45+
set(LLVM_VERSION_UPPER_BOUND 22.2.0)
4646

4747
# If we are not building as a part of LLVM, build clad as an
4848
# standalone project, using LLVM as an external library:
@@ -187,6 +187,13 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
187187

188188
add_definitions(${LLVM_DEFINITIONS})
189189

190+
# LLVM 22 sets _GLIBCXX_USE_CXX11_ABI twice (HandleLLVMOptions +
191+
# LLVMConfig), which trips -Werror=macro-redefined. Suppress that
192+
# specific warning -- it's an upstream duplication, not a code bug.
193+
if (LLVM_VERSION_MAJOR GREATER_EQUAL 22)
194+
add_compile_options(-Wno-macro-redefined)
195+
endif()
196+
190197
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/)
191198
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/)
192199

0 commit comments

Comments
 (0)