Skip to content

Commit 2858176

Browse files
build: Add compatibility with LLVM 21
This adds LLVM 21 compatibility by adding the relevant code changes guarded by `#ifdev`-statements for backwards compatibility. Additionally also add CI checks for this. Signed-off-by: Christian Heusel <[email protected]>
1 parent 233a54a commit 2858176

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

.github/workflows/build-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
restore-keys: ${{inputs.nametag}}
135135
- name: Install LLVM and Clang
136136
if: inputs.llvm_action_ver != ''
137-
uses: KyleMayes/install-llvm-action@a7a1a882e2d06ebe05d5bb97c3e1f8c984ae96fc # v2.0.7
137+
uses: KyleMayes/install-llvm-action@98e68e10c96dffcb7bfed8b2144541a66b49aa02 # v2.0.8
138138
with:
139139
version: ${{ inputs.llvm_action_ver }}
140140
- name: Dependencies

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ jobs:
442442
openimageio_ver: main
443443
pybind11_ver: master
444444
python_ver: "3.12"
445-
llvm_action_ver: "18.1.7"
445+
llvm_action_ver: "21.1.3"
446446
simd: avx2,f16c
447447
batched: b8_AVX2,b8_AVX512,b16_AVX512
448448
setenvs: export PUGIXML_VERSION=master
@@ -545,15 +545,14 @@ jobs:
545545
python_ver: "3.13"
546546
aclang: 15
547547
setenvs: export LLVMBREWVER="@19"
548-
- desc: MacOS-15-ARM aclang16/C++17/py3.13 llvm19 oiio-main
548+
- desc: MacOS-15-ARM aclang16/C++17/py3.13 llvm21 oiio-main
549549
runner: macos-15
550550
nametag: macos15-arm-py313
551551
cc_compiler: clang
552552
cxx_compiler: clang++
553553
cxx_std: 17
554554
python_ver: "3.13"
555555
openimageio_ver: main
556-
setenvs: export LLVMBREWVER="@19"
557556

558557

559558
windows:

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ NEW or CHANGED minimum dependencies since the last major release are **bold**.
4949
$OpenImageIO_ROOT/lib to be in your LD_LIBRARY_PATH (or
5050
DYLD_LIBRARY_PATH on OS X).
5151

52-
* [LLVM](http://www.llvm.org) **14.0 or newer**, 15, 16, 17, 18, 19, 20,
52+
* [LLVM](http://www.llvm.org) **14.0 or newer**, 15, 16, 17, 18, 19, 20, 21,
5353
including clang libraries.
5454

5555
* (optional) For GPU rendering on NVIDIA GPUs:

src/cmake/externalpackages.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ checked_find_package (pugixml REQUIRED
5858
# LLVM library setup
5959
checked_find_package (LLVM REQUIRED
6060
VERSION_MIN 14.0
61-
VERSION_MAX 20.9
61+
VERSION_MAX 21.9
6262
PRINT LLVM_SYSTEM_LIBRARIES CLANG_LIBRARIES
6363
LLVM_SHARED_MODE)
6464
# ensure include directory is added (in case of non-standard locations

src/liboslcomp/oslcomp.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,32 @@ OSLCompilerImpl::preprocess_buffer(const std::string& buffer,
171171
llvm::raw_string_ostream errstream(preproc_errors);
172172
clang::DiagnosticOptions* diagOptions = new clang::DiagnosticOptions();
173173
clang::TextDiagnosticPrinter* diagPrinter
174+
#if OSL_LLVM_VERSION < 210
174175
= new clang::TextDiagnosticPrinter(errstream, diagOptions);
176+
#else
177+
= new clang::TextDiagnosticPrinter(errstream, *diagOptions);
178+
#endif
175179
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(
176180
new clang::DiagnosticIDs);
177181
clang::DiagnosticsEngine* diagEngine
182+
#if OSL_LLVM_VERSION < 210
178183
= new clang::DiagnosticsEngine(diagIDs, diagOptions, diagPrinter);
184+
#else
185+
= new clang::DiagnosticsEngine(diagIDs, *diagOptions, diagPrinter);
186+
#endif
179187
inst.setDiagnostics(diagEngine);
180188

181189
const std::shared_ptr<clang::TargetOptions> targetopts
182190
= std::make_shared<clang::TargetOptions>(inst.getTargetOpts());
183191
targetopts->Triple = llvm::sys::getDefaultTargetTriple();
184192
clang::TargetInfo* target
193+
#if OSL_LLVM_VERSION < 210
185194
= clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(),
186195
targetopts);
196+
#else
197+
= clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(),
198+
*targetopts);
199+
#endif
187200

188201
inst.setTarget(target);
189202

src/liboslexec/llvm_instance.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,11 @@ BackendLLVM::run()
22252225
// The triple is empty with recent versions of LLVM (e.g., 15) for reasons that aren't
22262226
// clear. So we must set them to the expected values.
22272227
// See: https://llvm.org/docs/NVPTXUsage.html
2228+
# if OSL_LLVM_VERSION < 210
22282229
ll.module()->setTargetTriple("nvptx64-nvidia-cuda");
2230+
# else
2231+
ll.module()->setTargetTriple(llvm::Triple("nvptx64-nvidia-cuda"));
2232+
# endif
22292233
ll.module()->setDataLayout(
22302234
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64");
22312235

0 commit comments

Comments
 (0)