openshadinglanguage/openshadinglanguage-1.13.11.0-llvm-19.patch

117 lines
4.4 KiB
Diff

From 35a4ef87f672c747aa477a1f3143a07b9843c0c0 Mon Sep 17 00:00:00 2001
From: Larry Gritz <lg@larrygritz.com>
Date: Tue, 24 Sep 2024 08:25:49 -0700
Subject: [PATCH] build: Support for LLVM 19 (#1873)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
---
INSTALL.md | 4 ++--
src/build-scripts/gh-installdeps.bash | 9 +++++----
src/cmake/externalpackages.cmake | 2 +-
src/liboslexec/llvm_passes.h | 1 +
src/liboslexec/llvm_util.cpp | 14 +++++++++++---
5 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/INSTALL.md b/INSTALL.md
index d95b0db2e..17d608ef2 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -47,8 +47,8 @@ NEW or CHANGED dependencies since the last major release are **bold**.
$OpenImageIO_ROOT/lib to be in your LD_LIBRARY_PATH (or
DYLD_LIBRARY_PATH on OS X).
-* [LLVM](http://www.llvm.org) 9, 10, 11, 12, 13, 14, 15, 16, 17, or 18, including
- clang libraries.
+* [LLVM](http://www.llvm.org) 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, or 19,
+ including clang libraries.
* (optional) For GPU rendering on NVIDIA GPUs:
* [OptiX](https://developer.nvidia.com/rtx/ray-tracing/optix) 7.0 or higher.
diff --git a/src/build-scripts/gh-installdeps.bash b/src/build-scripts/gh-installdeps.bash
index 02f0ad31c..1e5012e25 100755
--- a/src/build-scripts/gh-installdeps.bash
+++ b/src/build-scripts/gh-installdeps.bash
@@ -94,11 +94,12 @@ else
libopencolorio-dev
if [[ "${QT_VERSION:-5}" == "5" ]] ; then
- time sudo apt-get -q install -y \
- qt5-default || /bin/true
+ time sudo apt-get -q install -y qt5-default || /bin/true
elif [[ "${QT_VERSION}" == "6" ]] ; then
- time sudo apt-get -q install -y \
- qt6-base-dev || /bin/true
+ time sudo apt-get -q install -y qt6-base-dev || /bin/true
+ fi
+ if [[ "${EXTRA_DEP_PACKAGES}" != "" ]] ; then
+ time sudo apt-get -q install -y ${EXTRA_DEP_PACKAGES}
fi
export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu:$CMAKE_PREFIX_PATH
diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake
index a652739cb..36aa570bf 100644
--- a/src/cmake/externalpackages.cmake
+++ b/src/cmake/externalpackages.cmake
@@ -58,7 +58,7 @@ checked_find_package (pugixml REQUIRED
# LLVM library setup
checked_find_package (LLVM REQUIRED
VERSION_MIN 9.0
- VERSION_MAX 18.9
+ VERSION_MAX 19.9
PRINT LLVM_SYSTEM_LIBRARIES CLANG_LIBRARIES)
# ensure include directory is added (in case of non-standard locations
include_directories (BEFORE SYSTEM "${LLVM_INCLUDES}")
diff --git a/src/liboslexec/llvm_passes.h b/src/liboslexec/llvm_passes.h
index 43c7a7289..d0a1b7502 100644
--- a/src/liboslexec/llvm_passes.h
+++ b/src/liboslexec/llvm_passes.h
@@ -12,6 +12,7 @@
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Instruction.h>
#include <llvm/IR/Instructions.h>
+#include <llvm/IR/Module.h>
#include <llvm/IR/PassManager.h>
#include <llvm/IR/Type.h>
#include <llvm/Pass.h>
diff --git a/src/liboslexec/llvm_util.cpp b/src/liboslexec/llvm_util.cpp
index de41e217f..dd1473b06 100644
--- a/src/liboslexec/llvm_util.cpp
+++ b/src/liboslexec/llvm_util.cpp
@@ -1173,7 +1173,12 @@ static llvm::StringMap<bool> sCpuFeatures;
static bool
populateCpuFeatures()
{
+#if OSL_LLVM_VERSION >= 190
+ sCpuFeatures = llvm::sys::getHostCPUFeatures();
+ return true;
+#else
return llvm::sys::getHostCPUFeatures(sCpuFeatures);
+#endif
}
@@ -1301,6 +1306,7 @@ static cspan<const char*>
get_required_cpu_features_for(TargetISA target)
{
switch (target) {
+ case TargetISA::UNKNOWN:
case TargetISA::NONE: return {};
case TargetISA::x64: return required_cpu_features_by_x64;
case TargetISA::SSE4_2: return required_cpu_features_by_SSE4_2;
@@ -1551,10 +1557,12 @@ LLVM_Util::make_jit_execengine(std::string* err, TargetISA requestedISA,
#if OSL_LLVM_VERSION < 120
options.StackAlignmentOverride = 0;
#endif
- options.FunctionSections = true;
- options.UseInitArray = false;
- options.FloatABIType = llvm::FloatABI::Default;
+ options.FunctionSections = true;
+ options.UseInitArray = false;
+ options.FloatABIType = llvm::FloatABI::Default;
+#if OSL_LLVM_VERSION < 190
options.RelaxELFRelocations = false;
+#endif
//options.DebuggerTuning = llvm::DebuggerKind::GDB;
// TODO: Find equivalent function for PrintMachineCode post LLVM 12