Skip to content

Commit c605f03

Browse files
committed
build: clean up obsolete logic for old compilers
* Enforce gcc, clang, and apple clang minimum versions. * Raise advertised minimum clang version to 10.0. Error for clang < 5, which we know is the true minimum because earlier than that won't support C++17 which we require. But in truth, we haven't tested versions older than 10.0 for a long time, so we should not be implying we know older versions will work or that we will support them. * Simplify cases no longer relevant for older gcc and clang. * Remove unneeded gcc guard in simd.h. I think it was important only for gcc 5! But it was also preventing the slightly faster construct from activating for clang. Seems to pass all our CI jobs with this simplified. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 6a4ab75 commit c605f03

7 files changed

Lines changed: 50 additions & 29 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
pybind11_ver: v2.8.1
7575
setenvs: export FREETYPE_VERSION=VER-2-12-0
7676
- desc: oldest gcc9.3/C++17 py3.9 exr-3.1
77-
# Oldest versions of the dependencies that we support.
77+
# Oldest gcc and versions of the dependencies that we support.
7878
nametag: linux-oldest
7979
runner: ubuntu-latest
8080
container: aswf/ci-osl:2022
@@ -91,6 +91,26 @@ jobs:
9191
WEBP_VERSION=v1.1.0
9292
PUGIXML_VERSION=v1.8
9393
depcmds: sudo rm -rf /usr/local/include/OpenEXR
94+
- desc: oldest clang10/C++17 py3.9 exr-3.1
95+
# Oldest clang and versions of the dependencies that we support.
96+
nametag: linux-oldest-clang
97+
runner: ubuntu-latest
98+
container: aswf/ci-osl:2022-clang10
99+
vfxyear: 2021
100+
old_node: 1
101+
cc_compiler: clang
102+
cxx_compiler: clang++
103+
cxx_std: 17
104+
fmt_ver: 7.0.1
105+
opencolorio_ver: v2.2.1
106+
openexr_ver: v3.1.0
107+
pybind11_ver: v2.7.0
108+
python_ver: 3.9
109+
setenvs: export CMAKE_VERSION=3.18.2
110+
PTEX_VERSION=v2.3.2
111+
WEBP_VERSION=v1.1.0
112+
PUGIXML_VERSION=v1.8
113+
depcmds: sudo rm -rf /usr/local/include/OpenEXR
94114
- desc: hobbled gcc9.3/C++17 py3.9 exr-3.1 no-sse
95115
# Use the oldest supported versions of required dependencies, and
96116
# disable most optional dependencies and features (no SSE or

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
1717
* C++17 or higher (also builds with C++20 and C++23)
1818
* The default build mode is C++17. This can be controlled by via the
1919
CMake configuration flag: `-DCMAKE_CXX_STANDARD=20`, etc.
20-
* Compilers: gcc 9.3 - 14.2, clang 5 - 19, MSVS 2017 - 2022 (v19.14
20+
* Compilers: gcc 9.3 - 14.2, **clang 10** - 20, MSVS 2017 - 2022 (v19.14
2121
and up), Intel icc 19+, Intel OneAPI C++ compiler 2022+.
2222
* CMake >= 3.18.2 (tested through 4.0)
2323
* Imath >= 3.1 (tested through 3.1.x and main)

src/cmake/compiler.cmake

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ if (CMAKE_COMPILER_IS_GNUCC)
5353
OUTPUT_VARIABLE GCC_VERSION
5454
OUTPUT_STRIP_TRAILING_WHITESPACE)
5555
message (VERBOSE "Using gcc ${GCC_VERSION} as the compiler")
56+
if (GCC_VERSION VERSION_LESS 9.0)
57+
message (ERROR "gcc minimum version is 9.0")
58+
endif ()
5659
else ()
5760
set (GCC_VERSION 0)
5861
endif ()
@@ -71,6 +74,11 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan
7174
string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" APPLECLANG_VERSION_STRING ${clang_full_version_string})
7275
set (ANY_CLANG_VERSION_STRING ${APPLECLANG_VERSION_STRING})
7376
message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}")
77+
if (APPLECLANG_VERSION_STRING VERSION_LESS 5.0)
78+
message (ERROR "Apple clang minimum version is 5.0")
79+
elseif (APPLECLANG_VERSION_STRING VERSION_LESS 10.0)
80+
message (WARNING "Apple clang minimum version is 10.0. Older versions might work, but we don't test or support them.")
81+
endif ()
7482
elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
7583
set (CMAKE_COMPILER_IS_INTELCLANG 1)
7684
string (REGEX MATCH "[0-9]+(\\.[0-9]+)+" INTELCLANG_VERSION_STRING ${clang_full_version_string})
@@ -81,6 +89,11 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan
8189
string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
8290
set (ANY_CLANG_VERSION_STRING ${CLANG_VERSION_STRING})
8391
message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${CLANG_VERSION_STRING}")
92+
if (CLANG_VERSION_STRING VERSION_LESS 5.0)
93+
message (ERROR "clang minimum version is 5.0")
94+
elseif (CLANG_VERSION_STRING VERSION_LESS 10.0)
95+
message (WARNING "clang minimum version is 10.0. Older versions might work, but we don't test or support them.")
96+
endif ()
8497
endif ()
8598
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
8699
set (CMAKE_COMPILER_IS_INTEL 1)
@@ -157,11 +170,10 @@ if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_APPLECLANG)
157170
add_compile_options ("-Qunused-arguments")
158171
# Don't warn if we ask it not to warn about warnings it doesn't know
159172
add_compile_options ("-Wunknown-warning-option")
160-
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.6 OR
161-
APPLECLANG_VERSION_STRING VERSION_GREATER 6.1)
173+
if (CLANG_VERSION_STRING OR APPLECLANG_VERSION_STRING VERSION_GREATER 6.1)
162174
add_compile_options ("-Wno-unused-local-typedefs")
163175
endif ()
164-
if (CLANG_VERSION_STRING VERSION_GREATER_EQUAL 3.9)
176+
if (CLANG_VERSION_STRING)
165177
# Don't warn about using unknown preprocessor symbols in `#if`
166178
add_compile_options ("-Wno-expansion-to-defined")
167179
endif ()
@@ -174,10 +186,8 @@ if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_I
174186
# gcc specific options
175187
add_compile_options ("-Wno-unused-local-typedefs")
176188
add_compile_options ("-Wno-unused-result")
177-
if (NOT ${GCC_VERSION} VERSION_LESS 7.0)
178-
add_compile_options ("-Wno-aligned-new")
179-
add_compile_options ("-Wno-noexcept-type")
180-
endif ()
189+
add_compile_options ("-Wno-aligned-new")
190+
add_compile_options ("-Wno-noexcept-type")
181191
endif ()
182192

