Commit: bcb7b119ae5240632b7f8b07f926c230f3c48daf Author: Campbell Barton Date: Mon Sep 26 12:26:48 2022 +1000 Branches: master https://developer.blender.org/rBbcb7b119ae5240632b7f8b07f926c230f3c48daf
Cleanup: remove workarounds and version checks for unsupported compilers Match minimum supported versions from the WIKI [0] by raising them to: - GCC 9.3.1 - CLANG 8.0 - MVCS 2019 (16.9.16 / 1928) Details: - Add CMake checks that ensure supported compiler versions early on. - Previously GCC per-processor version checks served to exclude `__clang__`, in some cases this has been replaced by explicitly excluding `__clang__`. This was needed as CLANG treated some of these flags differently to GCC, causing the build to fail. - Remove USE_APPLE_OMP_FIX GCC-4.2 OpenMP workaround. - Remove linking error workaround for old MSVC versions. [0]: https://wiki.blender.org/wiki/Building_Blender Reviewed by: brecht, LazyDodo Ref D16068 =================================================================== M CMakeLists.txt M build_files/cmake/macros.cmake M build_files/cmake/platform/platform_unix.cmake M build_files/cmake/platform/platform_win32.cmake M extern/gflags/CMakeLists.txt M intern/atomic/intern/atomic_ops_utils.h M intern/atomic/tests/atomic_test.cc M source/blender/blenlib/BLI_assert.h M source/blender/blenlib/BLI_compiler_attrs.h M source/blender/blenlib/BLI_endian_switch_inline.h M source/blender/blenlib/BLI_math_inline.h M source/blender/blenlib/BLI_strict_flags.h M source/blender/blenlib/BLI_winstuff.h M source/blender/blenlib/intern/threads.cc M source/blender/imbuf/intern/openexr/openexr_api.cpp =================================================================== diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a48caa4eae..ef3309ded48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,6 +111,25 @@ blender_project_hack_post() enable_testing() +# ----------------------------------------------------------------------------- +# Test Compiler Support +# +# Keep in sync with: https://wiki.blender.org/wiki/Building_Blender + +if(CMAKE_COMPILER_IS_GNUCC) + if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "9.3.1") + message(FATAL_ERROR "The minimum supported version of GCC is 9.3.1") + endif() +elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") + if(CMAKE_COMPILER_IS_GNUCC AND ("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "8.0")) + message(FATAL_ERROR "The minimum supported version of CLANG is 8.0") + endif() +elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC) + if(MSVC_VERSION VERSION_LESS "1928") + message(FATAL_ERROR "The minimum supported version of MSVC is 2019 (16.9.16)") + endif() +endif() + # ----------------------------------------------------------------------------- # Test Compiler/Library Features @@ -1428,22 +1447,13 @@ if(CMAKE_COMPILER_IS_GNUCC) add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_NULL -Wnonnull) add_check_c_compiler_flag(C_WARNINGS C_WARN_ABSOLUTE_VALUE -Wabsolute-value) - # gcc 4.2 gives annoying warnings on every file with this - if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3") - add_check_c_compiler_flag(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized) - add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) - endif() + add_check_c_compiler_flag(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized) + add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) - # versions before gcc4.6 give many BLI_math warnings - if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.6") - add_check_c_compiler_flag(C_WARNINGS C_WARN_REDUNDANT_DECLS -Wredundant-decls) - add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls) - endif() + add_check_c_compiler_flag(C_WARNINGS C_WARN_REDUNDANT_DECLS -Wredundant-decls) + add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls) - # versions before gcc4.8 include global name-space. - if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.8") - add_check_c_compiler_flag(C_WARNINGS C_WARN_SHADOW -Wshadow) - endif() + add_check_c_compiler_flag(C_WARNINGS C_WARN_SHADOW -Wshadow) # disable because it gives warnings for printf() & friends. # add_check_c_compiler_flag(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion) @@ -1470,11 +1480,7 @@ if(CMAKE_COMPILER_IS_GNUCC) add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness) add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict) add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override) - - # gcc 4.2 gives annoying warnings on every file with this - if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3") - add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) - endif() + add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) # causes too many warnings if(NOT APPLE) @@ -1483,11 +1489,8 @@ if(CMAKE_COMPILER_IS_GNUCC) endif() # Use 'ATTR_FALLTHROUGH' macro to suppress. - if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0")) - add_check_c_compiler_flag(C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5) - add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5) - endif() - + add_check_c_compiler_flag(C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5) + add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5) # --------------------- # Suppress Strict Flags @@ -1517,9 +1520,7 @@ if(CMAKE_COMPILER_IS_GNUCC) add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable) add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized) - if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0")) - add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough) - endif() + add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough) if(NOT APPLE) add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) @@ -1609,6 +1610,8 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") "/w34062" # switch statement contains 'default' but no 'case' labels "/w34115" # 'type' : named type definition in parentheses "/w34189" # local variable is initialized but not referenced + # see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017 + "/w35038" # order of initialization in c++ constructors # disable: "/wd4018" # signed/unsigned mismatch "/wd4146" # unary minus operator applied to unsigned type, result still unsigned @@ -1630,11 +1633,6 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") "/we4431" # missing type specifier - int assumed ) - if(MSVC_VERSION GREATER_EQUAL 1911) - # see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017 - string(APPEND _WARNINGS " /w35038") # order of initialization in c++ constructors - endif() - string(REPLACE ";" " " _WARNINGS "${_WARNINGS}") set(C_WARNINGS "${_WARNINGS}") set(CXX_WARNINGS "${_WARNINGS}") @@ -1686,7 +1684,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) # Make MSVC properly report the value of the __cplusplus preprocessor macro # Available MSVC 15.7 (1914) and up, without this it reports 199711L regardless # of the C++ standard chosen above. -if(MSVC AND MSVC_VERSION GREATER 1913) +if(MSVC) string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus") endif() diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index d41024759fc..3acea19079b 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -1190,8 +1190,6 @@ macro(openmp_delayload if(WITH_OPENMP) if(MSVC_CLANG) set(OPENMP_DLL_NAME "libomp") - elseif(MSVC_VERSION EQUAL 1800) - set(OPENMP_DLL_NAME "vcomp120") else() set(OPENMP_DLL_NAME "vcomp140") endif() diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index bfbc6b76b40..f640f7f7650 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -26,11 +26,6 @@ if(NOT DEFINED LIBDIR) else() set(WITH_LIBC_MALLOC_HOOK_WORKAROUND True) endif() - - if(CMAKE_COMPILER_IS_GNUCC AND - CMAKE_C_COMPILER_VERSION VERSION_LESS 9.3) - message(FATAL_ERROR "GCC version must be at least 9.3 for precompiled libraries, found ${CMAKE_C_COMPILER_VERSION}") - endif() endif() # Avoid namespace pollustion. diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index eeec4760b80..866d0bede3d 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -74,27 +74,6 @@ add_definitions(-DWIN32) add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>") add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>") -# Minimum MSVC Version -if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) - if(MSVC_VERSION EQUAL 1800) - set(_min_ver "18.0.31101") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver}) - message(FATAL_ERROR - "Visual Studio 2013 (Update 4, ${_min_ver}) required, " - "found (${CMAKE_CXX_COMPILER_VERSION})") - endif() - endif() - if(MSVC_VERSION EQUAL 1900) - set(_min_ver "19.0.24210") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver}) - message(FATAL_ERROR - "Visual Studio 2015 (Update 3, ${_min_ver}) required, " - "found (${CMAKE_CXX_COMPILER_VERSION})") - endif() - endif() -endif() -unset(_min_ver) - # needed for some MSVC installations # 4099 : PDB 'filename' was not found with 'object/library' string(APPEND CMAKE_EXE_LINKER_FLAGS " /SAFESEH:NO /ignore:4099") @@ -158,7 +137,7 @@ endif() # C++ standards conformace (/permissive-) is available on msvc 15.5 (1912) and up -if(MSVC_VERSION GREATER 1911 AND NOT MSVC_CLANG) +if(NOT MSVC_CLANG) string(APPEND CMAKE_CXX_FLAGS " /permissive-") # Two-phase name lookup does not place nicely with OpenMP yet, so disable for now string(APPEND CMAKE_CXX_FLAGS " /Zc:twoPhase-") @@ -218,7 +197,7 @@ unset(SYMBOL_FORMAT) unset(SYMBOL_FORMAT_RELEASE) # JMC is available on msvc 15.8 (1915) and up -if(MSVC_VERSION GREATER 1914 AND NOT MSVC_CLANG) +if(NOT MSVC_CLANG) string(APPEND CMAKE_CXX_FLAGS_DEBUG " /JMC") endif() @@ -251,9 +230,6 @@ if(NOT DEFINED LIBDIR) elseif(MSVC_VERSION GREATER 1919) message(STATUS "Visual Studio 2019 detected.") set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15) - elseif(MSVC_VERSION GREATER 1909) - message(STATUS "Visual Studio 2017 detected.") - set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15) endif() else() message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") @@ -264,10 +240,8 @@ endif() include(platform_old_libs_update) -if(CMAKE_GENERATOR MATCHES "^Visual Studio.+" AND # Only supported in the VS IDE - MSVC_VERSION GREATER_EQUAL 1924 AND # Supported for 16.4+ - WITH_CLANG_TIDY # And Clang Tidy needs to be on - ) +# Only supported in the VS IDE & Clang Tidy needs to be on. +if(CMAKE_GENERATOR MATCHES "^Visual Studio.+" AND WITH_CLANG_TIDY) set(CMAKE_VS_GLOBALS "RunCodeAnalysis=false" "EnableMicrosoftCodeAnalysis=false" @@ -278,8 +252,7 @@ endif() # Mark libdir as system headers with a lower warn level, to resolve some warnings # that we have very little control @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
