Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit d9a8f32

Browse files
committed
Bump minimum toolchain version
Summary: The RFC on moving past C++11 got good traction: http://lists.llvm.org/pipermail/llvm-dev/2019-January/129452.html This patch therefore bumps the toolchain versions according to our policy: llvm.org/docs/DeveloperPolicy.html#toolchain Subscribers: mgorny, jkorous, dexonsmith, llvm-commits, mehdi_amini, jyknight, rsmith, chandlerc, smeenai, hans, reames, lattner, lhames, erichkeane Differential Revision: https://reviews.llvm.org/D57264 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352951 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 05e6824 commit d9a8f32

File tree

4 files changed

+87
-40
lines changed

4 files changed

+87
-40
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,12 @@ option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF)
383383
set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
384384
"Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.")
385385

386-
option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
386+
option(LLVM_FORCE_USE_OLD_TOOLCHAIN
387387
"Set to ON to force using an old, unsupported host toolchain." OFF)
388388

389+
option(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN
390+
"Set to ON to only warn when using a toolchain which is about to be deprecated, instead of emitting an error." OFF)
391+
389392
option(LLVM_USE_INTEL_JITEVENTS
390393
"Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code"
391394
OFF)

cmake/modules/CheckCompilerVersion.cmake

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
include(CheckCXXSourceCompiles)
66

77
set(GCC_MIN 4.8)
8-
set(GCC_WARN 4.8)
8+
set(GCC_SOFT_ERROR 5.1)
99
set(CLANG_MIN 3.1)
10-
set(CLANG_WARN 3.1)
10+
set(CLANG_SOFT_ERROR 3.5)
1111
set(APPLECLANG_MIN 3.1)
12-
set(APPLECLANG_WARN 3.1)
13-
set(MSVC_MIN 19.0)
14-
set(MSVC_WARN 19.00.24213.1)
12+
set(APPLECLANG_SOFT_ERROR 6.0)
13+
set(MSVC_MIN 19.00.24213.1)
14+
set(MSVC_SOFT_ERROR 19.1)
15+
16+
# Map the above GCC versions to dates: https://gcc.gnu.org/develop.html#timeline
17+
set(GCC_MIN_DATE 20130322)
18+
set(GCC_SOFT_ERROR_DATE 20150422)
19+
1520

1621
if(DEFINED LLVM_COMPILER_CHECKED)
1722
return()
@@ -22,21 +27,25 @@ if(LLVM_FORCE_USE_OLD_TOOLCHAIN)
2227
return()
2328
endif()
2429

25-
function(check_compiler_version NAME NICE_NAME MINIMUM_VERSION WARN_VERSION)
30+
function(check_compiler_version NAME NICE_NAME MINIMUM_VERSION SOFT_ERROR_VERSION)
2631
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL NAME)
2732
return()
2833
endif()
2934
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MINIMUM_VERSION)
3035
message(FATAL_ERROR "Host ${NICE_NAME} version must be at least ${MINIMUM_VERSION}, your version is ${CMAKE_CXX_COMPILER_VERSION}.")
31-
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS WARN_VERSION)
32-
message(WARNING "Host ${NICE_NAME} version must be at least ${WARN_VERSION} due to miscompiles from earlier versions, your version is ${CMAKE_CXX_COMPILER_VERSION}.")
36+
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS SOFT_ERROR_VERSION)
37+
if(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN)
38+
message(WARNING "Host ${NICE_NAME} version should be at least ${SOFT_ERROR_VERSION} because LLVM will soon use new C++ features which your toolchain version doesn't support. Your version is ${CMAKE_CXX_COMPILER_VERSION}. Ignoring because you've set LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN, but very soon your toolchain won't be supported.")
39+
else()
40+
message(FATAL_ERROR "Host ${NICE_NAME} version should be at least ${SOFT_ERROR_VERSION} because LLVM will soon use new C++ features which your toolchain version doesn't support. Your version is ${CMAKE_CXX_COMPILER_VERSION}. You can temporarily opt out using LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN, but very soon your toolchain won't be supported.")
41+
endif()
3342
endif()
3443
endfunction(check_compiler_version)
3544

