Skip to content

Commit 269a897

Browse files
authored
build: raise C++ to 17, gcc min to 9.3, clang min to 5.0 (#1847)
It's time. This is for main (1.14), and will not be backported. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent b865cb0 commit 269a897

File tree

11 files changed

+78
-131
lines changed

11 files changed

+78
-131
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,7 @@ jobs:
3838
fail-fast: false
3939
matrix:
4040
include:
41-
- desc: gcc6/C++14 llvm9 py2.7 exr2.4 oiio2.3 sse2
42-
nametag: linux-vfx2020
43-
runner: ubuntu-latest
44-
container: aswftesting/ci-osl:2019-clang9
45-
vfxyear: 2019
46-
cxx_std: 14
47-
openexr_ver: v2.4.3
48-
openimageio_ver: v2.4.13.0
49-
python_ver: 2.7
50-
pybind11_ver: v2.4.2
51-
setenvs: export CMAKE_VERSION=3.15.5
52-
- desc: clang9/C++14 llvm9 oiio-release avx2 exr2.4 py2.7
53-
nametag: linux-clang9-llvm9
54-
runner: ubuntu-20.04
55-
container: aswftesting/ci-osl:2019-clang9
56-
vfxyear: 2019
57-
cc_compiler: clang
58-
cxx_compiler: clang++
59-
cxx_std: 14
60-
openexr_ver: v2.4.3
61-
openimageio_ver: release
62-
python_ver: 2.7
63-
# pybind11_ver: v2.9.0
64-
simd: avx
65-
setenvs: export CMAKE_VERSION=3.15.5
66-
- desc: gcc6/C++14 llvm10 py3.7 exr2.4 oiio2.2 sse4
67-
nametag: linux-vfx2020
68-
runner: ubuntu-latest
69-
container: aswftesting/ci-osl:2020
70-
vfxyear: 2020
71-
cxx_std: 14
72-
openimageio_ver: v2.4.13.0
73-
python_ver: 3.7
74-
pybind11_ver: v2.5.0
75-
simd: sse4.2
76-
setenvs: export CONAN_LLVM_VERSION=10.0.1
77-
- desc: gcc9/C++17 llvm11 py3.7 exr2.5 oiio2.3 avx2 batch-b8avx2
41+
- desc: gcc9/C++17 llvm11 py3.7 exr2.5 oiio2.3 sse4 batch-b8avx2
7842
nametag: linux-vfx2021
7943
runner: ubuntu-latest
8044
container: aswftesting/ci-osl:2021-clang11
@@ -83,7 +47,7 @@ jobs:
8347
openimageio_ver: v2.4.13.0
8448
python_ver: 3.7
8549
pybind11_ver: v2.7.0
86-
simd: avx2,f16c
50+
simd: sse4.2
8751
batched: b8_AVX2_noFMA
8852
- desc: gcc9/C++17 llvm13 py3.9 exr3.1 oiio-rel avx2
8953
nametag: linux-vfx2022
@@ -171,15 +135,15 @@ jobs:
171135
skip_tests: 1
172136
setenvs: export OSL_CMAKE_FLAGS="-DOSL_USE_OPTIX=1" OPTIX_VERSION=7.0
173137
OPENIMAGEIO_CMAKE_FLAGS=-DBUILD_FMT_VERSION=9.1.0
174-
- desc: oldest everything gcc6/C++14 llvm9 py2.7 oiio2.3 no-simd exr2.4
138+
- desc: oldest everything gcc9/C++17 llvm9 py3.7 oiio2.3 no-simd exr2.4
175139
nametag: linux-oldest
176140
runner: ubuntu-latest
177-
container: aswftesting/ci-osl:2019-clang9
178-
vfxyear: 2019
179-
cxx_std: 14
141+
container: aswftesting/ci-osl:2021-clang11
142+
vfxyear: 2021
143+
cxx_std: 17
180144
openexr_ver: v2.4.3
181145
openimageio_ver: v2.4.13.0
182-
python_ver: 2.7
146+
python_ver: 3.7
183147
pybind11_ver: v2.7.0
184148
simd: 0
185149
setenvs: export PUGIXML_VERSION=v1.8
@@ -344,11 +308,11 @@ jobs:
344308
fail-fast: false
345309
matrix:
346310
include:
347-
- desc: Debug gcc7/C++14 llvm9 py2.7 oiio2.3 exr2.4 sse4 exr2.4
311+
- desc: Debug gcc7/C++17 llvm9 py3.7 oiio2.3 exr2.4 sse4 exr2.4
348312
nametag: linux-debug-gcc7-llvm9
349313
runner: ubuntu-20.04
350-
cxx_compiler: g++-7
351-
cxx_std: 14
314+
cxx_compiler: g++-9
315+
cxx_std: 17
352316
openexr_ver: v2.4.3
353317
openimageio_ver: v2.4.13.0
354318
pybind11_ver: v2.6.2

INSTALL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ NEW or CHANGED dependencies since the last major release are **bold**.
2121

2222
* Build system: [CMake](https://cmake.org/) **3.15 or newer** (tested through 3.27)
2323

24-
* A suitable C++14 or C++17 compiler to build OSL itself, which may be any of:
25-
- GCC 6.1 or newer (tested through gcc 12.1)
26-
- Clang 3.4 or newer (tested through clang 17)
24+
* A suitable C++17 compiler to build OSL itself, which may be any of:
25+
- **GCC 9.3** or newer (tested through gcc 12.1)
26+
- **Clang 5** or newer (tested through clang 18)
2727
- Microsoft Visual Studio 2017 or newer
28-
- Intel C++ compiler icc version 17 or newer or LLVM-based icx compiler
28+
- Intel C++ compiler **icc version 19** or newer or LLVM-based icx compiler
2929
version 2022 or newer.
3030

3131
* **[OpenImageIO](http://openimageio.org) 2.4 or newer** (tested through 2.5 and master)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ help:
349349
@echo " VERBOSE=1 Show all compilation commands"
350350
@echo " STOP_ON_WARNING=0 Do not stop building if compiler warns"
351351
@echo " MYCC=xx MYCXX=yy Use custom compilers"
352-
@echo " CMAKE_CXX_STANDARD=14 C++ standard to build with (default is 14)"
352+
@echo " CMAKE_CXX_STANDARD=17 C++ standard to build with (default is 17)"
353353
@echo " USE_LIBCPLUSPLUS=1 For clang, use libc++"
354354
@echo " GLIBCXX_USE_CXX11_ABI=1 For gcc, use the new string ABI"
355355
@echo " EXTRA_CPP_ARGS= Additional args to the C++ command"

doc/build_install/windows/build_osl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,8 +1048,7 @@ def InstallOSL(context, force, buildArgs):
10481048
extraArgs.append("-DUSE_PYTHON=0")
10491049

10501050
extraArgs.append("-DOSL_BUILD_TESTS=0")
1051-
# if you are using LLVM 10 or higher C++ should be set on 14
1052-
extraArgs.append("-DCMAKE_CXX_STANDARD=14")
1051+
extraArgs.append("-DCMAKE_CXX_STANDARD=17")
10531052

10541053
# if you are using LLVM 10 or higher C++ should be set on 11
10551054
# extraArgs.append("-DCMAKE_CXX_STANDARD=11")
@@ -1273,7 +1272,7 @@ def InstallOpenColorIO(context, force, buildArgs):
12731272
option. This values for this option must take the form <library name>,<option>.
12741273
For example:
12751274
1276-
%(prog)s --build-args cxxflags=... OSL,-DCMAKE_CXX_STANDARD=14 ...
1275+
%(prog)s --build-args cxxflags=... OSL,-DCMAKE_CXX_STANDARD=17 ...
12771276
12781277
These arguments will be passed directly to the build system for the specified
12791278
library. Multiple quotes may be needed to ensure arguments are passed on

src/cmake/compiler.cmake

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,22 @@ message (STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
2525
###########################################################################
2626
# C++ language standard
2727
#
28+
set (CMAKE_CXX_MINIMUM 17)
2829
set (CMAKE_CXX_STANDARD 17 CACHE STRING
29-
"C++ standard to build with (14, 17, 20, etc.)")
30-
set (DOWNSTREAM_CXX_STANDARD 14 CACHE STRING
30+
"C++ standard to build with (17, 20, etc.) Minimum is ${CMAKE_CXX_MINIMUM}.")
31+
set (DOWNSTREAM_CXX_STANDARD 17 CACHE STRING
3132
"C++ minimum standard to impose on downstream clients")
3233
set (CMAKE_CXX_STANDARD_REQUIRED ON)
3334
set (CMAKE_CXX_EXTENSIONS OFF)
3435
message (STATUS "Building with C++${CMAKE_CXX_STANDARD}, downstream minimum C++${DOWNSTREAM_CXX_STANDARD}")
36+
if (CMAKE_CXX_STANDARD VERSION_LESS CMAKE_CXX_MINIMUM)
37+
message (FATAL_ERROR "C++${CMAKE_CXX_STANDARD} is not supported, minimum is C++${CMAKE_CXX_MINIMUM}")
38+
endif ()
39+
# Remember the -std flags we need will be used later for custom Cuda builds
40+
set (CSTD_FLAGS "")
41+
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_INTEL)
42+
set (CSTD_FLAGS "-std=c++${CMAKE_CXX_STANDARD}")
43+
endif ()
3544

3645

3746
###########################################################################

src/include/OSL/oslconfig.h.in

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -248,19 +248,8 @@ enum class SymArena {
248248
// various C++ versions or compilers, or to make up for things not
249249
// yet available in earlier C++ standards.
250250

251-
#if OSL_CPLUSPLUS_VERSION >= 17
252-
// fold expression to expand
253-
#define __OSL_EXPAND_PARAMETER_PACKS(EXPRESSION) \
254-
(void((EXPRESSION)) , ... );
255-
#else
256-
// Choose to use initializer list to expand our parameter pack so that
257-
// the order they are evaluated in the order they appear
258-
#define __OSL_EXPAND_PARAMETER_PACKS(EXPRESSION) \
259-
{ \
260-
using expander = int [sizeof...(IntListT)]; \
261-
(void)expander{((EXPRESSION),0)...}; \
262-
}
263-
#endif
251+
// fold expression to expand
252+
#define __OSL_EXPAND_PARAMETER_PACKS(EXPRESSION) (void((EXPRESSION)), ...);
264253

265254

266255
namespace pvt {
@@ -271,26 +260,20 @@ using int_sequence = std::integer_sequence<int, IntegerListT...>;
271260
template<int EndBeforeT>
272261
using make_int_sequence = std::make_integer_sequence<int, EndBeforeT>;
273262

274-
template<bool... BoolListT >
275-
using bool_sequence = std::integer_sequence<bool, BoolListT... >;
263+
template<bool... BoolListT>
264+
using bool_sequence = std::integer_sequence<bool, BoolListT...>;
276265

277-
#if (OSL_CPLUSPLUS_VERSION >= 17)
278-
template<class... ListT>
279-
using conjunction = std::conjunction<ListT...>;
280-
#else
281-
template<class... ListT>
282-
using conjunction = std::is_same<bool_sequence<true,ListT::value...>, bool_sequence<ListT::value..., true>>;
283-
#endif
266+
template<class... ListT> using conjunction = std::conjunction<ListT...>;
284267

285-
// We need the SFINAE type to be different for
286-
// enable_if_type from disable_if_type so that we can apply both to
287-
// the same template signature to avoid
288-
// "error: invalid redeclaration of member function template"
289-
// NOTE: std::enable_if_t is a c++14 library feature, our baseline
290-
// and we wish to remain compatible with c++11 header libraries.
291-
// Also we are using std::true_type vs. void as the default type
292-
template <bool TestT, typename TypeT = std::true_type>
293-
using enable_if_type = typename std::enable_if<TestT, TypeT>::type;
268+
// We need the SFINAE type to be different for
269+
// enable_if_type from disable_if_type so that we can apply both to
270+
// the same template signature to avoid
271+
// "error: invalid redeclaration of member function template"
272+
// NOTE: std::enable_if_t is a c++14 library feature, our baseline
273+
// and we wish to remain compatible with c++11 header libraries.
274+
// Also we are using std::true_type vs. void as the default type
275+
template<bool TestT, typename TypeT = std::true_type>
276+
using enable_if_type = typename std::enable_if<TestT, TypeT>::type;
294277

295278
} // namespace pvt
296279

src/include/OSL/oslversion.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace @PROJ_NAME@ = @PROJ_NAMESPACE_V@;
8484
#define @PROJ_NAME@_BUILD_CPP14 (@CMAKE_CXX_STANDARD@ >= 14)
8585
#define @PROJ_NAME@_BUILD_CPP17 (@CMAKE_CXX_STANDARD@ >= 17)
8686
#define @PROJ_NAME@_BUILD_CPP20 (@CMAKE_CXX_STANDARD@ >= 20)
87+
#define @PROJ_NAME@_BUILD_CPP23 (@CMAKE_CXX_STANDARD@ >= 20)
8788

8889
#define OSL_SHADER_INSTALL_DIR "@OSL_SHADER_INSTALL_DIR@"
8990

src/include/OSL/platform.h

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@
113113
# define OSL_MSVS_BEFORE_2015 (_MSC_VER < 1900)
114114
# define OSL_MSVS_AT_LEAST_2017 (_MSC_VER >= 1910)
115115
# define OSL_MSVS_BEFORE_2017 (_MSC_VER < 1910)
116+
# define OSL_MSVS_AT_LEAST_2019 (_MSC_VER >= 1920)
117+
# define OSL_MSVS_BEFORE_2019 (_MSC_VER < 1920)
118+
# define OSL_MSVS_AT_LEAST_2022 (_MSC_VER >= 1930)
119+
# define OSL_MSVS_BEFORE_2022 (_MSC_VER < 1930)
116120
# if OSL_MSVS_BEFORE_2017
117121
# error "This version of OSL is meant to work only with Visual Studio 2017 or later"
118122
# endif
@@ -124,6 +128,10 @@
124128
# define OSL_MSVS_BEFORE_2015 0
125129
# define OSL_MSVS_AT_LEAST_2017 0
126130
# define OSL_MSVS_BEFORE_2017 0
131+
# define OSL_MSVS_AT_LEAST_2019 0
132+
# define OSL_MSVS_BEFORE_2019 0
133+
# define OSL_MSVS_AT_LEAST_2022 0
134+
# define OSL_MSVS_BEFORE_2022 0
127135
#endif
128136

129137

@@ -132,31 +140,28 @@
132140
// Detect which C++ standard we're using, and handy macros.
133141
// See https://en.cppreference.com/w/cpp/compiler_support
134142
//
135-
// Note: oslversion.h defines OSL_BUILD_CPP to be 14, 17, etc., to reflect
143+
// Note: oslversion.h defines OSL_BUILD_CPP to be 17, 20, etc., to reflect
136144
// the version that OSL itself was built with. In contrast,
137145
// OSL_CPLUSPLUS_VERSION defined below will be set to the right number for
138146
// the C++ standard being compiled RIGHT NOW by whomever is parsing these
139147
// header files. These two things may be the same when compiling OSL, but
140148
// they may not be the same if another package is compiling against OSL and
141-
// using these headers (e.g., OSL may be C++14 but the client package may be
149+
// using these headers (e.g., OSL may be C++17 but the client package may be
142150
// newer, or vice versa -- use these two symbols to differentiate these
143151
// cases, when important).
144152
#if (__cplusplus >= 202001L)
145153
# define OSL_CPLUSPLUS_VERSION 20
146-
# define OSL_CONSTEXPR17 constexpr
147154
# define OSL_CONSTEXPR20 constexpr
148-
#elif (__cplusplus >= 201703L)
155+
#elif (__cplusplus >= 201703L) || (defined(_MSC_VER) && _MSC_VER >= 1914)
149156
# define OSL_CPLUSPLUS_VERSION 17
150-
# define OSL_CONSTEXPR17 constexpr
151-
# define OSL_CONSTEXPR20 /* not constexpr before C++20 */
152-
#elif (__cplusplus >= 201402L) || (defined(_MSC_VER) && _MSC_VER >= 1914)
153-
# define OSL_CPLUSPLUS_VERSION 14
154-
# define OSL_CONSTEXPR17 /* not constexpr before C++17 */
155157
# define OSL_CONSTEXPR20 /* not constexpr before C++20 */
156158
#else
157-
# error "This version of OSL requires C++14 or above"
159+
# error "This version of OSL requires C++17 or above"
158160
#endif
159161

162+
// DEPRECATED(1.14): use C++17 constexpr
163+
#define OSL_CONSTEXPR17 constexpr
164+
160165
// DEPRECATED(1.12): use C++14 constexpr
161166
#define OSL_CONSTEXPR14 constexpr
162167

@@ -339,13 +344,9 @@
339344

340345
// OSL_MAYBE_UNUSED is a function or variable attribute that assures the
341346
// compiler that it's fine for the item to appear to be unused.
342-
#if OSL_CPLUSPLUS_VERSION >= 17 || __has_cpp_attribute(maybe_unused)
343-
# define OSL_MAYBE_UNUSED [[maybe_unused]]
344-
#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) || __has_attribute(unused)
345-
# define OSL_MAYBE_UNUSED __attribute__((unused))
346-
#else
347-
# define OSL_MAYBE_UNUSED
348-
#endif
347+
// Consider this deprecated (as of OSL 1.14, C++17 minimum), you should favor
348+
// C++17's [[maybe_unused]] attribute.
349+
#define OSL_MAYBE_UNUSED [[maybe_unused]]
349350

350351

351352
// Some compilers define a special intrinsic to use in conditionals that can
@@ -393,26 +394,18 @@
393394

394395

395396
// OSL_DEPRECATED before a function declaration marks it as deprecated in
396-
// a way that will generate compile warnings if it is called (but will
397-
// preserve linkage compatibility).
398-
#if OSL_CPLUSPLUS_VERSION >= 14 || __has_cpp_attribute(deprecated)
399-
# define OSL_DEPRECATED(msg) [[deprecated(msg)]]
400-
#elif defined(__GNUC__) || defined(__clang__) || __has_attribute(deprecated)
401-
# define OSL_DEPRECATED(msg) __attribute__((deprecated(msg)))
402-
#elif defined(_MSC_VER)
403-
# define OSL_DEPRECATED(msg) __declspec(deprecated(msg))
404-
#else
405-
# define OSL_DEPRECATED(msg)
406-
#endif
397+
// a way that will generate compile warnings if it is called. This should
398+
// itself be considered deprecated (as of OSL 1.14) and code should use
399+
// [[deprecated(msg)]] instead.
400+
#define OSL_DEPRECATED(msg) [[deprecated(msg)]]
401+
407402

408403
// OSL_FALLTHROUGH at the end of a `case` label's statements documents that
409404
// the switch statement case is intentionally falling through to the code for
410405
// the next case.
411-
#if OSL_CPLUSPLUS_VERSION >= 17 || __has_cpp_attribute(fallthrough)
412-
# define OSL_FALLTHROUGH [[fallthrough]]
413-
#else
414-
# define OSL_FALLTHROUGH
415-
#endif
406+
// Consider this deprecated (as of OSL 1.14), you should favor C++17's
407+
// [[fallthrough]] attribute.
408+
#define OSL_FALLTHROUGH [[fallthrough]]
416409

417410

418411
// OSL_NODISCARD following a function declaration documents that the

testsuite/example-batched-deformer/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
# SPDX-License-Identifier: BSD-3-Clause
33
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
44

5-
cmake_minimum_required (VERSION 3.12)
5+
cmake_minimum_required (VERSION 3.15)
66
project (oslbatcheddeformer
77
LANGUAGES CXX)
88

99
if (NOT CMAKE_BUILD_TYPE)
10-
#set (CMAKE_BUILD_TYPE "Release")
11-
set (CMAKE_BUILD_TYPE "Debug")
10+
set (CMAKE_BUILD_TYPE "Release")
1211
endif ()
13-
set (CMAKE_BUILD_TYPE "Debug")
1412

1513
message (STATUS "Building ${PROJECT_NAME} ${PROJECT_VERSION} - ${CMAKE_BUILD_TYPE}")
1614

@@ -20,7 +18,7 @@ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
2018
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2119

2220
# Use C++11
23-
set (CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to prefer (14, 17, 20, etc.)")
21+
set (CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to prefer (17, 20, etc.)")
2422
set (CMAKE_CXX_STANDARD_REQUIRED ON)
2523
set (CMAKE_CXX_EXTENSIONS OFF)
2624

testsuite/example-cuda/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: BSD-3-Clause
33
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
44

5-
cmake_minimum_required(VERSION 3.12)
5+
cmake_minimum_required(VERSION 3.15)
66
project(examplecuda LANGUAGES CXX)
77

88
if (NOT CMAKE_BUILD_TYPE)
@@ -38,8 +38,8 @@ find_library(CUDA_cuda_LIBRARY cuda HINTS ${CUDA_TOOLKIT_ROOT_DIR} PATH_SUFFIXES
3838
# TODO: move to sm_60?
3939
set(CUDA_TARGET_ARCH sm_35)
4040

41-
set (CMAKE_CXX_STANDARD 14 CACHE STRING
42-
"C++ standard to build with (14, 17, 20, etc.)")
41+
set (CMAKE_CXX_STANDARD 17 CACHE STRING
42+
"C++ standard to build with (17, 20, etc.)")
4343

4444
# Compile our "renderer" to PTX
4545
cuda_compile_ptx(CUDA_PTX_FILES cuda_grid_renderer.cu
@@ -84,6 +84,6 @@ add_executable(example-cuda example-cuda.cpp cuda_grid_renderer.cpp)
8484

8585
target_link_libraries(example-cuda PRIVATE OSL::oslexec OSL::oslquery ${CUDA_LIBRARIES} ${CUDA_nvrtc_LIBRARY} ${CUDA_cuda_LIBRARY})
8686
target_include_directories(example-cuda PRIVATE ${CUDA_INCLUDE_DIRS})
87-
set_property(TARGET example-cuda PROPERTY CXX_STANDARD 14)
87+
set_property(TARGET example-cuda PROPERTY CXX_STANDARD 17)
8888

8989
install(TARGETS example-cuda DESTINATION ${CMAKE_CURRENT_SOURCE_DIR})

0 commit comments

Comments
 (0)