llvm.org GIT mirror llvm / ef6469f
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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_80@353512 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 9 months ago
5 changed file(s) with 182 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
382382 set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
383383 "Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.")
384384
385 option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
385 option(LLVM_FORCE_USE_OLD_TOOLCHAIN
386386 "Set to ON to force using an old, unsupported host toolchain." OFF)
387
388 option(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN
389 "Set to ON to only warn when using a toolchain which is about to be deprecated, instead of emitting an error." OFF)
387390
388391 option(LLVM_USE_INTEL_JITEVENTS
389392 "Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code"
None # Check if the host compiler is new enough. LLVM requires at least GCC 4.8,
1 # MSVC 2015 (Update 3), or Clang 3.1.
0 # Check if the host compiler is new enough.
1 # These versions are updated based on the following policy:
2 # llvm.org/docs/DeveloperPolicy.html#toolchain
23
34 include(CheckCXXSourceCompiles)
45
5 if(NOT DEFINED LLVM_COMPILER_CHECKED)
6 set(LLVM_COMPILER_CHECKED ON)
6 set(GCC_MIN 4.8)
7 set(GCC_SOFT_ERROR 5.1)
8 set(CLANG_MIN 3.1)
9 set(CLANG_SOFT_ERROR 3.5)
10 set(APPLECLANG_MIN 3.1)
11 set(APPLECLANG_SOFT_ERROR 6.0)
12 set(MSVC_MIN 19.00.24213.1)
13 set(MSVC_SOFT_ERROR 19.1)
714
8 if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
9 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
10 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
11 message(FATAL_ERROR "Host GCC version must be at least 4.8!")
12 endif()
13 elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
14 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
15 message(FATAL_ERROR "Host Clang version must be at least 3.1!")
16 endif()
15 # Map the above GCC versions to dates: https://gcc.gnu.org/develop.html#timeline
16 set(GCC_MIN_DATE 20130322)
17 set(GCC_SOFT_ERROR_DATE 20150422)
1718
18 if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
19 if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 19.0)
20 message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=19.0")
21 endif()
22 set(CLANG_CL 1)
23 elseif(NOT LLVM_ENABLE_LIBCXX)
24 # Otherwise, test that we aren't using too old of a version of libstdc++
25 # with the Clang compiler. This is tricky as there is no real way to
26 # check the version of libstdc++ directly. Instead we test for a known
27 # bug in libstdc++4.6 that is fixed in libstdc++4.7.
28 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
29 set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
30 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
31 check_cxx_source_compiles("
32 #include
33 std::atomic x(0.0f);
34 int main() { return (float)x; }"
35 LLVM_NO_OLD_LIBSTDCXX)
36 if(NOT LLVM_NO_OLD_LIBSTDCXX)
37 message(FATAL_ERROR "Host Clang must be able to find libstdc++4.8 or newer!")
38 endif()
39 set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
40 set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
41 endif()
42 elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
43 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0)
44 message(FATAL_ERROR "Host Visual Studio must be at least 2015")
45 elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.00.24213.1)
46 message(WARNING "Host Visual Studio should at least be 2015 Update 3 (MSVC 19.00.24213.1)"
47 " due to miscompiles from earlier versions")
19
20 if(DEFINED LLVM_COMPILER_CHECKED)
21 return()
22 endif()
23 set(LLVM_COMPILER_CHECKED ON)
24
25 if(LLVM_FORCE_USE_OLD_TOOLCHAIN)
26 return()
27 endif()
28
29 function(check_compiler_version NAME NICE_NAME MINIMUM_VERSION SOFT_ERROR_VERSION)
30 if(NOT CMAKE_CXX_COMPILER_ID STREQUAL NAME)
31 return()
32 endif()
33 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MINIMUM_VERSION)
34 message(FATAL_ERROR "Host ${NICE_NAME} version must be at least ${MINIMUM_VERSION}, your version is ${CMAKE_CXX_COMPILER_VERSION}.")
35 elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS SOFT_ERROR_VERSION)
36 if(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN)
37 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.")
38 else()
39 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.")
40 endif()
41 endif()
42 endfunction(check_compiler_version)
43
44 check_compiler_version("GNU" "GCC" ${GCC_MIN} ${GCC_SOFT_ERROR})
45 check_compiler_version("Clang" "Clang" ${CLANG_MIN} ${CLANG_SOFT_ERROR})
46 check_compiler_version("AppleClang" "Apple Clang" ${APPLECLANG_MIN} ${APPLECLANG_SOFT_ERROR})
47 check_compiler_version("MSVC" "Visual Studio" ${MSVC_MIN} ${MSVC_SOFT_ERROR})
48
49 if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
50 if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
51 if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS MSVC_MIN)
52 message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=${MSVC_MIN}, your version is ${CMAKE_CXX_COMPILER_VERSION}.")
53 endif()
54 set(CLANG_CL 1)
55 elseif(NOT LLVM_ENABLE_LIBCXX)
56 # Test that we aren't using too old of a version of libstdc++.
57 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
58 set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
59 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
60 check_cxx_source_compiles("
61 #include
62 #if defined(__GLIBCXX__)
63 #if __GLIBCXX__ < ${GCC_MIN_DATE}
64 #error Unsupported libstdc++ version
65 #endif
66 #endif
67 int main() { return 0; }
68 "
69 LLVM_LIBSTDCXX_MIN)
70 if(NOT LLVM_LIBSTDCXX_MIN)
71 message(FATAL_ERROR "libstdc++ version must be at least ${GCC_MIN}.")
72 endif()
73 check_cxx_source_compiles("
74 #include
75 #if defined(__GLIBCXX__)
76 #if __GLIBCXX__ < ${GCC_SOFT_ERROR_DATE}
77 #error Unsupported libstdc++ version
78 #endif
79 #endif
80 int main() { return 0; }
81 "
82 LLVM_LIBSTDCXX_SOFT_ERROR)
83 if(NOT LLVM_LIBSTDCXX_SOFT_ERROR)
84 if(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN)
85 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.")
86 else()
87 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.")
4888 endif()
4989 endif()
90 set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
91 set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
5092 endif()
5193 endif()
572572 options, which are passed to the CCACHE_MAXSIZE and CCACHE_DIR environment
573573 variables, respectively.
574574
575 **LLVM_FORCE_USE_OLD_TOOLCHAIN**:BOOL
576 If enabled, the compiler and standard library versions won't be checked. LLVM
577 may not compile at all, or might fail at runtime due to known bugs in these
578 toolchains.
579
580 **LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN**:BOOL
581 If enabled, the compiler version check will only warn when using a toolchain
582 which is about to be deprecated, instead of emitting an error.
583
575584 CMake Caches
576585 ============
577586
2121
2222 #. Make life as simple and easy for contributors as possible.
2323
24 #. Keep the tip of tree as stable as possible.
24 #. Keep the top of tree as stable as possible.
2525
2626 #. Establish awareness of the project's :ref:`copyright, license, and patent
2727 policies ` with contributors to the project.
637637 status, but also markers to define bit-rot, and will be used to clean up the
638638 tree from unmaintained targets.
639639
640 .. _toolchain:
641
642 Updating Toolchain Requirements
643 -------------------------------
644
645 We intend to require newer toolchains as time goes by. This means LLVM's
646 codebase can use newer versions of C++ as they get standardized. Requiring newer
647 toolchains to build LLVM can be painful for those building LLVM; therefore, it
648 will only be done through the following process:
649
650 * Generally, try to support LLVM and GCC versions from the last 3 years at a
651 minimum. This time-based guideline is not strict: we may support much older
652 compilers, or decide to support fewer versions.
653
654 * An RFC is sent to the `llvm-dev mailing list `_
655
656 - Detail upsides of the version increase (e.g. which newer C++ language or
657 library features LLVM should use; avoid miscompiles in particular compiler
658 versions, etc).
659 - Detail downsides on important platforms (e.g. Ubuntu LTS status).
660
661 * Once the RFC reaches consensus, update the CMake toolchain version checks as
662 well as the :doc:`getting started` guide. We want to
663 soft-error when developers compile LLVM. We say "soft-error" because the
664 error can be turned into a warning using a CMake flag. This is an important
665 step: LLVM still doesn't have code which requires the new toolchains, but it
666 soon will. If you compile LLVM but don't read the mailing list, we should
667 tell you!
668
669 * Ensure that at least one LLVM release has had this soft-error. Not all
670 developers compile LLVM top-of-tree. These release-bound developers should
671 also be told about upcoming changes.
672
673 * Turn the soft-error into a hard-error after said LLVM release has branched.
674
675 * Update the :doc:`coding standards` to allow the new
676 features we've explicitly approved in the RFC.
677
678 * Start using the new features in LLVM's codebase.
679
680
640681 .. _copyright-license-patents:
641682
642683 Copyright, License, and Patents
169169 Package Version Notes
170170 =========================================================== ============ ==========================================
171171 `GNU Make `_ 3.79, 3.79.1 Makefile/build processor
172 `GCC `_ >=4.8.0 C/C++ compiler\ :sup:`1`
172 `GCC `_ >=5.1.0 C/C++ compiler\ :sup:`1`
173173 `python `_ >=2.7 Automated test suite\ :sup:`2`
174174 `zlib `_ >=1.2.3.4 Compression library\ :sup:`3`
175175 =========================================================== ============ ==========================================
219219 ------------------------------------------------------
220220
221221 LLVM is very demanding of the host C++ compiler, and as such tends to expose
222 bugs in the compiler. We are also planning to follow improvements and
223 developments in the C++ language and library reasonably closely. As such, we
224 require a modern host C++ toolchain, both compiler and standard library, in
225 order to build LLVM.
226
227 For the most popular host toolchains we check for specific minimum versions in
228 our build systems:
222 bugs in the compiler. We also attempt to follow improvements and developments in
223 the C++ language and library reasonably closely. As such, we require a modern
224 host C++ toolchain, both compiler and standard library, in order to build LLVM.
225
226 LLVM is written using the subset of C++ documented in :doc:`coding
227 standards`. To enforce this language version, we check the most
228 popular host toolchains for specific minimum versions in our build systems:
229
230 * Clang 3.5
231 * Apple Clang 6.0
232 * GCC 5.1
233 * Visual Studio 2017
234
235 The below versions currently soft-error as we transition to the new compiler
236 versions listed above. The LLVM codebase is currently known to compile correctly
237 with the following compilers, though this will change in the near future:
229238
230239 * Clang 3.1
240 * Apple Clang 3.1
231241 * GCC 4.8
232242 * Visual Studio 2015 (Update 3)
233243
281291 distribution on which users have struggled with the version requirements is
282292 Ubuntu Precise, 12.04 LTS. For this distribution, one easy option is to install
283293 the `toolchain testing PPA`_ and use it to install a modern GCC. There is
284 a really nice discussions of this on the `ask ubuntu stack exchange`_. However,
285 not all users can use PPAs and there are many other distributions, so it may be
286 necessary (or just useful, if you're here you *are* doing compiler development
287 after all) to build and install GCC from source. It is also quite easy to do
288 these days.
294 a really nice discussions of this on the `ask ubuntu stack exchange`_ and a
295 `github gist`_ with updated commands. However, not all users can use PPAs and
296 there are many other distributions, so it may be necessary (or just useful, if
297 you're here you *are* doing compiler development after all) to build and install
298 GCC from source. It is also quite easy to do these days.
289299
290300 .. _toolchain testing PPA:
291301 https://launchpad.net/~ubuntu-toolchain-r/+archive/test
292302 .. _ask ubuntu stack exchange:
293 http://askubuntu.com/questions/271388/how-to-install-gcc-4-8-in-ubuntu-12-04-from-the-terminal
294
295 Easy steps for installing GCC 4.8.2:
296
297 .. code-block:: console
298
299 % wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2
300 % wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2.sig
303 https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu/581497#58149
304 .. _github gist:
305 https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
306
307 Easy steps for installing GCC 5.1.0:
308
309 .. code-block:: console
310
311 % gcc_version=5.1.0
312 % wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2
313 % wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2.sig
301314 % wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
302 % signature_invalid=`gpg --verify --no-default-keyring --keyring ./gnu-keyring.gpg gcc-4.8.2.tar.bz2.sig`
315 % signature_invalid=`gpg --verify --no-default-keyring --keyring ./gnu-keyring.gpg gcc-${gcc_version}.tar.bz2.sig`
303316 % if [ $signature_invalid ]; then echo "Invalid signature" ; exit 1 ; fi
304 % tar -xvjf gcc-4.8.2.tar.bz2
305 % cd gcc-4.8.2
317 % tar -xvjf gcc-${gcc_version}.tar.bz2
318 % cd gcc-${gcc_version}
306319 % ./contrib/download_prerequisites
307320 % cd ..
308 % mkdir gcc-4.8.2-build
309 % cd gcc-4.8.2-build
310 % $PWD/../gcc-4.8.2/configure --prefix=$HOME/toolchains --enable-languages=c,c++
321 % mkdir gcc-${gcc_version}-build
322 % cd gcc-${gcc_version}-build
323 % $PWD/../gcc-${gcc_version}/configure --prefix=$HOME/toolchains --enable-languages=c,c++
311324 % make -j$(nproc)
312325 % make install
313326
315328 of this information from.
316329
317330 .. _GCC wiki entry:
318 http://gcc.gnu.org/wiki/InstallingGCC
331 https://gcc.gnu.org/wiki/InstallingGCC
319332
320333 Once you have a GCC toolchain, configure your build of LLVM to use the new
321334 toolchain for your host compiler and C++ standard library. Because the new
335348 from the loader similar to ``libstdc++.so.6: version `GLIBCXX_3.4.20' not
336349 found``. This means you need to tweak the -rpath linker flag.
337350
338 When you build Clang, you will need to give *it* access to modern C++11
351 When you build Clang, you will need to give *it* access to modern C++
339352 standard library in order to use it as your new host in part of a bootstrap.
340353 There are two easy ways to do this, either build (and install) libc++ along
341354 with Clang and then use it with the ``-stdlib=libc++`` compile and link flag,