From a185e6ec5d1d9dda4ab658a30c0257ecd673d3b7 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Wed, 22 May 2024 11:09:58 -0700 Subject: [PATCH] build: gcc-14 support, testing, CI (#4270) * Switch runner type for bleeding edge, use gcc14 and python 3.12 * Various minor gcc-14 + C++20 + Python 3.12 fixes Notable: gcc14 warns about std::atomic_load for share_ptr as deprecated, since C++20 provides a true atomic shared pointer. Signed-off-by: Larry Gritz --- .github/workflows/ci.yml | 17 +++++++++++------ INSTALL.md | 2 +- src/build-scripts/gh-installdeps.bash | 11 +++++++---- src/libtexture/imagecache_pvt.h | 5 +++++ src/python/py_imagecache.cpp | 12 ++++++++++++ 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53e30a49ad..6414ba2d47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -308,16 +308,16 @@ jobs: USE_OPENVDB=0 WEBP_VERSION=v1.3.0 # The installed OpenVDB has a TLS conflict with Python 3.8 - - desc: bleeding edge gcc13 C++20 py3.10 OCIO/libtiff/exr-master boost1.74 avx2 + - desc: bleeding edge gcc14 C++20 py3.12 OCIO/libtiff/exr-master boost1.74 avx2 nametag: linux-bleeding-edge - runner: ubuntu-22.04 - cc_compiler: gcc-13 - cxx_compiler: g++-13 + runner: ubuntu-24.04 + cc_compiler: gcc-14 + cxx_compiler: g++-14 cxx_std: 20 fmt_ver: master openexr_ver: main pybind11_ver: master - python_ver: "3.10" + python_ver: "3.12" simd: avx2,f16c setenvs: export LIBJPEGTURBO_VERSION=main LIBRAW_VERSION=master @@ -326,9 +326,12 @@ jobs: OPENJPEG_VERSION=master PTEX_VERSION=main PUGIXML_VERSION=master - USE_OPENVDB=0 WEBP_VERSION=main OIIO_CMAKE_FLAGS="-DFORTIFY_SOURCE=2" + QT_VERSION=6 + EXTRA_DEP_PACKAGES="python3.12-dev python3-numpy" + PIP_INSTALLS="none" + USE_OPENVDB=0 # The installed OpenVDB has a TLS conflict with Python 3.8 - desc: clang14 C++20 avx2 exr3.1 ocio2.1 nametag: linux-clang14 @@ -431,6 +434,7 @@ jobs: path: /tmp/ccache key: ${{github.job}}-${{matrix.nametag}}-${{ steps.ccache_cache_keys.outputs.date }} restore-keys: ${{github.job}}- + save-always: true - name: Build setup run: | ${{matrix.setenvs}} @@ -509,6 +513,7 @@ jobs: path: /Users/runner/.ccache key: ${{github.job}}-${{matrix.nametag}}-${{ steps.ccache_cache_keys.outputs.date }} restore-keys: ${{github.job}}- + save-always: true - name: Build setup run: | ${{matrix.setenvs}} diff --git a/INSTALL.md b/INSTALL.md index 990a51b8e7..7bd50bb640 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,7 +18,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**. * The default build mode is C++14. This can be controlled by via the CMake configuration flag: `-DCMAKE_CXX_STANDARD=17`, etc. * ADVISORY: We expect that OIIO 2.6 in 2024 will require C++17 or higher. - * Compilers: gcc 6.1 - 13.1, clang 3.4 - 18, MSVS 2017 - 2019, + * Compilers: gcc 6.1 - 14.1, clang 3.4 - 18, MSVS 2017 - 2019, Intel icc 17+, Intel OneAPI C++ compiler 2022+. * **CMake >= 3.15** (tested through 3.28) * **OpenEXR/Imath >= 2.4** (recommended: 3.1 or higher; tested through 3.2 diff --git a/src/build-scripts/gh-installdeps.bash b/src/build-scripts/gh-installdeps.bash index 7693d5e202..7d498c7981 100755 --- a/src/build-scripts/gh-installdeps.bash +++ b/src/build-scripts/gh-installdeps.bash @@ -100,12 +100,11 @@ else # Nonstandard python versions if [[ "${PYTHON_VERSION}" == "3.9" ]] ; then time sudo apt-get -q install -y python3.9-dev python3-numpy - pip3 --version - pip3 install numpy elif [[ "$PYTHON_VERSION" == "2.7" ]] ; then time sudo apt-get -q install -y python-dev python-numpy - else - pip3 install numpy + fi + if [[ "${PIP_INSTALLS:=numpy}" != "none" ]] ; then + time pip3 install ${PIP_INSTALLS} fi if [[ "$USE_LIBHEIF" != "0" ]] ; then @@ -132,6 +131,10 @@ else time sudo apt-get install -y g++-11 elif [[ "$CXX" == "g++-12" ]] ; then time sudo apt-get install -y g++-12 + elif [[ "$CXX" == "g++-13" ]] ; then + time sudo apt-get install -y g++-13 + elif [[ "$CXX" == "g++-14" ]] ; then + time sudo apt-get install -y g++-14 fi if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$USE_ICX" != "" ]] ; then diff --git a/src/libtexture/imagecache_pvt.h b/src/libtexture/imagecache_pvt.h index 681cca0e16..db4f378b69 100644 --- a/src/libtexture/imagecache_pvt.h +++ b/src/libtexture/imagecache_pvt.h @@ -368,11 +368,16 @@ class OIIO_API ImageCacheFile final : public RefCnt { bool m_broken; ///< has errors; can't be used properly bool m_allow_release = true; ///< Allow the file to release()? std::string m_broken_message; ///< Error message for why it's broken +#if __cpp_lib_atomic_shared_ptr >= 201711L /* C++20 has atomic */ + // Open ImageInput, NULL if closed + std::atomic> m_input; +#else std::shared_ptr m_input; ///< Open ImageInput, NULL if closed // Note that m_input, the shared pointer itself, is NOT safe to // access directly. ALWAYS retrieve its value with get_imageinput // (it's thread-safe to use that result) and set its value with // set_imageinput -- those are guaranteed thread-safe. +#endif std::vector m_subimages; ///< Info on each subimage TexFormat m_texformat; ///< Which texture format TextureOpt::Wrap m_swrap; ///< Default wrap modes diff --git a/src/python/py_imagecache.cpp b/src/python/py_imagecache.cpp index 8c10b7aa1d..f5f3410360 100644 --- a/src/python/py_imagecache.cpp +++ b/src/python/py_imagecache.cpp @@ -117,7 +117,11 @@ declare_imagecache(py::module& m) .def("resolve_filename", [](ImageCacheWrap& ic, const std::string& filename) { py::gil_scoped_release gil; +#if PY_MAJOR_VERSION >= 3 + return ic.m_cache->resolve_filename(filename); +#else return PY_STR(ic.m_cache->resolve_filename(filename)); +#endif }) // .def("get_image_info", &ImageCacheWrap::get_image_info) .def( @@ -147,14 +151,22 @@ declare_imagecache(py::module& m) .def( "geterror", [](ImageCacheWrap& self, bool clear) { +#if PY_MAJOR_VERSION >= 3 + return self.m_cache->geterror(clear); +#else return PY_STR(self.m_cache->geterror(clear)); +#endif }, "clear"_a = true) .def( "getstats", [](ImageCacheWrap& ic, int level) { py::gil_scoped_release gil; +#if PY_MAJOR_VERSION >= 3 + return ic.m_cache->getstats(level); +#else return PY_STR(ic.m_cache->getstats(level)); +#endif }, "level"_a = 1) .def(