1*334522caSTobias Hieta
2*334522caSTobias Hietaoption(LLVM_ALLOW_PROBLEMATIC_CONFIGURATIONS OFF "Set this option to ON to allow problematic toolchain configurations. Use on your own risk.")
3*334522caSTobias Hieta
4*334522caSTobias Hietamacro(log_problematic MESSAGE)
5*334522caSTobias Hieta  if(LLVM_ALLOW_PROBLEMATIC_CONFIGURATIONS)
6*334522caSTobias Hieta    message(WARNING "${MESSAGE}")
7*334522caSTobias Hieta  else()
8*334522caSTobias Hieta    message(FATAL_ERROR "${MESSAGE}\nYou can force usage of this configuration by passing -DLLVM_ALLOW_PROBLEMATIC_CONFIGURATIONS=ON")
9*334522caSTobias Hieta  endif()
10*334522caSTobias Hietaendmacro()
11*334522caSTobias Hieta
12*334522caSTobias Hieta# MSVC and /arch:AVX is untested and have created problems before. See:
13*334522caSTobias Hieta# https://github.com/llvm/llvm-project/issues/54645
14*334522caSTobias Hietaif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
15*334522caSTobias Hieta  string(TOLOWER "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}" _FLAGS)
16*334522caSTobias Hieta  if(_FLAGS MATCHES "/arch:avx[0-9]*")
17*334522caSTobias Hieta    log_problematic("Compiling LLVM with MSVC and the /arch:AVX flag is known to cause issues with parts of LLVM.\nSee https://github.com/llvm/llvm-project/issues/54645 for details.\nUse clang-cl if you want to enable AVX instructions.")
18*334522caSTobias Hieta  endif()
19*334522caSTobias Hietaendif()
20