diff --git a/.github/workflows/dynamic_arch.yml b/.github/workflows/dynamic_arch.yml index 4fe6e63fc..85b20c060 100644 --- a/.github/workflows/dynamic_arch.yml +++ b/.github/workflows/dynamic_arch.yml @@ -167,9 +167,6 @@ jobs: idx: int32 target-prefix: mingw-w64-clang-x86_64 fc-pkg: fc - # Compiling with Flang 16 seems to cause test errors on machines - # with AVX512 instructions. Revisit after MSYS2 distributes Flang 17. - no-avx512-flags: -DNO_AVX512=1 - msystem: CLANG32 idx: int32 target-prefix: mingw-w64-clang-i686 @@ -185,9 +182,6 @@ jobs: idx64-flags: -DBINARY=64 -DINTERFACE64=1 target-prefix: mingw-w64-clang-x86_64 fc-pkg: fc - # Compiling with Flang 16 seems to cause test errors on machines - # with AVX512 instructions. Revisit after MSYS2 distributes Flang 17. - no-avx512-flags: -DNO_AVX512=1 - msystem: MINGW64 idx: int32 target-prefix: mingw-w64-x86_64 @@ -274,7 +268,6 @@ jobs: -DTARGET=CORE2 \ ${{ matrix.idx64-flags }} \ ${{ matrix.c-lapack-flags }} \ - ${{ matrix.no-avx512-flags }} \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_Fortran_COMPILER_LAUNCHER=ccache \ .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 35077f3c2..57767c598 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,38 @@ endif() message(WARNING "CMake support is experimental. It does not yet support all build options and may not produce the same Makefiles that OpenBLAS ships with.") +if(NOT NOFORTRAN) + # Check for working Fortran compiler + include(CheckLanguage) + check_language(Fortran) + if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) + else() + set(NOFORTRAN 1) + endif() +endif() + +if (NOT NOFORTRAN AND CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang") + if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 17 OR WIN32) + # The *blas3 tests fail on hardware with AVX512 instruction when using + # LLVM Flang before version 17 or when using LLVM Flang on Windows. + # Tested with LLVM Flang 16 and LLVM Flang 17 on Windows (MSYS2/CLANG64). + # FIXME: Revisit with LLVM Flang 18. + if (NOT NO_AVX512) + message(STATUS "Disabling AVX512 instructions for LLVM Flang before version 17 or on Windows.") + endif() + set(NO_AVX512 1) + endif() + + if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 17) + # LLVM Flang before version 17 doesn't support necessary OpenMP constructs. + if (USE_OPENMP) + message(STATUS "Disabling OpenMP for LLVM Flang before version 17.") + set(USE_OPENMP 0) + endif() + endif() +endif() + include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake") include("${PROJECT_SOURCE_DIR}/cmake/system.cmake") diff --git a/cmake/f_check.cmake b/cmake/f_check.cmake index df3a4858d..df9716cb7 100644 --- a/cmake/f_check.cmake +++ b/cmake/f_check.cmake @@ -20,12 +20,7 @@ # NEEDBUNDERSCORE # NEED2UNDERSCORES -include(CheckLanguage) -check_language(Fortran) -if(CMAKE_Fortran_COMPILER) - enable_language(Fortran) -else() - set (NOFORTRAN 1) +if(NOT CMAKE_Fortran_COMPILER) if (NOT NO_LAPACK) if (NOT XXXXX) message(STATUS "No Fortran compiler found, can build only BLAS and f2c-converted LAPACK")