diff options
author | Erik Flodin <erik@ejohansson.se> | 2020-10-22 19:51:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-22 19:51:36 +0200 |
commit | 0c967b01ea86666afd38b81b91b45b49df647ccd (patch) | |
tree | 3ece339e7bedbd0245937316a4e5df25d935d3a6 /cmake | |
parent | e660a38e8c052c8ce519ee0e159f78015e299346 (diff) | |
download | ccache-0c967b01ea86666afd38b81b91b45b49df647ccd.tar.gz |
Use BLAKE3 machinery for detecting AVX2 support (#696)
* Use BLAKE3 machinery for detecting AVX2 support
Instead of relying on the sometimes broken __builtin_cpu_support. See
discussion in #689.
* Require GCC >= 5.0 to enable AVX2 support
On e.g. GCC 4.8.5 the build fails with:
error: ā__m256iā does not name a type
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/GenerateConfigurationFile.cmake | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/cmake/GenerateConfigurationFile.cmake b/cmake/GenerateConfigurationFile.cmake index 582fedb0..0a33f763 100644 --- a/cmake/GenerateConfigurationFile.cmake +++ b/cmake/GenerateConfigurationFile.cmake @@ -53,7 +53,16 @@ check_struct_has_member("struct statfs" f_fstypename sys/mount.h 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) |