Skip to content

Commit 7bcf83e

Browse files
authored
build: Support llvm 22, clang 22 for building (#2086)
Fix the minor API changes that came with LLVM 22. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent a0eb54e commit 7bcf83e

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

.github/workflows/build-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jobs:
144144
restore-keys: ${{inputs.nametag}}
145145
- name: Install LLVM and Clang
146146
if: inputs.llvm_action_ver != ''
147-
uses: KyleMayes/install-llvm-action@98e68e10c96dffcb7bfed8b2144541a66b49aa02 # v2.0.8
147+
uses: KyleMayes/install-llvm-action@ebc0426251bc40c7cd31162802432c68818ab8f0 # v2.0.9
148148
with:
149149
version: ${{ inputs.llvm_action_ver }}
150150
- name: Dependencies

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ jobs:
391391
setenvs: export LLVM_VERSION=14.0.0 LLVM_DISTRO_NAME=ubuntu-18.04
392392
OPENIMAGEIO_CMAKE_FLAGS="-DBUILD_FMT_VERSION=7.0.1"
393393
PUGIXML_VERSION=v1.10
394-
- desc: latest releases gcc13/C++17 llvm18 oiio-rel exr3.4 py3.12 avx2 batch-b16avx512
394+
- desc: latest releases gcc13/C++17 llvm20 oiio-rel exr3.4 py3.12 avx2 batch-b16avx512
395395
nametag: linux-latest-releases
396396
runner: ubuntu-24.04
397397
cc_compiler: gcc-14
@@ -604,7 +604,7 @@ jobs:
604604
# Windows 2022 / MSVS 17 case is below. It's not working yet,
605605
# work in progress.
606606
#
607-
- desc: Windows-2022 VS2022
607+
- desc: Windows-2022 VS2022 llvm20 oiio3.1
608608
runner: windows-2022
609609
nametag: windows-2022
610610
generator: "Visual Studio 17 2022"
@@ -617,7 +617,7 @@ jobs:
617617
PUGIXML_VERSION=v1.14
618618
OpenImageIO_BUILD_MISSING_DEPS="Freetype;TIFF;libdeflate;libjpeg-turbo"
619619
LLVM_GOOGLE_DRIVE_ID="1uy7PNVlTQ-H56unXGOS6siRWtNcdS1J7"
620-
- desc: Windows-2025 VS2022
620+
- desc: Windows-2025 VS2022 llvm20 oiio3.1
621621
runner: windows-2025
622622
nametag: windows-2025
623623
generator: "Visual Studio 17 2022"

INSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ NEW or CHANGED minimum dependencies since the last major release are **bold**.
2424

2525
* A suitable C++17 compiler to build OSL itself, which may be any of:
2626
- GCC 9.3 or newer (tested through gcc 14)
27-
- Clang 5 or newer (tested through clang 20)
27+
- Clang 5 or newer (tested through clang 22)
2828
- Microsoft Visual Studio 2017 or newer
2929
- Intel C++ compiler icc version 19 or newer or LLVM-based icx compiler
3030
version 2022 or newer.
@@ -50,7 +50,7 @@ NEW or CHANGED minimum dependencies since the last major release are **bold**.
5050
DYLD_LIBRARY_PATH on OS X).
5151

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

5555
* (optional) For GPU rendering on NVIDIA GPUs:
5656
* [OptiX](https://developer.nvidia.com/rtx/ray-tracing/optix) 7.0 or higher.

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 21.9
61+
VERSION_MAX 22.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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ OSLCompilerImpl::preprocess_buffer(const std::string& buffer,
201201
inst.setTarget(target);
202202

203203
inst.createFileManager();
204+
#if OSL_LLVM_VERSION >= 220
205+
inst.createSourceManager();
206+
#else
204207
inst.createSourceManager(inst.getFileManager());
208+
#endif
205209
clang::SourceManager& sm = inst.getSourceManager();
206210
sm.setMainFileID(sm.createFileID(std::move(mbuf), clang::SrcMgr::C_User));
207211

src/liboslexec/llvm_util.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,11 @@ LLVM_Util::make_jit_execengine(std::string* err, TargetISA requestedISA,
15431543
// TODO: investigate if reciprocals can be disabled by other means.
15441544
// Perhaps enable UnsafeFPMath, then modify creation of DIV instructions
15451545
// to remove the arcp (allow reciprocal) flag on that instructions
1546+
#if OSL_LLVM_VERSION < 220
1547+
// UnsafeFPMath was removed from TargetOptions in LLVM 22; FP math
1548+
// control is now handled via per-instruction fast-math flags in IR.
15461549
options.UnsafeFPMath = false;
1550+
#endif
15471551
// Since there are OSL language functions isinf and isnan,
15481552
// we cannot assume there will not be infs and NANs
15491553
options.NoInfsFPMath = false;
@@ -1805,7 +1809,11 @@ LLVM_Util::nvptx_target_machine()
18051809
// N.B. 'Standard' only allow fusion of 'blessed' ops (currently just
18061810
// fmuladd). To truly disable FMA and never fuse FP-ops, we need to
18071811
// instead use llvm::FPOpFusion::Strict.
1808-
options.UnsafeFPMath = 1;
1812+
#if OSL_LLVM_VERSION < 220
1813+
// UnsafeFPMath was removed from TargetOptions in LLVM 22; FP math
1814+
// control is now handled via per-instruction fast-math flags in IR.
1815+
options.UnsafeFPMath = 1;
1816+
#endif
18091817
options.NoInfsFPMath = 1;
18101818
options.NoNaNsFPMath = 1;
18111819
options.HonorSignDependentRoundingFPMathOption = 0;
@@ -1817,8 +1825,13 @@ LLVM_Util::nvptx_target_machine()
18171825

18181826
// Verify that the NVPTX target has been initialized
18191827
std::string error;
1828+
#if OSL_LLVM_VERSION >= 220
1829+
const llvm::Target* llvm_target
1830+
= llvm::TargetRegistry::lookupTarget(ModuleTriple, error);
1831+
#else
18201832
const llvm::Target* llvm_target
18211833
= llvm::TargetRegistry::lookupTarget(ModuleTriple.str(), error);
1834+
#endif
18221835
OSL_ASSERT(llvm_target
18231836
&& "PTX compile error: LLVM Target is not initialized");
18241837

0 commit comments

Comments
 (0)