Skip to content

Commit ce52769

Browse files
committed
Merging r351387, r351765, and r353374:
------------------------------------------------------------------------ r351387 | jfb | 2019-01-16 23:22:38 +0100 (Wed, 16 Jan 2019) | 7 lines [NFC] Factor out + document build requirements Summary: This change factors out compiler checking / warning, and documents LLVM_FORCE_USE_OLD_TOOLCHAIN. It doesn't introduce any functional changes nor policy changes, these will come late. Subscribers: mgorny, jkorous, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D56799 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r351765 | jfb | 2019-01-22 00:53:52 +0100 (Tue, 22 Jan 2019) | 24 lines Document toolchain update policy Summary: Capture the current agreed-upon toolchain update policy based on the following discussions: - LLVM dev meeting 2018 BoF "Migrating to C++14, and beyond!" llvm.org/devmtg/2018-10/talk-abstracts.html#bof3 - A Short Policy Proposal Regarding Host Compilers lists.llvm.org/pipermail/llvm-dev/2018-May/123238.html - Using C++14 code in LLVM (2018) lists.llvm.org/pipermail/llvm-dev/2018-May/123182.html - Using C++14 code in LLVM (2017) lists.llvm.org/pipermail/llvm-dev/2017-October/118673.html - Using C++14 code in LLVM (2016) lists.llvm.org/pipermail/llvm-dev/2016-October/105483.html - Document and Enforce new Host Compiler Policy llvm.org/D47073 - Require GCC 5.1 and LLVM 3.5 at a minimum llvm.org/D46723 Subscribers: jkorous, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D56819 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r353374 | jfb | 2019-02-07 06:20:00 +0100 (Thu, 07 Feb 2019) | 12 lines 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 ------------------------------------------------------------------------ llvm-svn: 353512
1 parent 2699311 commit ce52769

File tree

5 files changed

+177
-69
lines changed

5 files changed

+177
-69
lines changed

llvm/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)
Lines changed: 85 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,94 @@
1-
# Check if the host compiler is new enough. LLVM requires at least GCC 4.8,
2-
# MSVC 2015 (Update 3), or Clang 3.1.
1+
# Check if the host compiler is new enough.
2+
# These versions are updated based on the following policy:
3+
# llvm.org/docs/DeveloperPolicy.html#toolchain
34

45
include(CheckCXXSourceCompiles)
56

6-
if(NOT DEFINED LLVM_COMPILER_CHECKED)
7-
set(LLVM_COMPILER_CHECKED ON)
7+
set(GCC_MIN 4.8)
8+
set(GCC_SOFT_ERROR 5.1)
9+
set(CLANG_MIN 3.1)
10+
set(CLANG_SOFT_ERROR 3.5)
11+
set(APPLECLANG_MIN 3.1)
12+
set(APPLECLANG_SOFT_ERROR 6.0)
13+
set(MSVC_MIN 19.00.24213.1)
14+
set(MSVC_SOFT_ERROR 19.1)
815

9-
if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
10-
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
11-
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
12-
message(FATAL_ERROR "Host GCC version must be at least 4.8!")
13-
endif()
14-
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
15-
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
16-
message(FATAL_ERROR "Host Clang version must be at least 3.1!")
17-
endif()
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)
1819

