Index: llvm/CMakeLists.txt =================================================================== --- llvm/CMakeLists.txt +++ llvm/CMakeLists.txt @@ -23,6 +23,9 @@ if(NOT DEFINED LLVM_VERSION_SUFFIX) set(LLVM_VERSION_SUFFIX svn) endif() +if (NOT DEFINED LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK) + set(LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK OFF) +endif() if (NOT PACKAGE_VERSION) set(PACKAGE_VERSION Index: llvm/cmake/modules/CheckCompilerVersion.cmake =================================================================== --- llvm/cmake/modules/CheckCompilerVersion.cmake +++ llvm/cmake/modules/CheckCompilerVersion.cmake @@ -1,19 +1,37 @@ -# Check if the host compiler is new enough. LLVM requires at least GCC 4.8, -# MSVC 2015 (Update 3), or Clang 3.1. - +# Check if the host compiler is new enough. +# See docs/GettingStarted.rst for the policy to update the minimum requirements include(CheckCXXSourceCompiles) +# These should be identical, except for one release cycle where we "warn" +# about the coming change in requirement in the following release. +set(GCC_MIN 4.8) +set(GCC_WARN 4.8) +set(CLANG_MIN 3.1) +set(CLANG_WARN 3.1) + if(NOT DEFINED LLVM_COMPILER_CHECKED) set(LLVM_COMPILER_CHECKED ON) if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - message(FATAL_ERROR "Host GCC version must be at least 4.8!") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_MIN) + message(FATAL_ERROR "GCC ${CMAKE_CXX_COMPILER_VERSION} is unsupported " + "(minimum version is GCC ${GCC_MIN}). + elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_WARN + AND NOT LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK) + message(FATAL_ERROR "GCC ${CMAKE_CXX_COMPILER_VERSION} will be unsupported" + " in the next release, the future requirement will be GCC ${GCC_WARN}." + " This warning can be ignored with the cmake option LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK.") endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) - message(FATAL_ERROR "Host Clang version must be at least 3.1!") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_MIN) + message(WARNING "Clang ${CMAKE_CXX_COMPILER_VERSION} is unsupported " + "(minimum version is Clang ${CLANG_MIN}).") + elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_WARN + AND NOT LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK) + message(FATAL_ERROR "Clang ${CMAKE_CXX_COMPILER_VERSION} will be unsupported" + " in the next release, the future requirement will be GCC ${GCC_WARN}." + " This warning can be ignored with the cmake option LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK.")" endif() if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC") Index: llvm/docs/CMake.rst =================================================================== --- llvm/docs/CMake.rst +++ llvm/docs/CMake.rst @@ -573,6 +573,11 @@ options, which are passed to the CCACHE_MAXSIZE and CCACHE_DIR environment variables, respectively. +**LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK**:BOOL + If enabled, the CMake checks for Clang and GCC minimum host compiler versions + will be ignored. This flag will likely be removed for LLVM 9.0 due to a bump + in the required C++ version. This defaults to OFF. + CMake Caches ============ Index: llvm/docs/GettingStarted.rst =================================================================== --- llvm/docs/GettingStarted.rst +++ llvm/docs/GettingStarted.rst @@ -220,10 +220,9 @@ ------------------------------------------------------ LLVM is very demanding of the host C++ compiler, and as such tends to expose -bugs in the compiler. We are also planning to follow improvements and -developments in the C++ language and library reasonably closely. As such, we -require a modern host C++ toolchain, both compiler and standard library, in -order to build LLVM. +bugs in the compiler. We also attempt to follow improvements and developments in +the C++ language and library reasonably closely. As such, we require a modern +host C++ toolchain, both compiler and standard library, in order to build LLVM. For the most popular host toolchains we check for specific minimum versions in our build systems: @@ -232,10 +231,14 @@ * GCC 4.8 * Visual Studio 2015 (Update 3) -Anything older than these toolchains *may* work, but will require forcing the -build system with a special option and is not really a supported host platform. -Also note that older versions of these compilers have often crashed or -miscompiled LLVM. +For GCC and Clang, LLVM's guideline is to support all major compiler versions +released at least 3 years from the date in which the previous version was +branched. Before dropping support for an older version of a compiler, we will +consider the benefits in terms of features available for development with the +availability of more recent versions on the most widely used platforms (for +example considering Ubuntu LTS, etc.). When we decide to bump the minimum +version of any compiler, we will issue a cmake warning for one release cycle +before enforcing the new minimum. For less widely used host toolchains such as ICC or xlC, be aware that a very recent version may be required to support all of the C++ features used in LLVM.