diff --git a/04dd02515d1ee05e26629ba540afc53986ae60e0.patch b/04dd02515d1ee05e26629ba540afc53986ae60e0.patch new file mode 100644 index 0000000..e832e9c --- /dev/null +++ b/04dd02515d1ee05e26629ba540afc53986ae60e0.patch @@ -0,0 +1,65 @@ +From 04dd02515d1ee05e26629ba540afc53986ae60e0 Mon Sep 17 00:00:00 2001 +From: Bastien Montagne +Date: Fri, 18 Feb 2022 11:05:34 +0100 +Subject: [PATCH] Fix compilation on GCC11. + +GCC11 removed some 'implicit includes', see +https://www.gnu.org/software/gcc/gcc-11/porting_to.html#header-dep-changes +for reference. +--- + pxr/base/js/testenv/testJsWriter.cpp | 1 + + pxr/base/tf/testenv/weakPtr.cpp | 1 + + pxr/base/work/singularTask.h | 2 +- + pxr/usd/sdr/shaderMetadataHelpers.h | 2 ++ + 4 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/pxr/base/js/testenv/testJsWriter.cpp b/pxr/base/js/testenv/testJsWriter.cpp +index cd897b8f4c..bd2a1788a0 100644 +--- a/pxr/base/js/testenv/testJsWriter.cpp ++++ b/pxr/base/js/testenv/testJsWriter.cpp +@@ -29,6 +29,7 @@ + #include "pxr/base/tf/diagnostic.h" + + #include ++#include + + PXR_NAMESPACE_USING_DIRECTIVE + +diff --git a/pxr/base/tf/testenv/weakPtr.cpp b/pxr/base/tf/testenv/weakPtr.cpp +index 6950d502d3..53e55d48b7 100644 +--- a/pxr/base/tf/testenv/weakPtr.cpp ++++ b/pxr/base/tf/testenv/weakPtr.cpp +@@ -37,6 +37,7 @@ + #include + #include + #include ++#include + + PXR_NAMESPACE_USING_DIRECTIVE + +diff --git a/pxr/base/work/singularTask.h b/pxr/base/work/singularTask.h +index 0c7914d0b7..bc82bbf748 100644 +--- a/pxr/base/work/singularTask.h ++++ b/pxr/base/work/singularTask.h +@@ -108,7 +108,7 @@ class WorkSingularTask + // case we go again to ensure the task can do whatever it + // was awakened to do. Once we successfully take the count + // to zero, we stop. +- size_t old = count; ++ std::size_t old = count; + do { _fn(); } while ( + !count.compare_exchange_strong(old, 0)); + }); +diff --git a/pxr/usd/sdr/shaderMetadataHelpers.h b/pxr/usd/sdr/shaderMetadataHelpers.h +index 1402a27e71..0ed3274a94 100644 +--- a/pxr/usd/sdr/shaderMetadataHelpers.h ++++ b/pxr/usd/sdr/shaderMetadataHelpers.h +@@ -32,6 +32,8 @@ + #include "pxr/base/tf/token.h" + #include "pxr/usd/sdr/declare.h" + ++#include ++ + PXR_NAMESPACE_OPEN_SCOPE + + /// \namespace ShaderMetadataHelpers diff --git a/USD-21.11-disable-malloc-hooks.patch b/USD-21.11-disable-malloc-hooks.patch new file mode 100644 index 0000000..e9164cb --- /dev/null +++ b/USD-21.11-disable-malloc-hooks.patch @@ -0,0 +1,23 @@ +diff -Naur USD-21.11-original/pxr/base/arch/mallocHook.cpp USD-21.11/pxr/base/arch/mallocHook.cpp +--- USD-21.11-original/pxr/base/arch/mallocHook.cpp 2021-11-01 13:10:51.000000000 -0400 ++++ USD-21.11/pxr/base/arch/mallocHook.cpp 2022-03-31 17:26:22.176739670 -0400 +@@ -177,7 +177,7 @@ + _underlyingMemalignFunc || _underlyingFreeFunc; + } + +-#if defined(ARCH_OS_LINUX) ++#if 0 + template + static bool _GetSymbol(T* addr, const char* name, string* errMsg) { + if (void* symbol = dlsym(RTLD_DEFAULT, name)) { +@@ -241,8 +241,8 @@ + ARCH_UNUSED_ARG void (*freeWrapper)(void*, const void*), + string* errMsg) + { +-#if !defined(ARCH_OS_LINUX) +- *errMsg = "ArchMallocHook functionality not implemented for non-linux systems"; ++#if 1 ++ *errMsg = "ArchMallocHook functionality not implemented"; + return false; + #else + if (IsInitialized()) { diff --git a/stb_image.patch b/stb_image.patch new file mode 100644 index 0000000..a8a3a30 --- /dev/null +++ b/stb_image.patch @@ -0,0 +1,155 @@ +--- stb/stb_image.h 2021-09-16 11:52:38.284782000 -0700k ++++ stb_image.h 2021-09-16 13:45:48.159770000 -0700 +@@ -488,14 +488,14 @@ + STBIDEF void stbi_image_free (void *retval_from_stbi_load); + + // get image dimensions & components without fully decoding +-STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); +-STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); ++STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, float *gamma); ++STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, float *gamma); + STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); + STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); + + #ifndef STBI_NO_STDIO +-STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); +-STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); ++STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp, float *gamma); ++STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp, float *gamma); + STBIDEF int stbi_is_16_bit (char const *filename); + STBIDEF int stbi_is_16_bit_from_file(FILE *f); + #endif +@@ -911,7 +911,7 @@ + #ifndef STBI_NO_PNG + static int stbi__png_test(stbi__context *s); + static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +-static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); ++static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp, float *gamma); + static int stbi__png_is16(stbi__context *s); + #endif + +@@ -4554,6 +4554,7 @@ + stbi__context *s; + stbi_uc *idata, *expanded, *out; + int depth; ++ float gamma = 0; + } stbi__png; + + +@@ -5112,6 +5113,13 @@ + break; + } + ++ case STBI__PNG_TYPE('g','A','M','A'): { ++ if (first) return stbi__err("first not IHDR", "Corrupt PNG"); ++ if (4 != c.length) return stbi__err("invalid gAMA","Corrupt PNG"); ++ z->gamma = stbi__get32be(s) / 100000.0f; ++ break; ++ } ++ + case STBI__PNG_TYPE('I','D','A','T'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); +@@ -5243,7 +5251,7 @@ + return r; + } + +-static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) ++static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp, float *gamma) + { + if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { + stbi__rewind( p->s ); +@@ -5252,21 +5260,22 @@ + if (x) *x = p->s->img_x; + if (y) *y = p->s->img_y; + if (comp) *comp = p->s->img_n; ++ if (gamma) *gamma = p->gamma; + return 1; + } + +-static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) ++static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp, float *gamma) + { + stbi__png p; + p.s = s; +- return stbi__png_info_raw(&p, x, y, comp); ++ return stbi__png_info_raw(&p, x, y, comp, gamma); + } + + static int stbi__png_is16(stbi__context *s) + { + stbi__png p; + p.s = s; +- if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) ++ if (!stbi__png_info_raw(&p, NULL, NULL, NULL, NULL)) + return 0; + if (p.depth != 16) { + stbi__rewind(p.s); +@@ -7538,14 +7547,14 @@ + } + #endif + +-static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) ++static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp, float *gamma) + { + #ifndef STBI_NO_JPEG + if (stbi__jpeg_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PNG +- if (stbi__png_info(s, x, y, comp)) return 1; ++ if (stbi__png_info(s, x, y, comp, gamma)) return 1; + #endif + + #ifndef STBI_NO_GIF +@@ -7597,23 +7606,23 @@ + } + + #ifndef STBI_NO_STDIO +-STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) ++STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp, float *gamma) + { + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) return stbi__err("can't fopen", "Unable to open file"); +- result = stbi_info_from_file(f, x, y, comp); ++ result = stbi_info_from_file(f, x, y, comp, gamma); + fclose(f); + return result; + } + +-STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) ++STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp, float *gamma) + { + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); +- r = stbi__info_main(&s,x,y,comp); ++ r = stbi__info_main(&s,x,y,comp, gamma); + fseek(f,pos,SEEK_SET); + return r; + } +@@ -7640,18 +7649,18 @@ + } + #endif // !STBI_NO_STDIO + +-STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) ++STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, float *gamma) + { + stbi__context s; + stbi__start_mem(&s,buffer,len); +- return stbi__info_main(&s,x,y,comp); ++ return stbi__info_main(&s,x,y,comp, gamma); + } + +-STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) ++STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp, float *gamma) + { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); +- return stbi__info_main(&s,x,y,comp); ++ return stbi__info_main(&s,x,y,comp, gamma); + } + + STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) diff --git a/usd.spec b/usd.spec index 1bcad8e..e0ebde1 100644 --- a/usd.spec +++ b/usd.spec @@ -1,19 +1,20 @@ -%global __cmake_in_source_build 0 -%global libmajor 0 +%global downstream_so_version 0 + %global srcname USD %bcond_without alembic %bcond_with documentation %bcond_without embree %bcond_without imaging -# We must keep jemalloc enabled to work around -# https://github.com/PixarAnimationStudios/USD/issues/1592. -%bcond_without jemalloc +%bcond_with jemalloc %bcond_with openshading %bcond_with openvdb %bcond_without ocio %bcond_without oiio %bcond_without python3 -%bcond_with test +# TODO: Figure out how to re-enable the tests. Currently these want to install +# into /usr/tests and, and there are issues with the launchers finding the +# command-line tools in the buildroot. +%bcond_with test Name: usd Version: 22.03 @@ -42,13 +43,47 @@ License: ASL 2.0 and BSD and MIT and (MIT or Unlicense) URL: http://www.openusd.org/ Source0: https://github.com/PixarAnimationStudios/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz Source1: org.open%{name}.%{name}view.desktop +# Latest stb_image.patch that applies cleanly against 2.27: +# %%{forgeurl}/raw/8f9bb9563980b41e7695148b63bf09f7abd38a41/pxr/imaging/hio/stb/stb_image.patch +# We treat this as a source file because it is applied separately during +# unbundling. It has been hand-edited to apply to 2.28, where +# stbi__unpremultiply_on_load_thread is already renamed to +# stbi_set_unpremultiply_on_load_thread. +Source2: stb_image.patch +# Upstream was asked about .so versioning and setting SONAME properly and +# seemed unprepared to handle the request: +# https://github.com/PixarAnimationStudios/USD/issues/1259#issuecomment-657120216 +# +# A patch was offered: # https://github.com/PixarAnimationStudios/USD/issues/1387 +# but it was not sufficient for the general case, since (1) it only handled the +# monolithic build, and (2) it derived the .so version from PXR_MAJOR_VERSION, +# which is *not* reliably bumped on API or ABI changes, and currently is still +# zero. +# +# We will therefore probably need to keep doing downstream .so versioning for +# the foreseeable future. A new scheme is implemented in F37 and later that +# assumes that the ABI is likely to change on every release (an appropriate +# assumption for a large C++ project with no ABI stability policy), and +# therefore builds the .so version from the project version. +# +# In F36 and older, we keep the old .so version scheme to avoid a breaking +# change. Patch1: %{srcname}-20.05-soversion.patch # https://github.com/PixarAnimationStudios/USD/issues/1591 Patch2: USD-21.08-OpenEXR3.patch +# USD uses deprecated malloc hooks removed in glibc 2.34 +# https://github.com/PixarAnimationStudios/USD/issues/1592 +# Based on: +# https://github.com/PixarAnimationStudios/USD/issues/1592#issuecomment-1047152905 +Patch3: USD-21.11-disable-malloc-hooks.patch + +# Backport upstream commit 04dd025 “Fix compilation on GCC11.” +Patch4: https://github.com/PixarAnimationStudios/USD/commit/04dd02515d1ee05e26629ba540afc53986ae60e0.patch + # Base BuildRequires: boost-devel BuildRequires: boost-program-options @@ -102,13 +137,15 @@ BuildRequires: hdf5-devel %endif # Header-only library: -static is for tracking per guidelines -# stb_image 2.27-0.7 is the minimum EVR to contain fixes for all of -# CVE-2021-28021, CVE-2021-42715, and CVE-2021-42716. -BuildRequires: stb_image-devel >= 2.27-0.7 +# +# Enforce the the minimum EVR to contain fixes for all of CVE-2021-28021, +# CVE-2021-42715, CVE-2021-42716, and CVE-2022-28041, plus the null-pointer +# dereference bug https://github.com/nothings/stb/issues/1452. +BuildRequires: stb_image-devel >= 2.28^20230129git5736b15-0.2 BuildRequires: stb_image-static -BuildRequires: stb_image_write-devel +BuildRequires: stb_image_write-devel >= 1.16 BuildRequires: stb_image_write-static -BuildRequires: stb_image_resize-devel +BuildRequires: stb_image_resize-devel >= 0.97 BuildRequires: stb_image_resize-static Requires: %{name}-libs%{?_isa} = %{version}-%{release} @@ -116,6 +153,18 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release} Requires: python3-%{name}%{?_isa} = %{version}-%{release} %endif +# This package is only available for x86_64 and aarch64 +# Will fail to build on other architectures +# https://bugzilla.redhat.com/show_bug.cgi?id=1960848 +ExclusiveArch: aarch64 x86_64 + +%description +Universal Scene Description (USD) is a time-sampled scene +description for interchange between graphics applications. + +%package libs +Summary: Universal Scene Description library + # Upstream bundles # Filed ticket to convince upstream to use system libraries # https://github.com/PixarAnimationStudios/USD/issues/1490 @@ -137,19 +186,6 @@ Provides: bundled(SPIRV-Reflect) = 1.0 # Version from: pxr/imaging/hgiVulkan/vk_mem_alloc.h (header comment) Provides: bundled(VulkanMemoryAllocator) = 3.0.0~development -# This package is only available for x86_64 and aarch64 -# Will fail to build on other architectures -# https://bugzilla.redhat.com/show_bug.cgi?id=1960848 -ExclusiveArch: aarch64 x86_64 - -%description -Universal Scene Description (USD) is a time-sampled scene -description for interchange between graphics applications. - -%package libs -Summary: Universal Scene Description library - - %description libs Universal Scene Description (USD) is an efficient, scalable system for authoring, reading, and streaming time-sampled scene description for @@ -223,9 +259,10 @@ ln -s %{_datadir}/fonts/google-roboto-mono \ # Unbundle stb_image, stb_image_write, stb_image_resize: pushd pxr/imaging/hio/stb -cp -p %{_includedir}/stb_image.h %{_includedir}/stb_image_write.h . -cat stb_image.patch stb_image_write.patch | patch -p1 -ln -svf %{_includedir}/stb_image_resize.h ./ +cp -p %{_includedir}/stb_image.h . +patch -p1 < '%{SOURCE2}' +ln -svf %{_includedir}/stb_image_resize.h \ + %{_includedir}/stb_image_write.h ./ popd # Use c++17 standard otherwise build fails @@ -247,10 +284,6 @@ sed -i 's|plugin/usd|%{_libdir}/usd/plugin|g' \ # Fix cmake directory destination sed -i 's|"${CMAKE_INSTALL_PREFIX}"|%{_libdir}/cmake/pxr|g' pxr/CMakeLists.txt -# Disable depreciated glibc mallocHook -# https://github.com/PixarAnimationStudios/USD/issues/1592#issuecomment-1003840684 -sed -i.bak -e 's/.if !defined.ARCH_OS_WINDOWS./#if 0/' -e 's/.if defined.ARCH_COMPILER_GCC.*/#if 0/' -e 's/defined.ARCH_COMPILER_CLANG.//' -e 's/.if defined.ARCH_OS_LINUX./#if 0/' -e 's/.if !defined.ARCH_OS_LINUX./#if 1/' pxr/base/arch/mallocHook.cpp - %build # Fix uic-qt5 use cat > uic-wrapper <<'EOF' @@ -330,8 +363,9 @@ desktop-file-install \ --dir=%{buildroot}%{_datadir}/applications \ %{SOURCE1} -# Remove arch-specific code in /usr/share -find %{buildroot}%{_datadir}/%{name}/examples -name '*.so' -print -delete +# Remove examples that were built and installed even though we set +# -DPXR_BUILD_EXAMPLES=OFF. +rm -vrf '%{buildroot}%{_datadir}/%{name}/examples' # Fix installation path for some files mv %{buildroot}%{_prefix}/lib/python/pxr/*.* \ @@ -339,6 +373,14 @@ mv %{buildroot}%{_prefix}/lib/python/pxr/*.* \ mv %{buildroot}%{_prefix}/lib/python/pxr/Usdviewq/* \ %{buildroot}%{python3_sitearch}/pxr/Usdviewq/ +# Currently, the pxrConfig.cmake that is installed is not correct for +# monolithic builds (and we must do a monolithic build in order to be usable as +# a dependency for Blender). It relies on the libraries that would be in +# pxrTargets.cmake, which is not generated for monolithic builds. +# https://bugzilla.redhat.com/show_bug.cgi?id=2055414 +# https://github.com/PixarAnimationStudios/USD/issues/1088 +rm -vrf '%{buildroot}%{_libdir}/cmake' + %check desktop-file-validate %{buildroot}%{_datadir}/applications/org.open%{name}.%{name}view.desktop %{?with_test:%ctest} @@ -346,9 +388,6 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/org.open%{name}.%{nam %files %doc NOTICE.txt README.md %{_bindir}/* -%dir %{_datadir}/%{name} -%dir %{_datadir}/%{name}/examples/ -%{_datadir}/%{name}/examples/* %if %{with python3} %files -n python3-%{name} @@ -359,14 +398,13 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/org.open%{name}.%{nam %files libs %license LICENSE.txt %doc NOTICE.txt README.md -%{_libdir}/lib%{name}_%{name}_ms.so.%{libmajor} +%{_libdir}/lib%{name}_%{name}_ms.so.%{downstream_so_version} %{_libdir}/%{name} %exclude %{_libdir}/%{name}/%{name}/resources/codegenTemplates %files devel %doc BUILDING.md CHANGELOG.md VERSIONS.md %{_includedir}/pxr/ -%{_libdir}/cmake/* %{_libdir}/lib%{name}_%{name}_ms.so %{_libdir}/%{name}/%{name}/resources/codegenTemplates/