19-
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
20-
if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 19.0)
21-
message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=19.0")
22-
endif()
23-
set(CLANG_CL 1)
24-
elseif(NOT LLVM_ENABLE_LIBCXX)
25-
# Otherwise, test that we aren't using too old of a version of libstdc++
26-
# with the Clang compiler. This is tricky as there is no real way to
27-
# check the version of libstdc++ directly. Instead we test for a known
28-
# bug in libstdc++4.6 that is fixed in libstdc++4.7.
29-
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
30-
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
31-
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
32-
check_cxx_source_compiles("
33-
#include <atomic>
34-
std::atomic<float> x(0.0f);
35-
int main() { return (float)x; }"
36-
LLVM_NO_OLD_LIBSTDCXX)
37-
if(NOT LLVM_NO_OLD_LIBSTDCXX)
38-
message(FATAL_ERROR "Host Clang must be able to find libstdc++4.8 or newer!")
39-
endif()
40-
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
41-
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
42-
endif()
43-
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
44-
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0)
45-
message(FATAL_ERROR "Host Visual Studio must be at least 2015")
46-
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.00.24213.1)
47-
message(WARNING "Host Visual Studio should at least be 2015 Update 3 (MSVC 19.00.24213.1)"
48-
" due to miscompiles from earlier versions")
20+
21+
if(DEFINED LLVM_COMPILER_CHECKED)
22+
return()
23+
endif()
24+
set(LLVM_COMPILER_CHECKED ON)
25+
26+
if(LLVM_FORCE_USE_OLD_TOOLCHAIN)
27+
return()
28+
endif()
29+
30+
function(check_compiler_version NAME NICE_NAME MINIMUM_VERSION SOFT_ERROR_VERSION)
31+
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL NAME)
32+
return()
33+
endif()
34+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MINIMUM_VERSION)
35+
message(FATAL_ERROR "Host ${NICE_NAME} version must be at least ${MINIMUM_VERSION}, 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()
42+
endif()
43+
endfunction(check_compiler_version)
44+
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})
49+
50+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
51+
if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
52+
if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS MSVC_MIN)
53+
message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=${MSVC_MIN}, your version is ${CMAKE_CXX_COMPILER_VERSION}.")
54+
endif()
55+
set(CLANG_CL 1)
56+
elseif(NOT LLVM_ENABLE_LIBCXX)
57+
# Test that we aren't using too old of a version of libstdc++.
58+
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
59+
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
60+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
61+
check_cxx_source_compiles("
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.")
4989
endif()
5090
endif()
91+
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
92+
set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
5193
endif()
5294
endif()

llvm/docs/CMake.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,15 @@ LLVM-specific variables
573573
options, which are passed to the CCACHE_MAXSIZE and CCACHE_DIR environment
574574
variables, respectively.
575575

576+
**LLVM_FORCE_USE_OLD_TOOLCHAIN**:BOOL
577+
If enabled, the compiler and standard library versions won't be checked. LLVM
578+
may not compile at all, or might fail at runtime due to known bugs in these
579+
toolchains.
580+
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+
576585
CMake Caches
577586
============
578587

llvm/docs/DeveloperPolicy.rst

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This policy is also designed to accomplish the following objectives:
2222

2323
#. Make life as simple and easy for contributors as possible.
2424

25-
#. Keep the tip of tree as stable as possible.
25+
#. Keep the top of tree as stable as possible.
2626

2727
#. Establish awareness of the project's :ref:`copyright, license, and patent
2828
policies <copyright-license-patents>` with contributors to the project.
@@ -638,6 +638,47 @@ In essences, these rules are necessary for targets to gain and retain their
638638
status, but also markers to define bit-rot, and will be used to clean up the
639639
tree from unmaintained targets.
640640

641+
.. _toolchain:
642+
643+
Updating Toolchain Requirements
644+
-------------------------------
645+
646+
We intend to require newer toolchains as time goes by. This means LLVM's
647+
codebase can use newer versions of C++ as they get standardized. Requiring newer
648+
toolchains to build LLVM can be painful for those building LLVM; therefore, it
649+
will only be done through the following process:
650+
651+
* Generally, try to support LLVM and GCC versions from the last 3 years at a
652+
minimum. This time-based guideline is not strict: we may support much older
653+
compilers, or decide to support fewer versions.
654+
655+
* An RFC is sent to the `llvm-dev mailing list <http://lists.llvm.org/mailman/listinfo/llvm-dev>`_
656+
657+
- Detail upsides of the version increase (e.g. which newer C++ language or
658+
library features LLVM should use; avoid miscompiles in particular compiler
659+
versions, etc).
660+
- Detail downsides on important platforms (e.g. Ubuntu LTS status).
661+
662+
* Once the RFC reaches consensus, update the CMake toolchain version checks as
663+
well as the :doc:`getting started<GettingStarted>` guide. We want to
664+
soft-error when developers compile LLVM. We say "soft-error" because the
665+
error can be turned into a warning using a CMake flag. This is an important
666+
step: LLVM still doesn't have code which requires the new toolchains, but it
667+
soon will. If you compile LLVM but don't read the mailing list, we should
668+
tell you!
669+
670+
* Ensure that at least one LLVM release has had this soft-error. Not all
671+
developers compile LLVM top-of-tree. These release-bound developers should
672+
also be told about upcoming changes.
673+
674+
* Turn the soft-error into a hard-error after said LLVM release has branched.
675+
676+
* Update the :doc:`coding standards<CodingStandards>` to allow the new
677+
features we've explicitly approved in the RFC.
678+
679+
* Start using the new features in LLVM's codebase.
680+
681+
641682
.. _copyright-license-patents:
642683

643684
Copyright, License, and Patents

llvm/docs/GettingStarted.rst

Lines changed: 37 additions & 24 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
=========================================================== ============ ==========================================
@@ -220,15 +220,25 @@ Host C++ Toolchain, both Compiler and Standard Library
220220
------------------------------------------------------
221221

222222
LLVM is very demanding of the host C++ compiler, and as such tends to expose
223-
bugs in the compiler. We are also planning to follow improvements and
224-
developments in the C++ language and library reasonably closely. As such, we
225-
require a modern host C++ toolchain, both compiler and standard library, in
226-
order to build LLVM.
223+
bugs in the compiler. We also attempt to follow improvements and developments in
224+
the C++ language and library reasonably closely. As such, we require a modern
225+
host C++ toolchain, both compiler and standard library, in order to build LLVM.
227226

228-
For the most popular host toolchains we check for specific minimum versions in
229-
our build systems:
227+
LLVM is written using the subset of C++ documented in :doc:`coding
228+
standards<CodingStandards>`. To enforce this language version, we check the most
229+
popular host toolchains for specific minimum versions in our build systems:
230+
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:
230239

231240
* Clang 3.1
241+
* Apple Clang 3.1
232242
* GCC 4.8
233243
* Visual Studio 2015 (Update 3)
234244

@@ -282,41 +292,44 @@ The first step is to get a recent GCC toolchain installed. The most common
282292
distribution on which users have struggled with the version requirements is
283293
Ubuntu Precise, 12.04 LTS. For this distribution, one easy option is to install
284294
the `toolchain testing PPA`_ and use it to install a modern GCC. There is
285-
a really nice discussions of this on the `ask ubuntu stack exchange`_. However,
286-
not all users can use PPAs and there are many other distributions, so it may be
287-
necessary (or just useful, if you're here you *are* doing compiler development
288-
after all) to build and install GCC from source. It is also quite easy to do
289-
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.
290300

291301
.. _toolchain testing PPA:
292302
https://launchpad.net/~ubuntu-toolchain-r/+archive/test
293303
.. _ask ubuntu stack exchange:
294-
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
295307

296-
Easy steps for installing GCC 4.8.2:
308+
Easy steps for installing GCC 5.1.0:
297309

298310
.. code-block:: console
299311
300-
% wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2
301-
% 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
302315
% wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
303-
% 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`
304317
% if [ $signature_invalid ]; then echo "Invalid signature" ; exit 1 ; fi
305-
% tar -xvjf gcc-4.8.2.tar.bz2
306-
% cd gcc-4.8.2
318+
% tar -xvjf gcc-${gcc_version}.tar.bz2
319+
% cd gcc-${gcc_version}
307320
% ./contrib/download_prerequisites
308321
% cd ..
309-
% mkdir gcc-4.8.2-build
310-
% cd gcc-4.8.2-build
311-
% $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++
312325
% make -j$(nproc)
313326
% make install
314327
315328
For more details, check out the excellent `GCC wiki entry`_, where I got most
316329
of this information from.
317330

318331
.. _GCC wiki entry:
319-
http://gcc.gnu.org/wiki/InstallingGCC
332+
https://gcc.gnu.org/wiki/InstallingGCC
320333

321334
Once you have a GCC toolchain, configure your build of LLVM to use the new
322335
toolchain for your host compiler and C++ standard library. Because the new
@@ -336,7 +349,7 @@ If you fail to set rpath, most LLVM binaries will fail on startup with a message
336349
from the loader similar to ``libstdc++.so.6: version `GLIBCXX_3.4.20' not
337350
found``. This means you need to tweak the -rpath linker flag.
338351

339-
When you build Clang, you will need to give *it* access to modern C++11
352+
When you build Clang, you will need to give *it* access to modern C++
340353
standard library in order to use it as your new host in part of a bootstrap.
341354
There are two easy ways to do this, either build (and install) libc++ along
342355
with Clang and then use it with the ``-stdlib=libc++`` compile and link flag,

0 commit comments

Comments
 (0)