Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ 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: cmake/modules/CheckCompilerVersion.cmake =================================================================== --- cmake/modules/CheckCompilerVersion.cmake +++ cmake/modules/CheckCompilerVersion.cmake @@ -1,19 +1,72 @@ -# 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. For MSVC, LLVM requires at least +# MSVC 2015 (Update 3). For GCC and Clang, LLVM's rough guideline is to support +# all major compiler versions released about 3 years from the date in which the +# previous version was branched. This time-based guideline is not strict; we +# want to keep some discretion when supporting older compilers still makes +# sense, or when newer compilers inflict significant pain. Additionally, a CMake +# warning is issued for versions older than 1.5 years. + +# Before updating the minimum versions, LLVM's policy requires an LLVM-Dev +# mailing list discussion. This discussion should revolve around the value the +# update brings to the LLVM project as well as any harm it causes to LLVM's +# users, consumers, and developers. However, a lack of significant harm should +# not be construed as sufficient reason to alter these minimums. + +# For current LLVM trunk (version 8.0), the effective date is January 3rd, 2018. include(CheckCXXSourceCompiles) +set(GCC_MIN 5.2) +set(GCC_WARN 6.3) +set(CLANG_MIN 3.6) +set(CLANG_WARN 4.0) +set(APPLECLANG_MIN 7.3) +set(APPLECLANG_WARN 8.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 + AND NOT LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK) + message(FATAL_ERROR "GCC ${CMAKE_CXX_COMPILER_VERSION} is unsupported " + "(minimum version is GCC ${GCC_MIN}). Compiler version checking" + " can be ignored with the cmake option LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK.") + elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_MIN) + message(WARNING "GCC ${CMAKE_CXX_COMPILER_VERSION} is unsupported " + "(minimum version is GCC ${GCC_MIN}).") + elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_WARN) + message(WARNING "GCC ${CMAKE_CXX_COMPILER_VERSION} will soon be " + " unsupported (version < GCC ${GCC_WARN}).") + endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS APPLECLANG_MIN + AND NOT LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK) + message(FATAL_ERROR "Apple-Clang ${CMAKE_CXX_COMPILER_VERSION} is unsupported " + "(minimum version is Apple-Clang ${APPLECLANG_MIN}). Compiler version " + "checking can be ignored with the cmake option " + "LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK.") + elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS APPLECLANG_MIN) + message(WARNING "Apple-Clang ${CMAKE_CXX_COMPILER_VERSION} is unsupported " + "(minimum version is Apple-Clang ${APPLECLANG_MIN}).") + elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS APPLECLANG_WARN) + message(WARNING "Apple-Clang ${CMAKE_CXX_COMPILER_VERSION} will soon be " + "unsupported (version < Apple-Clang ${APPLECLANG_WARN}).") 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 + AND NOT LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK) + message(FATAL_ERROR "Clang ${CMAKE_CXX_COMPILER_VERSION} is unsupported " + "(minimum version is Clang ${CLANG_MIN}). Compiler version " + "checking can be ignored with the cmake option " + "LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK.") + elseif(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) + message(WARNING "Clang ${CMAKE_CXX_COMPILER_VERSION} will soon be " + "unsupported (version < Clang ${CLANG_WARN}).") endif() if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC") Index: docs/CMake.rst =================================================================== --- docs/CMake.rst +++ 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: docs/CodingStandards.rst =================================================================== --- docs/CodingStandards.rst +++ docs/CodingStandards.rst @@ -184,7 +184,7 @@ traits header to emulate it. .. _the libstdc++ manual: - https://gcc.gnu.org/onlinedocs/gcc-4.8.0/libstdc++/manual/manual/status.html#status.iso.2011 + https://gcc.gnu.org/onlinedocs/gcc-5.1.0/libstdc++/manual/manual/status.html#status.iso.2011 Other Languages --------------- Index: docs/GettingStarted.rst =================================================================== --- docs/GettingStarted.rst +++ docs/GettingStarted.rst @@ -222,7 +222,7 @@ Package Version Notes =========================================================== ============ ========================================== `GNU Make `_ 3.79, 3.79.1 Makefile/build processor -`GCC `_ >=4.8.0 C/C++ compiler\ :sup:`1` +`GCC `_ >=5.1.0 C/C++ compiler\ :sup:`1` `python `_ >=2.7 Automated test suite\ :sup:`2` `zlib `_ >=1.2.3.4 Compression library\ :sup:`3` =========================================================== ============ ========================================== @@ -272,22 +272,31 @@ ------------------------------------------------------ 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: -* Clang 3.1 -* GCC 4.8 +* Clang 3.6 +* Apple-Clang 7.3 +* GCC 5.2 * Visual Studio 2015 (Update 3) +For GCC and Clang, LLVM's rough guideline is to support all major compiler +versions released about 3 years from the date in which the previous version was +branched. This time-based guideline is not strict; we want to keep some +discretion when supporting older compilers still makes sense, or when newer +compilers inflict significant pain. Additionally, in order to assist developers +to properly prepare their environments, a CMake warning is issued for versions +older than 1.5 years. + 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. +miscompiled LLVM. The checks can be ignored with the cmake option +LLVM_IGNORE_HOST_COMPILER_VERSION_CHECK. 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. @@ -334,33 +343,35 @@ distribution on which users have struggled with the version requirements is Ubuntu Precise, 12.04 LTS. For this distribution, one easy option is to install the `toolchain testing PPA`_ and use it to install a modern GCC. There is -a really nice discussions of this on the `ask ubuntu stack exchange`_. However, -not all users can use PPAs and there are many other distributions, so it may be -necessary (or just useful, if you're here you *are* doing compiler development -after all) to build and install GCC from source. It is also quite easy to do -these days. +a really nice discussions of this on the `ask ubuntu stack exchange`_ and a +`github gist`_ with updated commands. However, not all users can use PPAs and +there are many other distributions, so it may be necessary (or just useful, if +you're here you *are* doing compiler development after all) to build and install +GCC from source. It is also quite easy to do these days. .. _toolchain testing PPA: https://launchpad.net/~ubuntu-toolchain-r/+archive/test .. _ask ubuntu stack exchange: - http://askubuntu.com/questions/271388/how-to-install-gcc-4-8-in-ubuntu-12-04-from-the-terminal + https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu/581497#58149 +.. _github gist: + https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91 -Easy steps for installing GCC 4.8.2: +Easy steps for installing GCC 5.1.0: .. code-block:: console - % wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2 - % wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2.sig + % wget https://ftp.gnu.org/gnu/gcc/gcc-5.1.0/gcc-5.1.0.tar.bz2 + % wget https://ftp.gnu.org/gnu/gcc/gcc-5.1.0/gcc-5.1.0.tar.bz2.sig % wget https://ftp.gnu.org/gnu/gnu-keyring.gpg - % signature_invalid=`gpg --verify --no-default-keyring --keyring ./gnu-keyring.gpg gcc-4.8.2.tar.bz2.sig` + % signature_invalid=`gpg --verify --no-default-keyring --keyring ./gnu-keyring.gpg gcc-5.1.0.tar.bz2.sig` % if [ $signature_invalid ]; then echo "Invalid signature" ; exit 1 ; fi - % tar -xvjf gcc-4.8.2.tar.bz2 - % cd gcc-4.8.2 + % tar -xvjf gcc-5.1.0.tar.bz2 + % cd gcc-5.1.0 % ./contrib/download_prerequisites % cd .. - % mkdir gcc-4.8.2-build - % cd gcc-4.8.2-build - % $PWD/../gcc-4.8.2/configure --prefix=$HOME/toolchains --enable-languages=c,c++ + % mkdir gcc-5.1.0-build + % cd gcc-5.1.0-build + % $PWD/../gcc-5.1.0/configure --prefix=$HOME/toolchains --enable-languages=c,c++ % make -j$(nproc) % make install @@ -368,7 +379,7 @@ of this information from. .. _GCC wiki entry: - http://gcc.gnu.org/wiki/InstallingGCC + https://gcc.gnu.org/wiki/InstallingGCC Once you have a GCC toolchain, configure your build of LLVM to use the new toolchain for your host compiler and C++ standard library. Because the new