36-
check_compiler_version("GNU" "GCC" ${GCC_MIN} ${GCC_WARN})
37-
check_compiler_version("Clang" "Clang" ${CLANG_MIN} ${CLANG_WARN})
38-
check_compiler_version("AppleClang" "Apple Clang" ${APPLECLANG_MIN} ${APPLECLANG_WARN})
39-
check_compiler_version("MSVC" "Visual Studio" ${MSVC_MIN} ${MSVC_WARN})
45+
check_compiler_version("GNU" "GCC" ${GCC_MIN} ${GCC_SOFT_ERROR})
46+
check_compiler_version("Clang" "Clang" ${CLANG_MIN} ${CLANG_SOFT_ERROR})
47+
check_compiler_version("AppleClang" "Apple Clang" ${APPLECLANG_MIN} ${APPLECLANG_SOFT_ERROR})
48+
check_compiler_version("MSVC" "Visual Studio" ${MSVC_MIN} ${MSVC_SOFT_ERROR})
4049

4150
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
4251
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
@@ -45,20 +54,39 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
4554
endif()
4655
set(CLANG_CL 1)
4756
elseif(NOT LLVM_ENABLE_LIBCXX)
48-
# Test that we aren't using too old of a version of libstdc++
49-
# with the Clang compiler. This is tricky as there is no real way to
50-
# check the version of libstdc++ directly. Instead we test for a known
51-
# bug in libstdc++4.6 that is fixed in libstdc++4.7.
57+
# Test that we aren't using too old of a version of libstdc++.
5258
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
5359
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
5460
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
5561
check_cxx_source_compiles("
56-
#include <atomic>
57-
std::atomic<float> x(0.0f);
58-
int main() { return (float)x; }"
59-
LLVM_NO_OLD_LIBSTDCXX)
60-
if(NOT LLVM_NO_OLD_LIBSTDCXX)
61-
message(FATAL_ERROR "Host Clang must be able to find libstdc++4.8 or newer!")
62+
#include <iosfwd>
63+
#if defined(__GLIBCXX__)
64+
#if __GLIBCXX__ < ${GCC_MIN_DATE}
65+
#error Unsupported libstdc++ version
66+
#endif
67+
#endif
68+
int main() { return 0; }
69+
"
70+
LLVM_LIBSTDCXX_MIN)
71+
if(NOT LLVM_LIBSTDCXX_MIN)
72+
message(FATAL_ERROR "libstdc++ version must be at least ${GCC_MIN}.")
73+
endif()
74+
check_cxx_source_compiles("
75+
#include <iosfwd>
76+
#if defined(__GLIBCXX__)
77+
#if __GLIBCXX__ < ${GCC_SOFT_ERROR_DATE}
78+
#error Unsupported libstdc++ version
79+
#endif
80+
#endif
81+
int main() { return 0; }
82+
"
83+
LLVM_LIBSTDCXX_SOFT_ERROR)
84+
if(NOT LLVM_LIBSTDCXX_SOFT_ERROR)
85+
if(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN)
86+
message(WARNING "libstdc++ version should be at least ${GCC_SOFT_ERROR} because LLVM will soon use new C++ features which your toolchain version doesn't support. Ignoring because you've set LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN, but very soon your toolchain won't be supported.")
87+
else()
88+
message(FATAL_ERROR "libstdc++ version should be at least ${GCC_SOFT_ERROR} because LLVM will soon use new C++ features which your toolchain version doesn't support. You can temporarily opt out using LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN, but very soon your toolchain won't be supported.")
89+
endif()
6290
endif()
6391
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
6492
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})

docs/CMake.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ LLVM-specific variables
578578
may not compile at all, or might fail at runtime due to known bugs in these
579579
toolchains.
580580

581+
**LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN**:BOOL
582+
If enabled, the compiler version check will only warn when using a toolchain
583+
which is about to be deprecated, instead of emitting an error.
584+
581585
CMake Caches
582586
============
583587

docs/GettingStarted.rst

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ uses the package and provides other details.
170170
Package Version Notes
171171
=========================================================== ============ ==========================================
172172
`GNU Make <http://savannah.gnu.org/projects/make>`_ 3.79, 3.79.1 Makefile/build processor
173-
`GCC <http://gcc.gnu.org/>`_ >=4.8.0 C/C++ compiler\ :sup:`1`
173+
`GCC <http://gcc.gnu.org/>`_ >=5.1.0 C/C++ compiler\ :sup:`1`
174174
`python <http://www.python.org/>`_ >=2.7 Automated test suite\ :sup:`2`
175175
`zlib <http://zlib.net>`_ >=1.2.3.4 Compression library\ :sup:`3`
176176
=========================================================== ============ ==========================================
@@ -228,6 +228,15 @@ LLVM is written using the subset of C++ documented in :doc:`coding
228228
standards<CodingStandards>`. To enforce this language version, we check the most
229229
popular host toolchains for specific minimum versions in our build systems:
230230