183193
if (INTELCLANG_VERSION_STRING VERSION_GREATER_EQUAL 2022.1.0)
@@ -284,10 +294,8 @@ endif ()
284294
# legit problem later.
285295
#
286296
set (GLIBCXX_USE_CXX11_ABI "" CACHE STRING "For gcc, use the new C++11 library ABI (0|1)")
287-
if (CMAKE_COMPILER_IS_GNUCC AND ${GCC_VERSION} VERSION_GREATER_EQUAL 5.0)
288-
if (NOT ${GLIBCXX_USE_CXX11_ABI} STREQUAL "")
289-
add_compile_definitions (_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI})
290-
endif ()
297+
if (CMAKE_COMPILER_IS_GNUCC AND NOT ${GLIBCXX_USE_CXX11_ABI} STREQUAL "")
298+
add_compile_definitions (_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI})
291299
endif ()
292300

293301

src/include/OpenImageIO/simd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,7 +3317,7 @@ OIIO_FORCEINLINE const vbool4 vbool4::False () {
33173317
OIIO_FORCEINLINE const vbool4 vbool4::True () {
33183318
// Fastest way to fill with all 1 bits is to cmp any value to itself.
33193319
#if OIIO_SIMD_SSE
3320-
# if OIIO_SIMD_AVX && (OIIO_GNUC_VERSION > 50000)
3320+
# if OIIO_SIMD_AVX
33213321
__m128i anyval = _mm_undefined_si128();
33223322
# else
33233323
__m128i anyval = _mm_setzero_si128();
@@ -3676,7 +3676,7 @@ OIIO_FORCEINLINE const vbool8 vbool8::False () {
36763676

36773677
OIIO_FORCEINLINE const vbool8 vbool8::True () {
36783678
#if OIIO_SIMD_AVX
3679-
# if OIIO_SIMD_AVX >= 2 && (OIIO_GNUC_VERSION > 50000)
3679+
# if OIIO_SIMD_AVX >= 2
36803680
// Fastest way to fill with all 1 bits is to cmp any value to itself.
36813681
__m256i anyval = _mm256_undefined_si256();
36823682
return _mm256_castsi256_ps (_mm256_cmpeq_epi8 (anyval, anyval));
@@ -4413,7 +4413,7 @@ OIIO_FORCEINLINE const vint4 vint4::NegOne () {
44134413
#if OIIO_SIMD_SSE
44144414
// Fastest way to fill an __m128 with all 1 bits is to cmpeq_epi8
44154415
// any value to itself.
4416-
# if OIIO_SIMD_AVX && (OIIO_GNUC_VERSION > 50000)
4416+
# if OIIO_SIMD_AVX
44174417
__m128i anyval = _mm_undefined_si128();
44184418
# else
44194419
__m128i anyval = _mm_setzero_si128();

src/libOpenImageIO/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if (NOT USE_EXTERNAL_PUGIXML)
1515
../include/OpenImageIO/detail/pugixml/pugixml.hpp
1616
../include/OpenImageIO/detail/pugixml/pugixml.cpp
1717
)
18-
if (CMAKE_COMPILER_IS_GNUCC AND NOT ${GCC_VERSION} VERSION_LESS 6.0)
18+
if (CMAKE_COMPILER_IS_GNUCC)
1919
set_source_files_properties (formatspec.cpp xmp.cpp
2020
PROPERTIES COMPILE_FLAGS -Wno-error=placement-new)
2121
endif ()
@@ -30,17 +30,11 @@ if (NOT MSVC)
3030
PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations")
3131
endif()
3232

33-
if (CMAKE_COMPILER_IS_GNUCC AND ${GCC_VERSION} VERSION_GREATER_EQUAL 9.0)
33+
if (CMAKE_COMPILER_IS_GNUCC)
3434
set_source_files_properties (../libutil/SHA1.cpp
3535
PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation)
3636
endif ()
3737

38-
if (CMAKE_COMPILER_IS_GNUCC AND ${GCC_VERSION} VERSION_GREATER_EQUAL 6.0
39-
AND ${GCC_VERSION} VERSION_LESS 7.0)
40-
set_source_files_properties (../openvdb.imageio/openvdbinput.cpp
41-
PROPERTIES COMPILE_FLAGS -Wno-error=strict-overflow)
42-
endif ()
43-
4438
set (libOpenImageIO_srcs
4539
imagebufalgo.cpp
4640
imagebufalgo_pixelmath.cpp

src/libutil/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set (libOpenImageIO_Util_srcs argparse.cpp benchmark.cpp
99
strutil.cpp sysutil.cpp thread.cpp timer.cpp
1010
typedesc.cpp ustring.cpp xxhash.cpp)
1111

12-
if (CMAKE_COMPILER_IS_GNUCC AND NOT ${GCC_VERSION} VERSION_LESS 9.0)
12+
if (CMAKE_COMPILER_IS_GNUCC)
1313
set_property (SOURCE SHA1.cpp
1414
APPEND PROPERTY COMPILE_OPTIONS -Wno-stringop-truncation)
1515
endif ()

src/raw.imageio/rawinput.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
#include <OpenImageIO/sysutil.h>
1717
#include <OpenImageIO/tiffutils.h>
1818

19-
#if OIIO_GNUC_VERSION || OIIO_CLANG_VERSION >= 50000
19+
#if OIIO_GNUC_VERSION || OIIO_CLANG_VERSION
2020
// fix warnings in libraw headers: use of auto_ptr
2121
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
2222
#endif
2323

24-
#if OIIO_CPLUSPLUS_VERSION >= 17 \
25-
&& ((OIIO_CLANG_VERSION && OIIO_CLANG_VERSION < 110000) \
26-
|| OIIO_APPLE_CLANG_VERSION)
24+
#if (OIIO_CLANG_VERSION && OIIO_CLANG_VERSION < 110000) \
25+
|| OIIO_APPLE_CLANG_VERSION
2726
// libraw uses auto_ptr, which is not in C++17 at all for clang, though
2827
// it does seem to be for gcc. So for clang, alias it to unique_ptr.
2928
namespace std {

0 commit comments

Comments
 (0)