diff --git a/src/cmake/compiler.cmake b/src/cmake/compiler.cmake index 8051196d4..e52cd9a6c 100644 --- a/src/cmake/compiler.cmake +++ b/src/cmake/compiler.cmake @@ -49,6 +49,9 @@ if (CMAKE_COMPILER_IS_GNUCC) OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) message (VERBOSE "Using gcc ${GCC_VERSION} as the compiler") + if (GCC_VERSION VERSION_LESS 9.0) + message (ERROR "gcc minimum version is 9.0") + endif () else () set (GCC_VERSION 0) endif () @@ -67,6 +70,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" APPLECLANG_VERSION_STRING ${clang_full_version_string}) set (ANY_CLANG_VERSION_STRING ${APPLECLANG_VERSION_STRING}) message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${APPLECLANG_VERSION_STRING}") + if (APPLECLANG_VERSION_STRING VERSION_LESS 5.0) + message (ERROR "Apple clang minimum version is 5.0") + endif () elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM") set (CMAKE_COMPILER_IS_INTELCLANG 1) string (REGEX MATCH "[0-9]+(\\.[0-9]+)+" INTELCLANG_VERSION_STRING ${clang_full_version_string}) @@ -77,6 +83,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER MATCHES "[Cc]lan string (REGEX REPLACE ".* version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string}) set (ANY_CLANG_VERSION_STRING ${CLANG_VERSION_STRING}) message (VERBOSE "The compiler is Clang: ${CMAKE_CXX_COMPILER_ID} version ${CLANG_VERSION_STRING}") + if (CLANG_VERSION_STRING VERSION_LESS 5.0) + message (ERROR "clang minimum version is 5.0") + endif () endif () elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel") set (CMAKE_COMPILER_IS_INTEL 1) @@ -180,9 +189,7 @@ if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_I add_compile_options ("-Wno-error=strict-overflow") add_compile_options ("-Wno-unused-local-typedefs") add_compile_options ("-Wno-unused-result") - if (NOT ${GCC_VERSION} VERSION_LESS 6.0) - add_compile_options ("-Wno-error=misleading-indentation") - endif () + add_compile_options ("-Wno-error=misleading-indentation") endif () if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) @@ -276,10 +283,8 @@ endif () # legit problem later. # set (GLIBCXX_USE_CXX11_ABI "" CACHE STRING "For gcc, use the new C++11 library ABI (0|1)") -if (CMAKE_COMPILER_IS_GNUCC AND ${GCC_VERSION} VERSION_GREATER_EQUAL 5.0) - if (NOT ${GLIBCXX_USE_CXX11_ABI} STREQUAL "") - add_compile_definitions (_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}) - endif () +if (CMAKE_COMPILER_IS_GNUCC AND NOT ${GLIBCXX_USE_CXX11_ABI} STREQUAL "") + add_compile_definitions (_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}) endif () diff --git a/src/include/OSL/platform.h b/src/include/OSL/platform.h index e4f00a43d..86735ec9e 100644 --- a/src/include/OSL/platform.h +++ b/src/include/OSL/platform.h @@ -208,8 +208,10 @@ # define OSL_GCC_PRAGMA(UnQuotedPragma) OSL_PRAGMA(UnQuotedPragma) # if defined(__clang__) # define OSL_CLANG_PRAGMA(UnQuotedPragma) OSL_PRAGMA(UnQuotedPragma) +# define OSL_GCC_ONLY_PRAGMA(UnQuotedPragma) # else # define OSL_CLANG_PRAGMA(UnQuotedPragma) +# define OSL_GCC_ONLY_PRAGMA(UnQuotedPragma) OSL_PRAGMA(UnQuotedPragma) # endif # if defined(__INTEL_COMPILER) # define OSL_INTEL_CLASSIC_PRAGMA(UnQuotedPragma) OSL_PRAGMA(UnQuotedPragma) @@ -228,6 +230,7 @@ # define OSL_PRAGMA_VISIBILITY_PUSH /* N/A on MSVS */ # define OSL_PRAGMA_VISIBILITY_POP /* N/A on MSVS */ # define OSL_GCC_PRAGMA(UnQuotedPragma) +# define OSL_GCC_ONLY_PRAGMA(UnQuotedPragma) # define OSL_CLANG_PRAGMA(UnQuotedPragma) # define OSL_INTEL_CLASSIC_PRAGMA(UnQuotedPragma) # define OSL_INTEL_LLVM_PRAGMA(UnQuotedPragma) @@ -238,6 +241,7 @@ # define OSL_PRAGMA_VISIBILITY_PUSH # define OSL_PRAGMA_VISIBILITY_POP # define OSL_GCC_PRAGMA(UnQuotedPragma) +# define OSL_GCC_ONLY_PRAGMA(UnQuotedPragma) # define OSL_CLANG_PRAGMA(UnQuotedPragma) # define OSL_INTEL_CLASSIC_PRAGMA(UnQuotedPragma) # define OSL_INTEL_LLVM_PRAGMA(UnQuotedPragma) diff --git a/src/liboslcomp/osllex.l b/src/liboslcomp/osllex.l index d304cdea8..da2650ddc 100644 --- a/src/liboslcomp/osllex.l +++ b/src/liboslcomp/osllex.l @@ -103,18 +103,12 @@ using namespace OSL::pvt; // flex itself will generate fatal warnings about signed vs unsigned. // Bypass that nonsense. -#if OSL_GNUC_VERSION >= 60000 -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif +OSL_GCC_ONLY_PRAGMA(GCC diagnostic ignored "-Wsign-compare") // flex uses the 'register' keyword, warned because it's deprecated in C++17. -#if defined(__clang__) -#pragma GCC diagnostic ignored "-Wdeprecated-register" -#pragma GCC diagnostic ignored "-Wregister" -#endif -#if OSL_GNUC_VERSION >= 90000 -#pragma GCC diagnostic ignored "-Wregister" -#endif +OSL_CLANG_PRAGMA(GCC diagnostic ignored "-Wdeprecated-register") +OSL_CLANG_PRAGMA(GCC diagnostic ignored "-Wregister") +OSL_GCC_ONLY_PRAGMA(GCC diagnostic ignored "-Wregister") #if defined(__GNUC__) || defined(__clang__) #pragma GCC visibility push(hidden) diff --git a/src/liboslexec/CMakeLists.txt b/src/liboslexec/CMakeLists.txt index 8b9cfccda..2ed348b95 100644 --- a/src/liboslexec/CMakeLists.txt +++ b/src/liboslexec/CMakeLists.txt @@ -440,12 +440,10 @@ foreach(batched_target ${BATCHED_TARGET_LIST}) if (${TARGET_OPT_ISA} STREQUAL "AVX512") list (APPEND TARGET_CXX_OPTS "-march=skylake-avx512") - if (NOT ${GCC_VERSION} VERSION_LESS 8.1) - if (${TARGET_BATCH_SIZE} STREQUAL "16") - list (APPEND TARGET_CXX_OPTS "-mprefer-vector-width=512") - else () - list (APPEND TARGET_CXX_OPTS "-mprefer-vector-width=256") - endif () + if (${TARGET_BATCH_SIZE} STREQUAL "16") + list (APPEND TARGET_CXX_OPTS "-mprefer-vector-width=512") + else () + list (APPEND TARGET_CXX_OPTS "-mprefer-vector-width=256") endif () elseif (${TARGET_OPT_ISA} STREQUAL "AVX2") list (APPEND TARGET_CXX_OPTS "-march=haswell") diff --git a/src/liboslexec/constfold.cpp b/src/liboslexec/constfold.cpp index 76d22ccb0..bc3364a54 100644 --- a/src/liboslexec/constfold.cpp +++ b/src/liboslexec/constfold.cpp @@ -2866,10 +2866,8 @@ DECLFOLDER(constfold_noise) return 0; // optional args starting, we don't fold them yet } -#if OSL_GNUC_VERSION >= 90000 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#endif + OSL_PRAGMA_WARNING_PUSH + OSL_GCC_ONLY_PRAGMA(GCC diagnostic ignored "-Wmaybe-uninitialized") if (name == u_cellnoise || name == u_cell) { CellNoise cell; if (outdim == 1) { @@ -2901,9 +2899,7 @@ DECLFOLDER(constfold_noise) return 1; } } -#if OSL_GNUC_VERSION >= 90000 -# pragma GCC diagnostic pop -#endif + OSL_PRAGMA_WARNING_POP return 0; } diff --git a/src/liboslexec/osolex.l b/src/liboslexec/osolex.l index 9c87489ab..d51aaa10d 100644 --- a/src/liboslexec/osolex.l +++ b/src/liboslexec/osolex.l @@ -111,18 +111,12 @@ OSL_NAMESPACE_END // flex itself will generate fatal warnings about signed vs unsigned. // Bypass that nonsense. -#if OSL_GNUC_VERSION >= 60000 -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif +OSL_GCC_ONLY_PRAGMA(GCC diagnostic ignored "-Wsign-compare") // flex uses the 'register' keyword, warned because it's deprecated in C++17. -#if defined(__clang__) -#pragma GCC diagnostic ignored "-Wdeprecated-register" -#pragma GCC diagnostic ignored "-Wregister" -#endif -#if OSL_GNUC_VERSION >= 90000 -#pragma GCC diagnostic ignored "-Wregister" -#endif +OSL_CLANG_PRAGMA(GCC diagnostic ignored "-Wdeprecated-register") +OSL_CLANG_PRAGMA(GCC diagnostic ignored "-Wregister") +OSL_GCC_ONLY_PRAGMA(GCC diagnostic ignored "-Wregister") #if defined(__GNUC__) || defined(__clang__) #pragma GCC visibility push(hidden)