231+
* Clang 3.5
232+
* Apple Clang 6.0
233+
* GCC 5.1
234+
* Visual Studio 2017
235+
236+
The below versions currently soft-error as we transition to the new compiler
237+
versions listed above. The LLVM codebase is currently known to compile correctly
238+
with the following compilers, though this will change in the near future:
239+
231240
* Clang 3.1
232241
* Apple Clang 3.1
233242
* GCC 4.8
@@ -283,41 +292,44 @@ The first step is to get a recent GCC toolchain installed. The most common
283292
distribution on which users have struggled with the version requirements is
284293
Ubuntu Precise, 12.04 LTS. For this distribution, one easy option is to install
285294
the `toolchain testing PPA`_ and use it to install a modern GCC. There is
286-
a really nice discussions of this on the `ask ubuntu stack exchange`_. However,
287-
not all users can use PPAs and there are many other distributions, so it may be
288-
necessary (or just useful, if you're here you *are* doing compiler development
289-
after all) to build and install GCC from source. It is also quite easy to do
290-
these days.
295+
a really nice discussions of this on the `ask ubuntu stack exchange`_ and a
296+
`github gist`_ with updated commands. However, not all users can use PPAs and
297+
there are many other distributions, so it may be necessary (or just useful, if
298+
you're here you *are* doing compiler development after all) to build and install
299+
GCC from source. It is also quite easy to do these days.
291300

292301
.. _toolchain testing PPA:
293302
https://launchpad.net/~ubuntu-toolchain-r/+archive/test
294303
.. _ask ubuntu stack exchange:
295-
http://askubuntu.com/questions/271388/how-to-install-gcc-4-8-in-ubuntu-12-04-from-the-terminal
304+
https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu/581497#58149
305+
.. _github gist:
306+
https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
296307

297-
Easy steps for installing GCC 4.8.2:
308+
Easy steps for installing GCC 5.1.0:
298309

299310
.. code-block:: console
300311
301-
% wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2
302-
% wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2.sig
312+
% gcc_version=5.1.0
313+
% wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2
314+
% wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2.sig
303315
% wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
304-
% signature_invalid=`gpg --verify --no-default-keyring --keyring ./gnu-keyring.gpg gcc-4.8.2.tar.bz2.sig`
316+
% signature_invalid=`gpg --verify --no-default-keyring --keyring ./gnu-keyring.gpg gcc-${gcc_version}.tar.bz2.sig`
305317
% if [ $signature_invalid ]; then echo "Invalid signature" ; exit 1 ; fi
306-
% tar -xvjf gcc-4.8.2.tar.bz2
307-
% cd gcc-4.8.2
318+
% tar -xvjf gcc-${gcc_version}.tar.bz2
319+
% cd gcc-${gcc_version}
308320
% ./contrib/download_prerequisites
309321
% cd ..
310-
% mkdir gcc-4.8.2-build
311-
% cd gcc-4.8.2-build
312-
% $PWD/../gcc-4.8.2/configure --prefix=$HOME/toolchains --enable-languages=c,c++
322+
% mkdir gcc-${gcc_version}-build
323+
% cd gcc-${gcc_version}-build
324+
% $PWD/../gcc-${gcc_version}/configure --prefix=$HOME/toolchains --enable-languages=c,c++
313325
% make -j$(nproc)
314326
% make install
315327
316328
For more details, check out the excellent `GCC wiki entry`_, where I got most
317329
of this information from.
318330

319331
.. _GCC wiki entry:
320-
http://gcc.gnu.org/wiki/InstallingGCC
332+
https://gcc.gnu.org/wiki/InstallingGCC
321333

322334
Once you have a GCC toolchain, configure your build of LLVM to use the new
323335
toolchain for your host compiler and C++ standard library. Because the new

0 commit comments

Comments
 (0)