]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Disable some AVX features on old Apple clang versions (#704)
authorErik Flodin <erik@ejohansson.se>
Fri, 30 Oct 2020 09:41:58 +0000 (10:41 +0100)
committerGitHub <noreply@github.com>
Fri, 30 Oct 2020 09:41:58 +0000 (10:41 +0100)
Disable avx2 and avx512 support on some apple clang versions as the compile
fails even though the compiler seems to accept the -m flags that are used to
enable the feature.

See issue #689.

cmake/GenerateConfigurationFile.cmake
cmake/StandardSettings.cmake
src/third_party/blake3/CMakeLists.txt

index 0a33f763a0ae34e100241be64af26a4a925177bf..e31b4df344c1dbcab4a1b5542c98ec9af903f361 100644 (file)
@@ -54,16 +54,17 @@ check_struct_has_member("struct statfs" f_fstypename sys/mount.h
 
 include(CheckCXXCompilerFlag)
 
-if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
-    AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
-  # Old GCC versions don't have the required header support.
+# Old GCC versions don't have the required header support.
+# Old Apple Clang versions seem to support -mavx2 but not the target
+# attribute that's used to enable AVX2 for a certain function.
+if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
+   OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0))
   message(STATUS "Detected unsupported compiler for HAVE_AVX2 - disabled")
   set(HAVE_AVX2 FALSE)
 else()
   check_cxx_compiler_flag(-mavx2 HAVE_AVX2)
 endif()
 
-
 list(APPEND CMAKE_REQUIRED_LIBRARIES ws2_32)
 list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ws2_32)
 
index 755ff9f2d83583895b263570bb449bee0ecdbfd8..88d8dff0b3f53fdca26dbe4c48226108e7a92946 100644 (file)
@@ -6,7 +6,7 @@ add_library(standard_settings INTERFACE)
 # Not supported in CMake 3.4: target_compile_features(project_options INTERFACE
 # c_std_11 cxx_std_11)
 
-if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|Clang$")
+if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$")
   option(ENABLE_COVERAGE "Enable coverage reporting for GCC/Clang" FALSE)
   if(ENABLE_COVERAGE)
     target_compile_options(standard_settings INTERFACE --coverage -O0 -g)
index b45b781461a9debed2d15594991a4f40e3d1ba22..a75e56114243946e590d5b02bef37289a07d1d35 100644 (file)
@@ -17,7 +17,15 @@ include(CheckCCompilerFlag)
 
 function(add_source_if_enabled feature compile_flags)
   string(TOUPPER "have_${blake_source_type}_${feature}" have_feature)
-  if(${blake_source_type} STREQUAL "asm")
+
+  # AVX512 support fails to compile with old Apple Clang versions even though
+  # the compiler accepts the -m flags.
+  if(${feature} STREQUAL "avx512"
+      AND CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
+      AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+    message(STATUS "Detected unsupported compiler for ${have_feature} - disabled")
+    set(${have_feature} FALSE)
+  elseif(${blake_source_type} STREQUAL "asm")
     check_asm_compiler_flag(${compile_flags} ${have_feature})
   else()
     check_c_compiler_flag(${compile_flags} ${have_feature})