Bump minimum toolchain version · llvm/llvm-project@388cefa (original) (raw)
`@@ -5,13 +5,18 @@
`
5
5
`include(CheckCXXSourceCompiles)
`
6
6
``
7
7
`set(GCC_MIN 4.8)
`
8
``
`-
set(GCC_WARN 4.8)
`
``
8
`+
set(GCC_SOFT_ERROR 5.1)
`
9
9
`set(CLANG_MIN 3.1)
`
10
``
`-
set(CLANG_WARN 3.1)
`
``
10
`+
set(CLANG_SOFT_ERROR 3.5)
`
11
11
`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
+
15
20
``
16
21
`if(DEFINED LLVM_COMPILER_CHECKED)
`
17
22
`return()
`
`@@ -22,21 +27,25 @@ if(LLVM_FORCE_USE_OLD_TOOLCHAIN)
`
22
27
`return()
`
23
28
`endif()
`
24
29
``
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)
`
26
31
` if(NOT CMAKE_CXX_COMPILER_ID STREQUAL NAME)
`
27
32
`return()
`
28
33
` endif()
`
29
34
` if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MINIMUM_VERSION)
`
30
35
`message(FATAL_ERROR "Host NICENAMEversionmustbeatleast{NICE_NAME} version must be at least NICENAMEversionmustbeatleast{MINIMUM_VERSION}, your version is ${CMAKE_CXX_COMPILER_VERSION}.")
`
31
``
`-
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS WARN_VERSION)
`
32
``
`-
message(WARNING "Host NICENAMEversionmustbeatleast{NICE_NAME} version must be at least NICENAMEversionmustbeatleast{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 NICENAMEversionshouldbeatleast{NICE_NAME} version should be at least NICENAMEversionshouldbeatleast{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 NICENAMEversionshouldbeatleast{NICE_NAME} version should be at least NICENAMEversionshouldbeatleast{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()
`
33
42
` endif()
`
34
43
`endfunction(check_compiler_version)
`
35
44
``
36
``
`-
check_compiler_version("GNU" "GCC" GCCMIN{GCC_MIN} GCCMIN{GCC_WARN})
`
37
``
`-
check_compiler_version("Clang" "Clang" CLANGMIN{CLANG_MIN} CLANGMIN{CLANG_WARN})
`
38
``
`-
check_compiler_version("AppleClang" "Apple Clang" APPLECLANGMIN{APPLECLANG_MIN} APPLECLANGMIN{APPLECLANG_WARN})
`
39
``
`-
check_compiler_version("MSVC" "Visual Studio" MSVCMIN{MSVC_MIN} MSVCMIN{MSVC_WARN})
`
``
45
`+
check_compiler_version("GNU" "GCC" GCCMIN{GCC_MIN} GCCMIN{GCC_SOFT_ERROR})
`
``
46
`+
check_compiler_version("Clang" "Clang" CLANGMIN{CLANG_MIN} CLANGMIN{CLANG_SOFT_ERROR})
`
``
47
`+
check_compiler_version("AppleClang" "Apple Clang" APPLECLANGMIN{APPLECLANG_MIN} APPLECLANGMIN{APPLECLANG_SOFT_ERROR})
`
``
48
`+
check_compiler_version("MSVC" "Visual Studio" MSVCMIN{MSVC_MIN} MSVCMIN{MSVC_SOFT_ERROR})
`
40
49
``
41
50
`if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
`
42
51
` if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
`
`@@ -45,20 +54,39 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
`
45
54
` endif()
`
46
55
`set(CLANG_CL 1)
`
47
56
` 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++.
`
52
58
`set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
`
53
59
`set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
`
54
60
`set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
`
55
61
`check_cxx_source_compiles("
`
56
``
`-
#include
`
57
``
`-
std::atomic 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
`
``
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
`
``
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()
`
62
90
` endif()
`
63
91
`set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
`
64
92
`set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
`