Skip to content

Commit b135650

Browse files
committed
[LLVM] Update C++ standard to 17
Also make the soft toolchain requirements hard. This allows us to use C++17 features in LLVM now. If we find patterns with C++17 that improve readability it should be recommended in the coding standards. Reviewed By: jhenderson, cor3ntin, MaskRay Differential Revision: https://reviews.llvm.org/D130689
1 parent 786b503 commit b135650

File tree

8 files changed

+32
-24
lines changed

8 files changed

+32
-24
lines changed

bolt/runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13.4)
22
include(CheckIncludeFiles)
33

44
set(CMAKE_CXX_EXTENSIONS OFF)
5-
set(CMAKE_CXX_STANDARD 14)
5+
set(CMAKE_CXX_STANDARD 17)
66

77
project(libbolt_rt_project)
88

clang/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ endif()
1111
include(GNUInstallDirs)
1212

1313
if(CLANG_BUILT_STANDALONE)
14-
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
14+
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
1515
set(CMAKE_CXX_STANDARD_REQUIRED YES)
1616
set(CMAKE_CXX_EXTENSIONS NO)
1717

lld/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ endif()
1111
include(GNUInstallDirs)
1212

1313
if(LLD_BUILT_STANDALONE)
14-
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
14+
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
1515
set(CMAKE_CXX_STANDARD_REQUIRED YES)
1616
set(CMAKE_CXX_EXTENSIONS NO)
1717

lldb/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ include(GNUInstallDirs)
2020
if(LLDB_BUILT_STANDALONE)
2121
include(LLDBStandalone)
2222

23-
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
23+
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
2424
set(CMAKE_CXX_STANDARD_REQUIRED YES)
2525
set(CMAKE_CXX_EXTENSIONS NO)
2626
endif()

llvm/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ project(LLVM
5858
# Must go after project(..)
5959
include(GNUInstallDirs)
6060

61-
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
61+
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
6262
set(CMAKE_CXX_STANDARD_REQUIRED YES)
6363
if (CYGWIN)
6464
# Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in

llvm/cmake/modules/CheckCompilerVersion.cmake

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44

55
include(CheckCXXSourceCompiles)
66

7-
set(GCC_MIN 5.1)
7+
set(GCC_MIN 7.1)
88
set(GCC_SOFT_ERROR 7.1)
9-
set(CLANG_MIN 3.5)
9+
set(CLANG_MIN 5.0)
1010
set(CLANG_SOFT_ERROR 5.0)
11-
set(APPLECLANG_MIN 6.0)
11+
set(APPLECLANG_MIN 9.3)
1212
set(APPLECLANG_SOFT_ERROR 9.3)
1313

1414
# https://en.wikipedia.org/wiki/Microsoft_Visual_C#Internal_version_numbering
15-
# _MSC_VER == 1920 MSVC++ 14.20 Visual Studio 2019 Version 16.0
1615
# _MSC_VER == 1927 MSVC++ 14.27 Visual Studio 2019 Version 16.7
17-
set(MSVC_MIN 19.20)
16+
set(MSVC_MIN 19.27)
1817
set(MSVC_SOFT_ERROR 19.27)
1918

20-
# Map the above GCC versions to dates: https://gcc.gnu.org/develop.html#timeline
21-
set(GCC_MIN_DATE 20150422)
19+
set(LIBSTDCXX_MIN 7)
2220
set(LIBSTDCXX_SOFT_ERROR 7)
2321

2422

@@ -76,22 +74,14 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
7674
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
7775
set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
7876
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
79-
# Test for libstdc++ version of at least 4.8 by checking for _ZNKSt17bad_function_call4whatEv.
80-
# Note: We should check _GLIBCXX_RELEASE when possible (i.e., for GCC 7.1 and up).
8177
check_cxx_source_compiles("
8278
#include <iosfwd>
8379
#if defined(__GLIBCXX__)
84-
#if __GLIBCXX__ < ${GCC_MIN_DATE}
80+
#if !defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE < ${LIBSTDCXX_MIN}
8581
#error Unsupported libstdc++ version
8682
#endif
8783
#endif
88-
#if defined(__GLIBCXX__)
89-
extern const char _ZNKSt17bad_function_call4whatEv[];
90-
const char *chk = _ZNKSt17bad_function_call4whatEv;
91-
#else
92-
const char *chk = \"\";
93-
#endif
94-
int main() { ++chk; return 0; }
84+
int main() { return 0; }
9585
"
9686
LLVM_LIBSTDCXX_MIN)
9787
if(NOT LLVM_LIBSTDCXX_MIN)

llvm/docs/CodingStandards.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ choice.
5353
C++ Standard Versions
5454
---------------------
5555

56-
Unless otherwise documented, LLVM subprojects are written using standard C++14
56+
Unless otherwise documented, LLVM subprojects are written using standard C++17
5757
code and avoid unnecessary vendor-specific extensions.
5858

5959
Nevertheless, we restrict ourselves to features which are available in the
@@ -63,7 +63,13 @@ section `Software`).
6363
Each toolchain provides a good reference for what it accepts:
6464

6565
* Clang: https://clang.llvm.org/cxx_status.html
66-
* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx14
66+
67+
* libc++: https://libcxx.llvm.org/Status/Cxx17.html
68+
69+
* GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx17
70+
71+
* libstdc++: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017
72+
6773
* MSVC: https://msdn.microsoft.com/en-us/library/hh567368.aspx
6874

6975

llvm/docs/ReleaseNotes.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ Non-comprehensive list of changes in this release
4747
Update on required toolchains to build LLVM
4848
-------------------------------------------
4949

50+
LLVM is now built with C++17 by default. This means C++17 can be used in
51+
the code base.
52+
53+
The previous "soft" toolchain requirements have now been changed to "hard".
54+
This means that the the following versions are now required to build LLVM
55+
and there is no way to suppress this error.
56+
57+
* GCC >= 7.1
58+
* Clang >= 5.0
59+
* Apple Clang >= 9.3
60+
* Visual Studio 2019 >= 16.7
61+
5062
Changes to the LLVM IR
5163
----------------------
5264

0 commit comments

Comments
 (0)