Skip to content

cleanup: Simplify some clauses involving old compilers #2016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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})
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 ()


Expand Down
4 changes: 4 additions & 0 deletions src/include/OSL/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
14 changes: 4 additions & 10 deletions src/liboslcomp/osllex.l
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions src/liboslexec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
10 changes: 3 additions & 7 deletions src/liboslexec/constfold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 4 additions & 10 deletions src/liboslexec/osolex.l
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading