Skip to content

Commit

Permalink
build!: Move to C++17 minimum (AcademySoftwareFoundation#4199)
Browse files Browse the repository at this point in the history
These are build-breaking changes that impose a variety of new minimum
dependencies for the toolchain.

C++17 is the new minimum. All hail C++17.

Bump minimum compiler versions to the respective releases of each one
that is requred to fully support C++17 for us. This means new minimum
changes of gcc 6.1 -> 9.3, clang 3.4 -> 5.0, icc 17 -> 19, and MSVS
v19.14 or higher now.

Remove CI tests for too-old platforms, and adjust some others that
needed particular components upgraded. We now will no longer attempt to
test on "VFX Platform 2019" or 2020. The 2021 platforms are the earliest
we claim to support (reflecting VFXP's guidance about trying to support
up to 3 years back).

By removing the old test cases, we're also removing the last platforms
that test Python 2.7. So while this PR isn't the one that officially
removes the last vestiges of Python 2, it does mean that once this is
merged, we will no longer be testing less than Python 3.7. (A separate
PR removing all Python 2 support will follow and presumably be merged
around the same time.)

With C++17 min, remove traces of boost::filesystem. We can rely on
std::filesystem now.

Clean up pre-C++17 macros in platform.h

Needless to say, this will not be backported to any release branches,
which guarantee that they will never raise the minimum supported
versions of any dependencies. This is just for future OIIO. I won't
merge this until after April 1, at which point I will also tag the last
spot in master that is known to work with C++14/gcc6.

Signed-off-by: Larry Gritz <[email protected]>
  • Loading branch information
lgritz authored Apr 5, 2024
1 parent fc5a454 commit e83cd7c
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 220 deletions.
63 changes: 14 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,6 @@ jobs:
fail-fast: false
matrix:
include:
- desc: gcc6/C++14 py2.7 boost1.66 exr2.4 ocio1.1
nametag: linux-vfx2019
runner: ubuntu-latest
container: aswf/ci-osl:2019
vfxyear: 2019
cxx_std: 14
openexr_ver: v2.4.3
python_ver: 2.7
simd: sse4.2
fmt_ver: 7.0.1
pybind11_ver: v2.4.2
setenvs: export PUGIXML_VERSION=v1.9 CMAKE_VERSION=3.15.5
- desc: gcc6/C++14 py3.7 boost1.70 exr2.4 ocio1.1
nametag: linux-vfx2020
runner: ubuntu-latest
container: aswf/ci-osl:2020
vfxyear: 2020
cxx_std: 14
python_ver: 3.7
simd: avx
fmt_ver: 7.0.1
pybind11_ver: v2.5.0
setenvs: export PUGIXML_VERSION=v1.9 WEBP_VERSION=v1.1.0
- desc: gcc9/C++17 py3.7 boost1.73 exr2.5 ocio2.0
nametag: linux-vfx2021
runner: ubuntu-latest
Expand All @@ -68,14 +45,14 @@ jobs:
fmt_ver: 7.1.0
pybind11_ver: v2.7.0
setenvs: export PUGIXML_VERSION=v1.9 WEBP_VERSION=v1.1.0
- desc: clang10/C++14 avx2 exr2.5 ocio2.0
- desc: clang10/C++17 avx2 exr2.5 ocio2.0
nametag: linux-clang10-cpp14
runner: ubuntu-latest
container: aswf/ci-osl:2021-clang10
vfxyear: 2021
cc_compiler: clang
cxx_compiler: clang++
cxx_std: 14
cxx_std: 17
pybind11_ver: v2.6.2
python_ver: 3.7
simd: "avx2,f16c"
Expand Down Expand Up @@ -163,18 +140,18 @@ jobs:
simd: "avx2,f16c"
fmt_ver: 10.1.1
pybind11_ver: v2.10.0
- desc: oldest/hobbled gcc6.3/C++14 py2.7 boost-1.66 exr-2.4 no-sse no-ocio
- desc: oldest/hobbled gcc9.3/C++17 py3.7 boost-1.66 exr-2.4 no-sse no-ocio
# Oldest versions of the dependencies that we can muster, and various
# things disabled (no SSE, OCIO, or OpenCV, don't embed plugins).
nametag: linux-oldest
runner: ubuntu-latest
container: aswf/ci-osl:2019
vfxyear: 2019
cxx_std: 14
container: aswf/ci-osl:2021
vfxyear: 2021
cxx_std: 17
fmt_ver: 7.0.1
openexr_ver: v2.4.0
pybind11_ver: v2.4.2
python_ver: 2.7
python_ver: 3.7
simd: 0
setenvs: export EMBEDPLUGINS=0
CMAKE_VERSION=3.15.5
Expand Down Expand Up @@ -352,13 +329,13 @@ jobs:
OPENCOLORIO_VERSION=v2.1.2
USE_OPENVDB=0
# The installed OpenVDB has a TLS conflict with Python 3.8
- desc: debug gcc7/C++14, sse4.2, exr2.4
nametag: linux-gcc7-cpp14-debug
- desc: debug gcc9/C++17, sse4.2, exr2.4
nametag: linux-gcc9-cpp17-debug
runner: ubuntu-20.04
container:
image: ubuntu-18.04
cxx_compiler: g++-7
cxx_std: 14
cxx_compiler: g++-9
cxx_std: 17
python_ver: 2.7
simd: sse4.2
openexr_ver: v2.4.3
Expand All @@ -367,25 +344,13 @@ jobs:
PUGIXML_VERSION=v1.9
CTEST_TEST_TIMEOUT=1200

- desc: gcc8 C++17 avx exr2.5
nametag: linux-gcc8
runner: ubuntu-20.04
container:
image: ubuntu-18.04
cc_compiler: gcc-8
cxx_compiler: g++-8
cxx_std: 17
openexr_ver: v2.5.8
pybind11_ver: v2.5.0
simd: avx
setenvs: export EXTRA_DEP_PACKAGES=libjpeg-turbo8-dev
- desc: static libs gcc7 C++14 exr2.4
- desc: static libs gcc9 C++17 exr2.4
nametag: linux-static
runner: ubuntu-20.04
container:
image: ubuntu-18.04
cxx_compiler: g++-7
cxx_std: 14
cxx_compiler: g++-9
cxx_std: 17
openexr_ver: v2.4.3
pybind11_ver: v2.6.2
setenvs: export BUILD_SHARED_LIBS=OFF
Expand Down
9 changes: 4 additions & 5 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.

### Required dependencies -- OIIO will not build at all without these

* C++14 or higher (also builds with C++17, and C++20)
* **C++17 or higher** (also builds with C++20)
* The default build mode is C++17. This can be controlled by via the
CMake configuration flag: `-DCMAKE_CXX_STANDARD=14`, 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 - 17, MSVS 2017 - 2019,
Intel icc 17+, Intel OneAPI C++ compiler 2022+.
CMake configuration flag: `-DCMAKE_CXX_STANDARD=20`, etc.
* Compilers: **gcc 9.3** - 13.1, **clang 5** - 17, MSVS 2017 - 2019 (**v19.14
and up**), **Intel icc 19+**, 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
and main) (ADVISORY: We expect that OIIO 2.6 in 2024 will require OpenEXR >= 3.1)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ help:
@echo " VERBOSE=1 Show all compilation commands"
@echo " STOP_ON_WARNING=0 Do not stop building if compiler warns"
@echo " MYCC=xx MYCXX=yy Use custom compilers"
@echo " CMAKE_CXX_STANDARD=14 C++ standard to build with (default is 17)"
@echo " CMAKE_CXX_STANDARD=20 C++ standard to build with (default is 17)"
@echo " USE_LIBCPLUSPLUS=1 For clang, use libc++"
@echo " GLIBCXX_USE_CXX11_ABI=1 For gcc, use the new string ABI"
@echo " EXTRA_CPP_ARGS= Additional args to the C++ command"
Expand Down
2 changes: 1 addition & 1 deletion src/build-scripts/ci-startup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export OpenImageIO_CI=true
export USE_NINJA=${USE_NINJA:=1}
export CMAKE_GENERATOR=${CMAKE_GENERATOR:=Ninja}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
export CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD:=14}
export CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD:=17}

export LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=$HOME/ext}
export PATH=${LOCAL_DEPS_DIR}/dist/bin:$PATH
Expand Down
10 changes: 3 additions & 7 deletions src/build-scripts/gh-installdeps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,16 @@ else

export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu:$CMAKE_PREFIX_PATH

if [[ "$CXX" == "g++-6" ]] ; then
time sudo apt-get install -y g++-6
elif [[ "$CXX" == "g++-7" ]] ; then
time sudo apt-get install -y g++-7
elif [[ "$CXX" == "g++-8" ]] ; then
time sudo apt-get install -y g++-8
elif [[ "$CXX" == "g++-9" ]] ; then
if [[ "$CXX" == "g++-9" ]] ; then
time sudo apt-get install -y g++-9
elif [[ "$CXX" == "g++-10" ]] ; then
time sudo apt-get install -y g++-10
elif [[ "$CXX" == "g++-11" ]] ; then
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
fi

if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$USE_ICX" != "" ]] ; then
Expand Down
27 changes: 2 additions & 25 deletions src/cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ endmacro ()
###########################################################################
# C++ language standard
#
set (CMAKE_CXX_MINIMUM 14)
set (CMAKE_CXX_MINIMUM 17)
set (CMAKE_CXX_STANDARD 17 CACHE STRING
"C++ standard to build with (14, 17, 20, etc.) Minimum is ${CMAKE_CXX_MINIMUM}.")
set (DOWNSTREAM_CXX_STANDARD 14 CACHE STRING
set (DOWNSTREAM_CXX_STANDARD 17 CACHE STRING
"C++ minimum standard to impose on downstream clients")
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
Expand Down Expand Up @@ -389,29 +389,6 @@ if (NOT MSVC AND NOT APPLE AND NOT ANDROID)
endif ()


###########################################################################
# Check if we need have std::filesystem on this platform.
#
cmake_push_check_state ()
set (CMAKE_REQUIRED_DEFINITIONS ${CSTD_FLAGS})
check_cxx_source_compiles("#include <filesystem>
int main() { std::filesystem::path p; return 0; }"
USE_STD_FILESYSTEM)
if (USE_STD_FILESYSTEM AND GCC_VERSION AND GCC_VERSION VERSION_LESS 9.0)
message (STATUS "Excluding USE_STD_FILESYSTEM because gcc is ${GCC_VERSION}")
set (USE_STD_FILESYSTEM OFF)
endif ()
if (USE_STD_FILESYSTEM)
# Note: std::filesystem seems unreliable for gcc until 9
message (STATUS "Compiler supports std::filesystem")
proj_add_compile_definitions (-DUSE_STD_FILESYSTEM)
else ()
message (STATUS "Using Boost::filesystem")
proj_add_compile_definitions (-DUSE_BOOST_FILESYSTEM)
endif ()
cmake_pop_check_state ()


###########################################################################
# Code coverage options
#
Expand Down
7 changes: 2 additions & 5 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ if (MSVC)
endif ()

set (Boost_COMPONENTS thread)
if (NOT USE_STD_FILESYSTEM)
list (APPEND Boost_COMPONENTS filesystem)
endif ()
message (STATUS "Boost_COMPONENTS = ${Boost_COMPONENTS}")
# The FindBoost.cmake interface is broken if it uses boost's installed
# cmake output (e.g. boost 1.70.0, cmake <= 3.14). Specifically it fails
Expand Down Expand Up @@ -232,8 +229,8 @@ if (LibRaw_FOUND AND LibRaw_VERSION VERSION_LESS 0.20 AND CMAKE_CXX_STANDARD VER
# Currently, we issue the above warning and let them take their chances.
# If we wish to disable the LibRaw<0.20/C++17 combination that may fail,
# just uncomment the following two lines.
# set (LibRaw_FOUND 0)
# set (LIBRAW_FOUND 0)
set (LibRaw_FOUND 0)
set (LIBRAW_FOUND 0)
endif ()

checked_find_package (OpenJPEG VERSION_MIN 2.0
Expand Down
1 change: 0 additions & 1 deletion src/doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,6 @@ PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \
OIIO_HOSTDEVICE= \
OIIO_NAMESPACE_BEGIN="namespace OIIO {" \
OIIO_NAMESPACE_END="}" \
OIIO_CONSTEXPR14=constexpr \
OIIO_CONSTEXPR17=constexpr \
OIIO_CONSTEXPR20=constexpr \
OIIO_INLINE_CONSTEXPR="inline constexpr" \
Expand Down
10 changes: 2 additions & 8 deletions src/include/OpenImageIO/detail/farmhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,13 @@
// Make static inline 'const expr, if possible. Also, try to make CUDA friendly
// for device code.
#undef STATIC_INLINE
#if OIIO_CPLUSPLUS_VERSION >= 14
# define HASH_CAN_USE_CONSTEXPR 1
#endif
#define STATIC_INLINE OIIO_HOSTDEVICE inline OIIO_CONSTEXPR14
#define HASH_CAN_USE_CONSTEXPR 1
#define STATIC_INLINE OIIO_HOSTDEVICE inline constexpr

// FARMHASH PORTABILITY LAYER: Runtime error if misconfigured

#ifndef FARMHASH_DIE_IF_MISCONFIGURED
#ifdef HASH_CAN_USE_CONSTEXPR
#define FARMHASH_DIE_IF_MISCONFIGURED
#else
#define FARMHASH_DIE_IF_MISCONFIGURED do { *(char*)(len % 17) = 0; } while (0)
#endif
#endif

// FARMHASH PORTABILITY LAYER: endianness and byteswapping functions
Expand Down
2 changes: 1 addition & 1 deletion src/include/OpenImageIO/oiioversion.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ namespace @PROJ_NAME@ = @PROJ_NAMESPACE_V@;
#define OIIO_USING_IMATH_VERSION_MAJOR @Imath_VERSION_MAJOR@
#define OIIO_USING_IMATH_VERSION_MINOR @Imath_VERSION_MINOR@

// Which CPP standard (11, 14, etc.) was this copy of OIIO *built* with?
// Which CPP standard (17, 20, etc.) was this copy of OIIO *built* with?
#define OIIO_BUILD_CPP @CMAKE_CXX_STANDARD@

// DEPRECATED(2.1): old macros separately giving compatibility.
Expand Down
55 changes: 16 additions & 39 deletions src/include/OpenImageIO/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
// OIIO_INLINE_CONSTEXPR : inline constexpr variables, added in C++17. For
// older C++, static constexpr.
//
// Note: oiioversion.h defines OIIO_BUILD_CPP (set to 14, 17, etc.)
// Note: oiioversion.h defines OIIO_BUILD_CPP (set to 17, 20, etc.)
// reflecting what OIIO itself was *built* with. In contrast,
// OIIO_CPLUSPLUS_VERSION defined below will be set to the right number for
// the C++ standard being compiled RIGHT NOW. These two things may be the
Expand All @@ -77,18 +77,13 @@
# define OIIO_CONSTEXPR17 constexpr
# define OIIO_CONSTEXPR20 constexpr
# define OIIO_INLINE_CONSTEXPR inline constexpr
#elif (__cplusplus >= 201703L)
#elif (__cplusplus >= 201703L) || (defined(_MSC_VER) && _MSC_VER >= 1914)
# define OIIO_CPLUSPLUS_VERSION 17
# define OIIO_CONSTEXPR17 constexpr
# define OIIO_CONSTEXPR20 /* not constexpr before C++20 */
# define OIIO_INLINE_CONSTEXPR inline constexpr
#elif (__cplusplus >= 201402L) || (defined(_MSC_VER) && _MSC_VER >= 1914)
# define OIIO_CPLUSPLUS_VERSION 14
# define OIIO_CONSTEXPR17 /* not constexpr before C++17 */
# define OIIO_CONSTEXPR20 /* not constexpr before C++20 */
# define OIIO_INLINE_CONSTEXPR static constexpr
#else
# error "This version of OIIO is meant to work only with C++14 and above"
# error "This version of OIIO is meant to work only with C++17 and above"
#endif

// DEPRECATED(2.3): use C++14 constexpr
Expand All @@ -113,12 +108,6 @@
# define __has_attribute(x) 0
#endif

// In C++17 (and some compilers before that), __has_include("blah.h") or
// __has_include(<blah.h>) can test for presence of an include file.
#ifndef __has_include
# define __has_include(x) 0
#endif



// Detect which compiler and version we're using
Expand Down Expand Up @@ -389,7 +378,7 @@
#endif


// OIIO_FORCELINE is a function attribute that attempts to make the function
// OIIO_FORCEINLINE is a function attribute that attempts to make the function
// always inline. On many compilers regular 'inline' is only advisory. Put
// this attribute before the function return type, just like you would use
// 'inline'.
Expand Down Expand Up @@ -431,15 +420,11 @@
# define OIIO_CONST_FUNC
#endif

// OIIO_MAYBE_UNUSED is a function or variable attribute that assures the
// compiler that it's fine for the item to appear to be unused.
#if OIIO_CPLUSPLUS_VERSION >= 17 || __has_cpp_attribute(maybe_unused)
# define OIIO_MAYBE_UNUSED [[maybe_unused]]
#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) || __has_attribute(unused)
# define OIIO_MAYBE_UNUSED __attribute__((unused))
#else
# define OIIO_MAYBE_UNUSED
#endif
// OIIO_MAYBE_UNUSED is an annotator for function or variable attribute that
// assures the compiler that it's fine for the item to appear to be unused.
// Consider this deprecated (as of OIIO 3.0), you should favor C++17's
// [[maybe_unused]] attribute.
#define OIIO_MAYBE_UNUSED [[maybe_unused]]

// DEPRECATED(1.9) name:
#define OIIO_UNUSED_OK OIIO_MAYBE_UNUSED
Expand All @@ -455,26 +440,18 @@


// OIIO_DEPRECATED before a function declaration marks it as deprecated in
// a way that will generate compile warnings if it is called.
#if OIIO_CPLUSPLUS_VERSION >= 14 || __has_cpp_attribute(deprecated)
# define OIIO_DEPRECATED(msg) [[deprecated(msg)]]
#elif defined(__GNUC__) || defined(__clang__) || __has_attribute(deprecated)
# define OIIO_DEPRECATED(msg) __attribute__((deprecated(msg)))
#elif defined(_MSC_VER)
# define OIIO_DEPRECATED(msg) __declspec(deprecated(msg))
#else
# define OIIO_DEPRECATED(msg)
#endif
// a way that will generate compile warnings if it is called. This should
// itself be considered deprecated (as of OIIO 3.0) and code should use
// [[deprecated(msg)]] instead.
#define OIIO_DEPRECATED(msg) [[deprecated(msg)]]


// OIIO_FALLTHROUGH at the end of a `case` label's statements documents that
// the switch statement case is intentionally falling through to the code
// for the next case.
#if OIIO_CPLUSPLUS_VERSION >= 17 || __has_cpp_attribute(fallthrough)
# define OIIO_FALLTHROUGH [[fallthrough]]
#else
# define OIIO_FALLTHROUGH
#endif
// Consider this deprecated (as of OIIO 3.0), you should favor C++17's
// [[fallthrough]] attribute.
#define OIIO_FALLTHROUGH [[fallthrough]]


// OIIO_NODISCARD following a function declaration documents that the
Expand Down
Loading

0 comments on commit e83cd7c

Please sign in to comment.