Subject: Re: bug#72046: [core-updates] OpenImageIO fails to build

From: Zheng Junjie <[email-masked]>
Date: Thu, 11 Jul 2024 14:29:59 +0800

Leo Famulari <[email-masked]> writes:

> On core-updates commit 378e1d9b69b030a165, openimageio fails to build
> like this:
>
> ------
> [ 30%] Building CXX object src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/imageio.cpp.o
> cd /tmp/guix-build-openimageio-2.5.13.0.drv-0/build/src/libOpenImageIO
> && /gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/bin/c++
> -DEMBED_PLUGINS=1 -DOIIO_FREETYPE_VERSION=\"\" -DOIIO_INTERNAL=1
> -DOIIO_OPENEXR_CORE_DEFAULT=1 -DOIIO_OpenCV_VERSION=\"\"
> -DOIIO_PYTHON_VERSION=\"3.10.7\" -DOIIO_QT_VERSION=\"\"
> -DOIIO_TBB_VERSION=\"\" -DOIIO_USE_EXR_C_API=1 -DOpenImageIO_EXPORTS
> -DUSE_BOOST_FILESYSTEM -DUSE_EXTERNAL_PUGIXML=1 -DUSE_GIF -DUSE_HEIF=1
> -DUSE_JPEG_TURBO=1 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
> -I/tmp/guix-build-openimageio-2.5.13.0.drv-0/build/include/OpenImageIO
> -I/tmp/guix-build-openimageio-2.5.13.0.drv-0/build/include
> -I/tmp/guix-build-openimageio-2.5.13.0.drv-0/build/src/include
> -I/tmp/guix-build-openimageio-2.5.13.0.drv-0/source/src/include
> -I/OpenEXR -isystem
> /gnu/store/mcyxqs4sxnb8r642q1l0gfmg86hrngqp-imath-3.1.3/include/Imath
> -isystem
> /gnu/store/p1rqc1ydnvcrn5ndjq9kn37l7fscilrv-openexr-3.2.4/include/OpenEXR
> -O2 -g -DNDEBUG -fPIC -fvisibility=hidden -Wall
> -Wno-unused-local-typedefs -Wno-unused-result -Wno-aligned-new
> -Wno-noexcept-type -fno-math-errno -std=c++14 -MD -MT
> src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/imageio.cpp.o -MF
> CMakeFiles/OpenImageIO.dir/imageio.cpp.o.d -o
> CMakeFiles/OpenImageIO.dir/imageio.cpp.o -c
> /tmp/guix-build-openimageio-2.5.13.0.drv-0/source/src/libOpenImageIO/imageio.cpp
> /tmp/guix-build-openimageio-2.5.13.0.drv-0/source/src/libOpenImageIO/imageio.cpp:
> In function ‘bool
> OpenImageIO_v2_5::getattribute(OpenImageIO_v2_5::string_view,
> OpenImageIO_v2_5::TypeDesc, void*)’:
> /tmp/guix-build-openimageio-2.5.13.0.drv-0/source/src/libOpenImageIO/imageio.cpp:623:33:
> error: expected primary-expression before ‘(’ token
>   623 |         *(ustring*)val = ustring(OIIO_ALL_BUILD_DEPS_FOUND);
>       |                                 ^
> In file included from /tmp/guix-build-openimageio-2.5.13.0.drv-0/source/src/libOpenImageIO/imageio.cpp:24:
> /tmp/guix-build-openimageio-2.5.13.0.drv-0/build/include/imageio_pvt.h:229:377:
> error: expected ‘)’ before numeric constant
>   229 | #define OIIO_ALL_BUILD_DEPS_FOUND "Boost 1.83.0;BZip2
> 1.0.8;DCMTK NONE;FFmpeg NONE;fmt 9.1.0;Freetype NONE;GIF 5.2.1;Libheif
> 1.17.6;libjpeg-turbo 2.1.4;LibRaw NONE;OpenColorIO NONE;OpenCV
> NONE;OpenEXR 3.2.4;OpenGL NONE;OpenJPEG NONE;PNG 1.6.39;Ptex NONE;Ptex
> NONE;pugixml 1.12;pybind11 2.8.1;Python 3.10.7;Robinmap;TBB NONE;TIFF
> 4.4.0;WebP NONE;ZLIB 1.3.#define ZLIB_VERSION "1.3""
>       |                                                                                                                                                                                                                                                                                                                                                                                         ^~~
> /tmp/guix-build-openimageio-2.5.13.0.drv-0/source/src/libOpenImageIO/imageio.cpp:623:34:
> note: in expansion of macro ‘OIIO_ALL_BUILD_DEPS_FOUND’
>   623 |         *(ustring*)val = ustring(OIIO_ALL_BUILD_DEPS_FOUND);
>       |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
> /tmp/guix-build-openimageio-2.5.13.0.drv-0/source/src/libOpenImageIO/imageio.cpp:623:33: note: to match this ‘(’
>   623 |         *(ustring*)val = ustring(OIIO_ALL_BUILD_DEPS_FOUND);
>       |                                 ^
> make[2]: ***
> [src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/build.make:387:
> src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/imageio.cpp.o] Error 1
> make[2]: Leaving directory '/tmp/guix-build-openimageio-2.5.13.0.drv-0/build'
> make[1]: *** [CMakeFiles/Makefile2:1703: src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/all] Error 2
> make[1]: Leaving directory '/tmp/guix-build-openimageio-2.5.13.0.drv-0/build'
> make: *** [Makefile:169: all] Error 2
> error: in phase 'build': uncaught exception:
> %exception #<&invoke-error program: "make" arguments: ("-j" "1") exit-status: 2 term-signal: #f stop-signal: #f> 
> phase `build' failed after 426.2 seconds
> command "make" "-j" "1" failed with status 2
> build process 14 exited with status 256
> builder for `/gnu/store/zbb1ycg7q7iqsp8pa1dyvbsxvh2v94lx-openimageio-2.5.13.0.drv' failed with exit code 1
> ------
>
> I can't find anything online related to this. Any ideas? Full log
> attached.
>
> [2. application/x-gunzip; b1ycg7q7iqsp8pa1dyvbsxvh2v94lx-openimageio-2.5.13.0.drv.gz]...

see patch, as i known, because ours cmake too old, have a bug about zlib.

> Found ZLIB 1.3.#define ZLIB_VERSION "1.3"

``` C
#define OIIO_ALL_BUILD_DEPS_FOUND "Boost 1.83.0;BZip2 1.0.8;DCMTK NONE;FFmpeg NONE;fmt 9.1.0;Freetype NONE;GIF 5.2.1;Libheif 1.17.6;libjpeg-turbo 2.1.4;LibRaw 0.20.0;OpenColorIO NONE;OpenCV NONE;OpenEXR 3.2.4;OpenGL NONE;OpenJPEG NONE;PNG 1.6.39;Ptex NONE;Ptex NONE;pugixml 1.12;pybind11 2.8.1;Python 3.10.7;Robinmap;TBB NONE;TIFF 4.4.0;WebP;ZLIB 1.3.#define ZLIB_VERSION "1.3""
```

shulde be

``` C
#define OIIO_ALL_BUILD_DEPS_FOUND "Boost 1.83.0;BZip2 1.0.8;DCMTK NONE;FFmpeg NONE;fmt 9.1.0;Freetype NONE;GIF 5.2.1;Libheif 1.17.6;libjpeg-turbo 2.1.4;LibRaw 0.20.0;OpenColorIO NONE;OpenCV NONE;OpenEXR 3.2.4;OpenGL NONE;OpenJPEG NONE;PNG 1.6.39;Ptex NONE;Ptex NONE;pugixml 1.12;pybind11 2.8.1;Python 3.10.7;Robinmap;TBB NONE;TIFF 4.4.0;WebP;ZLIB 1.3."
```

so is not a Not a qualified c file.

From 9c756204a49ce7bbfda7cbb2faa8e68bf56dfdc9 Mon Sep 17 00:00:00 2001
Message-ID: <9c7[email-masked]>
From: Zheng Junjie <[email-masked]>
Date: Thu, 11 Jul 2024 14:24:31 +0800
Subject: [PATCH] gnu: openimageio: Fix build.

* gnu/packages/graphics.scm (openimageio)[arguments]<#:phases>: Add
fix-zlib-version phase.

Change-Id: I7ea6e7b7da675bf11a85381cbe26c6992f2bd299
---
 gnu/packages/graphics.scm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index 89dae5a261..06341bc288 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -1349,7 +1349,13 @@ (define-public openimageio
     (arguments
      (list #:tests? #f ; half the tests require online data or use redirection
            #:configure-flags #~(list "-DUSE_EXTERNAL_PUGIXML=1"
-                                     "-DOIIO_BUILD_TESTS=false")))
+                                     "-DOIIO_BUILD_TESTS=false")
+           #:phases #~(modify-phases %standard-phases
+                        (add-after 'configure 'fix-zlib-version
+                          (lambda _
+                            (substitute* "include/imageio_pvt.h"
+                              (("#define ZLIB_VERSION \"1\\.3\"")
+                               "")))))))
     (native-inputs
      (list pkg-config))
     (inputs

base-commit: 378e1d9b69b030a165236323392a0a10684422c5
-- 
2.45.2