HAVE_STRUCT_STATFS_F_FSTYPENAME)
include(CheckCXXCompilerFlag)
-check_cxx_compiler_flag(-mavx2 HAVE_AVX2)
+
+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.
+ 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)
#include "execute.hpp"
#include "macroskip.hpp"
+#include "third_party/blake3/blake3_cpu_supports_avx2.h"
+
#ifdef INODE_CACHE_SUPPORTED
# include "InodeCache.hpp"
#endif
# include "Win32Util.hpp"
#endif
-// With older GCC (libgcc), __builtin_cpu_supports("avx2) returns true if AVX2
-// is supported by the CPU but disabled by the OS. This was fixed in GCC 8, 7.4
-// and 6.5 (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85100).
-//
-// For Clang it seems to be correct if compiler-rt is used as -rtlib, at least
-// as of 3.9 (see https://bugs.llvm.org/show_bug.cgi?id=25510). But if libgcc is
-// used we have the same problem as mentioned above. Unfortunately there doesn't
-// seem to be a way to detect which one is used, or the version of libgcc when
-// used by Clang, so assume that it works with Clang >= 3.9.
-#if !(__GNUC__ >= 8 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 4) \
- || (__GNUC__ == 6 && __GNUC_MINOR__ >= 5) || __clang_major__ > 3 \
- || (__clang_major__ == 3 && __clang_minor__ >= 9))
-# undef HAVE_AVX2
-#endif
-
#ifdef HAVE_AVX2
# include <immintrin.h>
#endif
check_for_temporal_macros(string_view str)
{
#ifdef HAVE_AVX2
- if (__builtin_cpu_supports("avx2")) {
+ if (blake3_cpu_supports_avx2()) {
return check_for_temporal_macros_avx2(str);
}
#endif
--- /dev/null
+#ifndef BLAKE3_CPU_SUPPORTS_AVX2_H
+#define BLAKE3_CPU_SUPPORTS_AVX2_H
+
+// This file is a ccache modification to BLAKE3
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool blake3_cpu_supports_avx2();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+// This file is a ccache modification to BLAKE3
+
+#include "blake3_dispatch.c"
+
+#include "blake3_cpu_supports_avx2.h"
+
+bool blake3_cpu_supports_avx2()
+{
+ return get_cpu_features() & AVX2;
+}