Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-libs/osl/, media-libs/osl/files/
Date: Thu, 10 Jun 2021 00:51:43
Message-Id: 1623284356.7da3d02dd4d346906f0bdf7cd0df04f542706bb8.sam@gentoo
1 commit: 7da3d02dd4d346906f0bdf7cd0df04f542706bb8
2 Author: Sebastian Parborg <darkdefende <AT> gmail <DOT> com>
3 AuthorDate: Tue Apr 27 23:42:58 2021 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Thu Jun 10 00:19:16 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7da3d02d
7
8 media-libs/osl: bump to 1.12.0.2
9
10 Signed-off-by: Sebastian Parborg <darkdefende <AT> gmail.com>
11 Signed-off-by: Sam James <sam <AT> gentoo.org>
12
13 media-libs/osl/Manifest | 1 +
14 media-libs/osl/files/osl-1.12.0.2-llvm-11.patch | 29 +++
15 media-libs/osl/files/osl-1.12.0.2-llvm-12.patch | 240 ++++++++++++++++++++++++
16 media-libs/osl/osl-1.12.0.2.ebuild | 88 +++++++++
17 4 files changed, 358 insertions(+)
18
19 diff --git a/media-libs/osl/Manifest b/media-libs/osl/Manifest
20 index db1eb09c70c..d880f7d1d0f 100644
21 --- a/media-libs/osl/Manifest
22 +++ b/media-libs/osl/Manifest
23 @@ -1,2 +1,3 @@
24 DIST osl-1.10.13.tar.gz 13551733 BLAKE2B 63b687ec46bd5334a7d0c00cfa5bf5243003e16adf2637fba648a75f98c10103c7c4b5fa1d091ab43b0929f85523b0fa79589eca56686490ee61c48069593767 SHA512 bc39fcf80878160807e35c52654a2993a7d33b3ab2fbf567ec50d0b23636a19064830afab5734f1e39276c77e843bbfe1d6b10a64fd4ebe69b17c8faa5378201
25 DIST osl-1.11.9.0.tar.gz 14137334 BLAKE2B db68cb77d6af56e711b897371a4fe9386bf1a62625f9fa04012e9ec22346933fe3b0112301a8ad17ac6dd9c01c2a8e00c6d6e557d947870fd39bb3dec1443fd8 SHA512 f93bce0b29ff2da022372d81f2709c7db68e011c07c346b679c4b5ce05425f7eda8904779d7ea460817639e6be78a8c77272d71a3ffa8b068cfaab7572eb2e65
26 +DIST osl-1.12.0.2.tar.gz 16205315 BLAKE2B 543d120e981f093c121b4abb4c36d7d8c127555c8986df931a3040136e3ae3d84d602d73395604cd492f8d192e408f585cd6579fe6283c974778f0b99092985d SHA512 cdcd1fb348f6f2f1f889ed1895bac545e10b73e700959bc09b1df2a40cd86e69ba43a1dfaf26dedaec9c23aa17b74428d4bccc9cf7f4d27ae2fc5152adb6c010
27
28 diff --git a/media-libs/osl/files/osl-1.12.0.2-llvm-11.patch b/media-libs/osl/files/osl-1.12.0.2-llvm-11.patch
29 new file mode 100644
30 index 00000000000..a47bcd4e47d
31 --- /dev/null
32 +++ b/media-libs/osl/files/osl-1.12.0.2-llvm-11.patch
33 @@ -0,0 +1,29 @@
34 +From 84c26c0baab8f071270d0fef23175c24d738c73c Mon Sep 17 00:00:00 2001
35 +From: Brecht Van Lommel <brecht@×××××××.org>
36 +Date: Mon, 19 Apr 2021 13:49:22 +0200
37 +Subject: [PATCH] Fix crash generating closure functions calls with LLVM 11
38 +
39 +Generating code for prepare_closure and gen_closure was crashing.
40 +The code now matches the implementation of the removed LLVM function.
41 +
42 +Signed-off-by: Brecht Van Lommel <brecht@×××××××.org>
43 +---
44 + src/liboslexec/llvm_util.cpp | 5 +++--
45 + 1 file changed, 3 insertions(+), 2 deletions(-)
46 +
47 +diff --git a/src/liboslexec/llvm_util.cpp b/src/liboslexec/llvm_util.cpp
48 +index 445f64000..3d468de27 100644
49 +--- a/src/liboslexec/llvm_util.cpp
50 ++++ b/src/liboslexec/llvm_util.cpp
51 +@@ -3430,8 +3430,9 @@ LLVM_Util::call_function (llvm::Value *func, cspan<llvm::Value *> args)
52 + #endif
53 + //llvm_gen_debug_printf (std::string("start ") + std::string(name));
54 + #if OSL_LLVM_VERSION >= 110
55 +- OSL_DASSERT(llvm::isa<llvm::Function>(func));
56 +- llvm::Value *r = builder().CreateCall(llvm::cast<llvm::Function>(func), llvm::ArrayRef<llvm::Value *>(args.data(), args.size()));
57 ++ llvm::Value* r = builder().CreateCall(
58 ++ llvm::cast<llvm::FunctionType>(func->getType()->getPointerElementType()), func,
59 ++ llvm::ArrayRef<llvm::Value*>(args.data(), args.size()));
60 + #else
61 + llvm::Value *r = builder().CreateCall (func, llvm::ArrayRef<llvm::Value *>(args.data(), args.size()));
62 + #endif
63
64 diff --git a/media-libs/osl/files/osl-1.12.0.2-llvm-12.patch b/media-libs/osl/files/osl-1.12.0.2-llvm-12.patch
65 new file mode 100644
66 index 00000000000..dcf9ac863f7
67 --- /dev/null
68 +++ b/media-libs/osl/files/osl-1.12.0.2-llvm-12.patch
69 @@ -0,0 +1,240 @@
70 +commit f76ea6220a5f0d59f5f43d3d6d526f1fd09b90f7
71 +Author: Euan Haahr <euanhaahrmail2@×××××.com>
72 +Date: Fri Feb 5 22:51:14 2021 +0000
73 +
74 + Various fixes for LLVM 12 compatibility (1351)
75 +
76 + Removed use of options.PrintMachineCode since this has been removed as
77 + of llvm 12. Converted uses of DebugLoc::get to DILocation::get since
78 + it has been deprecated and removed as of llvm 12.
79 +
80 + PrintMachine code will only be used if llvm is lower than version 12.
81 + TODO: Needs to be re-added in the new way for LLVM12. (LG just doesn't
82 + have time to figure this out right now.)
83 +
84 + Pass adjustment as various things have been deprecated or changed
85 + names. (LG)
86 +
87 + Signed-off-by: Euan Haahr <euanhaahrmail2@×××××.com>
88 + Signed-off-by: Larry Gritz <lg@××××××××××.com>
89 +
90 +diff --git a/src/liboslexec/llvm_passes.h b/src/liboslexec/llvm_passes.h
91 +index 4ec3489c..7c14fc76 100644
92 +--- a/src/liboslexec/llvm_passes.h
93 ++++ b/src/liboslexec/llvm_passes.h
94 +@@ -73,9 +73,14 @@ public:
95 + // 16 bit and 32 bit native mask representation to be passed as a
96 + // livein.
97 + m_native_mask_type = llvm::FixedVectorType::get(llvm_type_int32, WidthT);
98 ++# if OSL_LLVM_VERSION >= 112
99 ++ m_wide_zero_initializer = llvm::ConstantDataVector::getSplat(WidthT,
100 ++ llvm::ConstantInt::get(M.getContext(), llvm::APInt(32,0)));
101 ++# else
102 + m_wide_zero_initializer = llvm::ConstantVector::getSplat(
103 + llvm::ElementCount(WidthT, false),
104 + llvm::ConstantInt::get (M.getContext(), llvm::APInt(32,0)));
105 ++# endif
106 + #else
107 + m_llvm_mask_type = llvm::VectorType::get(llvm_type_bool, WidthT);
108 + m_native_mask_type = llvm::VectorType::get(llvm_type_int32, WidthT);
109 +@@ -341,9 +346,8 @@ public:
110 + // of the mask promotion will always be correct here. Should 16 bit
111 + // support be needed, this pass could be extended.
112 + m_native_mask_type = llvm::FixedVectorType::get(llvm_type_int32, WidthT);
113 +- m_wide_zero_initializer = llvm::ConstantVector::getSplat(
114 +- llvm::ElementCount(WidthT, false),
115 +- llvm::ConstantInt::get (M.getContext(), llvm::APInt(32,0)));
116 ++ m_wide_zero_initializer = llvm::ConstantDataVector::getSplat(WidthT,
117 ++ llvm::ConstantInt::get(M.getContext(), llvm::APInt(32,0)));
118 + #else
119 + m_llvm_mask_type = llvm::VectorType::get(llvm_type_bool, WidthT);
120 + m_native_mask_type = llvm::VectorType::get(llvm_type_int32, WidthT);
121 +diff --git a/src/liboslexec/llvm_util.cpp b/src/liboslexec/llvm_util.cpp
122 +index fed8c5ec..b2a02f61 100644
123 +--- a/src/liboslexec/llvm_util.cpp
124 ++++ b/src/liboslexec/llvm_util.cpp
125 +@@ -20,6 +20,7 @@
126 + #include "llvm_passes.h"
127 +
128 + #include <llvm/InitializePasses.h>
129 ++#include <llvm/Pass.h>
130 + #include <llvm/IR/Constant.h>
131 + #include <llvm/IR/Constants.h>
132 + #include <llvm/IR/DebugInfo.h>
133 +@@ -59,6 +60,7 @@
134 + #include <llvm/Analysis/BasicAliasAnalysis.h>
135 + #include <llvm/Analysis/TypeBasedAliasAnalysis.h>
136 + #include <llvm/Analysis/TargetTransformInfo.h>
137 ++#include <llvm/IR/Function.h>
138 + #include <llvm/IR/Verifier.h>
139 + #include <llvm/Target/TargetMachine.h>
140 + #include <llvm/Target/TargetOptions.h>
141 +@@ -74,10 +76,9 @@
142 + #include <llvm/Transforms/Scalar/GVN.h>
143 + #include <llvm/Transforms/Utils.h>
144 +
145 +-
146 +-#include <llvm/Pass.h>
147 +-#include <llvm/IR/Function.h>
148 +-#include <llvm/Support/raw_ostream.h>
149 ++#if OSL_LLVM_VERSION >= 120
150 ++#include <llvm/CodeGen/Passes.h>
151 ++#endif
152 +
153 + // additional includes for PTX generation
154 + #include <llvm/Transforms/Utils/SymbolRewriter.h>
155 +@@ -129,6 +130,11 @@ static bool setup_done = false;
156 + static std::unique_ptr<std::vector<std::shared_ptr<LLVMMemoryManager> >> jitmm_hold;
157 + static int jit_mem_hold_users = 0;
158 +
159 ++
160 ++#if OSL_LLVM_VERSION >= 120
161 ++llvm::raw_os_ostream raw_cout(std::cout);
162 ++#endif
163 ++
164 + }; // end anon namespace
165 +
166 +
167 +@@ -701,7 +707,8 @@ LLVM_Util::debug_pop_function()
168 + // that has been finalized, point it back to the compilation unit
169 + OSL_ASSERT(m_builder);
170 + OSL_ASSERT(m_builder->getCurrentDebugLocation().get() != nullptr);
171 +- m_builder->SetCurrentDebugLocation(llvm::DebugLoc::get(static_cast<unsigned int>(1),
172 ++ m_builder->SetCurrentDebugLocation(llvm::DILocation::get(getCurrentDebugScope()->getContext(),
173 ++ static_cast<unsigned int>(1),
174 + static_cast<unsigned int>(0), /* column? we don't know it, may be worth tracking through osl->oso*/
175 + getCurrentDebugScope()));
176 +
177 +@@ -776,7 +783,8 @@ LLVM_Util::debug_set_location(ustring sourcefile, int sourceline)
178 + }
179 + if (newDebugLocation) {
180 + llvm::DebugLoc debug_location =
181 +- llvm::DebugLoc::get(static_cast<unsigned int>(sourceline),
182 ++ llvm::DILocation::get(sp->getContext(),
183 ++ static_cast<unsigned int>(sourceline),
184 + static_cast<unsigned int>(0), /* column? we don't know it, may be worth tracking through osl->oso*/
185 + sp,
186 + inlineSite);
187 +@@ -958,7 +966,8 @@ LLVM_Util::new_builder (llvm::BasicBlock *block)
188 + m_builder = new IRBuilder (block);
189 + if (this->debug_is_enabled()) {
190 + OSL_ASSERT(getCurrentDebugScope());
191 +- m_builder->SetCurrentDebugLocation(llvm::DebugLoc::get(static_cast<unsigned int>(1),
192 ++ m_builder->SetCurrentDebugLocation(llvm::DILocation::get(getCurrentDebugScope()->getContext(),
193 ++ static_cast<unsigned int>(1),
194 + static_cast<unsigned int>(0), /* column? we don't know it, may be worth tracking through osl->oso*/
195 + getCurrentDebugScope()));
196 + }
197 +@@ -1386,7 +1395,13 @@ LLVM_Util::make_jit_execengine (std::string *err,
198 + options.RelaxELFRelocations = false;
199 + //options.DebuggerTuning = llvm::DebuggerKind::GDB;
200 +
201 ++ // TODO: Find equivalent function for PrintMachineCode post LLVM 12
202 ++#if OSL_LLVM_VERSION < 120
203 ++ // This option disappeared from the TargetOptions struct in LLVM 12.
204 ++ // It is instead accomplished with a MachineFunctionPrinterPass.
205 + options.PrintMachineCode = dumpasm();
206 ++#endif
207 ++
208 + engine_builder.setTargetOptions(options);
209 +
210 + detect_cpu_features(requestedISA, !jit_fma());
211 +@@ -1715,14 +1730,14 @@ LLVM_Util::setup_optimization_passes (int optlevel, bool target_host)
212 +
213 + mpm.add(llvm::createReassociatePass());
214 + mpm.add(llvm::createConstantPropagationPass());
215 +- mpm.add(llvm::createDeadInstEliminationPass());
216 ++ mpm.add(llvm::createDeadCodeEliminationPass());
217 + mpm.add(llvm::createCFGSimplificationPass());
218 +
219 + mpm.add(llvm::createPromoteMemoryToRegisterPass());
220 + mpm.add(llvm::createAggressiveDCEPass());
221 +
222 + mpm.add(llvm::createInstructionCombiningPass());
223 +- mpm.add(llvm::createDeadInstEliminationPass());
224 ++ mpm.add(llvm::createDeadCodeEliminationPass());
225 +
226 + mpm.add(llvm::createJumpThreadingPass());
227 + mpm.add(llvm::createSROAPass());
228 +@@ -1746,8 +1761,10 @@ LLVM_Util::setup_optimization_passes (int optlevel, bool target_host)
229 +
230 + // Eliminate and remove as much as possible up front
231 + mpm.add(llvm::createReassociatePass());
232 ++#if OSL_LLVM_VERSION < 120
233 + mpm.add(llvm::createConstantPropagationPass());
234 +- mpm.add(llvm::createDeadInstEliminationPass());
235 ++#endif
236 ++ mpm.add(llvm::createDeadCodeEliminationPass());
237 + mpm.add(llvm::createCFGSimplificationPass());
238 +
239 + mpm.add(llvm::createPromoteMemoryToRegisterPass());
240 +@@ -1784,7 +1801,7 @@ LLVM_Util::setup_optimization_passes (int optlevel, bool target_host)
241 + mpm.add(llvm::createInstructionCombiningPass());
242 +
243 + mpm.add(llvm::createPromoteMemoryToRegisterPass());
244 +- mpm.add(llvm::createDeadInstEliminationPass());
245 ++ mpm.add(llvm::createDeadCodeEliminationPass());
246 +
247 + mpm.add(llvm::createGlobalDCEPass());
248 + mpm.add(llvm::createConstantMergePass());
249 +@@ -1803,8 +1820,10 @@ LLVM_Util::setup_optimization_passes (int optlevel, bool target_host)
250 + mpm.add(llvm::createLowerExpectIntrinsicPass());
251 +
252 + mpm.add(llvm::createReassociatePass());
253 ++#if OSL_LLVM_VERSION < 120
254 + mpm.add(llvm::createConstantPropagationPass());
255 +- mpm.add(llvm::createDeadInstEliminationPass());
256 ++#endif
257 ++ mpm.add(llvm::createDeadCodeEliminationPass());
258 + mpm.add(llvm::createCFGSimplificationPass());
259 +
260 + mpm.add(llvm::createPromoteMemoryToRegisterPass());
261 +@@ -1814,7 +1833,7 @@ LLVM_Util::setup_optimization_passes (int optlevel, bool target_host)
262 + // optimizations, should attempt to reduce the number of times it is
263 + // executed, if at all
264 + mpm.add(llvm::createInstructionCombiningPass());
265 +- mpm.add(llvm::createDeadInstEliminationPass());
266 ++ mpm.add(llvm::createDeadCodeEliminationPass());
267 +
268 + mpm.add(llvm::createSROAPass());
269 + mpm.add(llvm::createInstructionCombiningPass());
270 +@@ -1822,7 +1841,16 @@ LLVM_Util::setup_optimization_passes (int optlevel, bool target_host)
271 + mpm.add(llvm::createPromoteMemoryToRegisterPass());
272 + mpm.add(llvm::createGlobalOptimizerPass());
273 + mpm.add(llvm::createReassociatePass());
274 ++#if OSL_LLVM_VERSION < 120
275 + mpm.add(llvm::createIPConstantPropagationPass());
276 ++#else
277 ++ // createIPConstantPropagationPass disappeared with LLVM 12.
278 ++ // Comments in their PR indicate that IPSCCP is better, but I don't
279 ++ // know if that means such a pass should be *right here*. I leave it
280 ++ // to others who use opt==13 to continue to curate this particular
281 ++ // list of passes.
282 ++ mpm.add(llvm::createIPSCCPPass());
283 ++#endif
284 +
285 + mpm.add(llvm::createDeadArgEliminationPass());
286 + mpm.add(llvm::createInstructionCombiningPass());
287 +@@ -1831,8 +1859,10 @@ LLVM_Util::setup_optimization_passes (int optlevel, bool target_host)
288 + mpm.add(llvm::createPostOrderFunctionAttrsLegacyPass());
289 + mpm.add(llvm::createReversePostOrderFunctionAttrsPass());
290 + mpm.add(llvm::createFunctionInliningPass());
291 ++#if OSL_LLVM_VERSION < 120
292 + mpm.add(llvm::createConstantPropagationPass());
293 +- mpm.add(llvm::createDeadInstEliminationPass());
294 ++#endif
295 ++ mpm.add(llvm::createDeadCodeEliminationPass());
296 + mpm.add(llvm::createCFGSimplificationPass());
297 +
298 + mpm.add(llvm::createArgumentPromotionPass());
299 +@@ -1845,8 +1875,9 @@ LLVM_Util::setup_optimization_passes (int optlevel, bool target_host)
300 + mpm.add(llvm::createTailCallEliminationPass());
301 +
302 + mpm.add(llvm::createFunctionInliningPass());
303 ++#if OSL_LLVM_VERSION < 120
304 + mpm.add(llvm::createConstantPropagationPass());
305 +-
306 ++#endif
307 +
308 + mpm.add(llvm::createIPSCCPPass());
309 + mpm.add(llvm::createDeadArgEliminationPass());
310
311 diff --git a/media-libs/osl/osl-1.12.0.2.ebuild b/media-libs/osl/osl-1.12.0.2.ebuild
312 new file mode 100644
313 index 00000000000..a312fa3bc86
314 --- /dev/null
315 +++ b/media-libs/osl/osl-1.12.0.2.ebuild
316 @@ -0,0 +1,88 @@
317 +# Copyright 1999-2021 Gentoo Authors
318 +# Distributed under the terms of the GNU General Public License v2
319 +
320 +EAPI=7
321 +inherit cmake llvm toolchain-funcs
322 +
323 +# check this on updates
324 +LLVM_MAX_SLOT=12
325 +
326 +DESCRIPTION="Advanced shading language for production GI renderers"
327 +HOMEPAGE="http://opensource.imageworks.com/?p=osl"
328 +SRC_URI="https://github.com/imageworks/OpenShadingLanguage/archive/Release-${PV}-dev.tar.gz -> ${P}.tar.gz"
329 +
330 +LICENSE="BSD"
331 +SLOT="0"
332 +KEYWORDS="~amd64 ~x86"
333 +
334 +X86_CPU_FEATURES=(
335 + sse2:sse2 sse3:sse3 ssse3:ssse3 sse4_1:sse4.1 sse4_2:sse4.2
336 + avx:avx avx2:avx2 avx512f:avx512f f16c:f16c
337 +)
338 +CPU_FEATURES=( ${X86_CPU_FEATURES[@]/#/cpu_flags_x86_} )
339 +
340 +IUSE="doc partio qt5 test ${CPU_FEATURES[@]%:*}"
341 +
342 +RDEPEND="
343 + dev-libs/boost:=
344 + dev-libs/pugixml
345 + media-libs/openexr:=
346 + media-libs/openimageio:=
347 + <=sys-devel/clang-13:=
348 + sys-libs/zlib:=
349 + dev-python/pybind11
350 + partio? ( media-libs/partio )
351 + qt5? (
352 + dev-qt/qtcore:5
353 + dev-qt/qtgui:5
354 + dev-qt/qtwidgets:5
355 + )
356 +"
357 +
358 +DEPEND="${RDEPEND}"
359 +BDEPEND="
360 + sys-devel/bison
361 + sys-devel/flex
362 + virtual/pkgconfig
363 +"
364 +
365 +PATCHES=(
366 + ${FILESDIR}/${P}-llvm-11.patch
367 + ${FILESDIR}/${P}-llvm-12.patch
368 +)
369 +
370 +# Restricting tests as Make file handles them differently
371 +RESTRICT="test"
372 +
373 +S="${WORKDIR}/OpenShadingLanguage-Release-${PV}-dev"
374 +
375 +llvm_check_deps() {
376 + has_version -r "sys-devel/clang:${LLVM_SLOT}"
377 +}
378 +
379 +src_configure() {
380 + local cpufeature
381 + local mysimd=()
382 + for cpufeature in "${CPU_FEATURES[@]}"; do
383 + use "${cpufeature%:*}" && mysimd+=("${cpufeature#*:}")
384 + done
385 +
386 + # If no CPU SIMDs were used, completely disable them
387 + [[ -z ${mysimd} ]] && mysimd=("0")
388 +
389 + local gcc=$(tc-getCC)
390 + # LLVM needs CPP11. Do not disable.
391 + local mycmakeargs=(
392 + -DCMAKE_CXX_STANDARD=14
393 + -DCMAKE_INSTALL_DOCDIR="share/doc/${PF}"
394 + -DINSTALL_DOCS=$(usex doc)
395 + -DLLVM_STATIC=OFF
396 + -DOSL_BUILD_TESTS=$(usex test)
397 + -DSTOP_ON_WARNING=OFF
398 + -DUSE_PARTIO=$(usex partio)
399 + -DUSE_QT=$(usex qt5)
400 + -DUSE_SIMD="$(IFS=","; echo "${mysimd[*]}")"
401 + )
402 +
403 + cmake_src_configure
404 +}