diff options
author | Young Jin Kim <youki@microsoft.com> | 2021-03-22 06:28:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 06:28:41 +0300 |
commit | 5af561fb3637bf2b31ab568d5d8b0b32b86546f3 (patch) | |
tree | bc6bd16faafb4550ccacfafded5ac9d91b0dedae | |
parent | 64888200cbc9e9c287601f23c58b4088cdf51cba (diff) |
gcc 9.3+ build fix (#10)
* Turn -march=native off when using gcc 9.3+ (-march=x86-64)
-rw-r--r-- | CMakeLists.txt | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e5dfa6..e665ab4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ else() if(NOT COMPILER_SUPPORTS_AVX512) message(FATAL_ERROR "A compiler with AVX512 support is required.") endif() + # string(REPLACE "-march=native" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endif() #We should default to a Release build @@ -123,8 +124,16 @@ set_target_properties(fbgemm_generic fbgemm_avx2 fbgemm_avx512 PROPERTIES CXX_VISIBILITY_PRESET hidden) if (NOT MSVC) - target_compile_options(fbgemm_avx2 PRIVATE - "-m64" "-mavx2" "-mfma" "-masm=intel" "-mf16c") + # '-march=native' makes avx2 assembly generation fail on AVX512 CPUs with gcc 9.3+ + if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.2) + message(WARNING "When built with gcc 9.3+, '-march=native' should be disabled.") + target_compile_options(fbgemm_avx2 PRIVATE + "-m64" "-mavx2" "-mfma" "-masm=intel" "-mf16c" "-march=x86-64") + else() + target_compile_options(fbgemm_avx2 PRIVATE + "-m64" "-mavx2" "-mfma" "-masm=intel" "-mf16c") + endif() + target_compile_options(fbgemm_avx512 PRIVATE "-m64" "-mavx2" "-mfma" "-mavx512f" "-mavx512bw" "-mavx512dq" "-mavx512vl" "-masm=intel" "-mf16c") |