@@ -24,6 +24,9 @@ case "$compiler" in
24
24
if [ -z " $minorVersion " ] && [ -n " $majorVersion " ] && [ " $majorVersion " -le 6 ]; then
25
25
minorVersion=0;
26
26
fi
27
+
28
+ # LLVM based on v18 released in early 2024, with two releases per year
29
+ maxVersion=" $(( 18 + ((($(date +% Y) - 2024 ) * 12 + $(date +% m) - 3 ) / 6 )) )"
27
30
compiler=clang
28
31
;;
29
32
@@ -32,6 +35,9 @@ case "$compiler" in
32
35
version=" $( echo " $compiler " | tr -d ' [:alpha:]-=' ) "
33
36
majorVersion=" ${version%% .* } "
34
37
[ -z " ${version##* .* } " ] && minorVersion=" ${version#* .} "
38
+
39
+ # GCC based on v14 released in early 2024, with one release per year
40
+ maxVersion=" $(( 14 + ((($(date +% Y) - 2024 ) * 12 + $(date +% m) - 3 ) / 12 )) )"
35
41
compiler=gcc
36
42
;;
37
43
esac
@@ -84,11 +90,9 @@ if [ -z "$CLR_CC" ]; then
84
90
85
91
# Set default versions
86
92
if [ -z " $majorVersion " ]; then
87
- # note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero.
88
- if [ " $compiler " = " clang" ]; then versions=" 18 17 16 15 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5"
89
- elif [ " $compiler " = " gcc" ]; then versions=" 14 13 12 11 10 9 8 7 6 5 4.9" ; fi
90
-
91
- for version in $versions ; do
93
+ i=" $(( maxVersion + 1 )) " # +1 for headspace
94
+ minVersion=8
95
+ while [ " $i " -ge $minVersion ]; do
92
96
_major=" ${version%% .* } "
93
97
[ -z " ${version##* .* } " ] && _minor=" ${version#* .} "
94
98
desired_version=" $( check_version_exists " $_major " " $_minor " ) "
@@ -97,25 +101,13 @@ if [ -z "$CLR_CC" ]; then
97
101
98
102
if [ -z " $majorVersion " ]; then
99
103
if ! command -v " $compiler " > /dev/null; then
100
- echo " Error: No usable version of $compiler found."
104
+ echo " Error: No compatible version of $compiler was found within the range of $minVersion to $maxVersion . Please upgrade your toolchain or specify the compiler explicitly using CLR_CC and CLR_CXX environment variables ."
101
105
exit 1
102
106
fi
103
107
104
108
CC=" $( command -v " $compiler " 2> /dev/null) "
105
109
CXX=" $( command -v " $cxxCompiler " 2> /dev/null) "
106
110
set_compiler_version_from_CC
107
- else
108
- if [ " $compiler " = " clang" ] && [ " $majorVersion " -lt 5 ] && { [ " $build_arch " = " arm" ] || [ " $build_arch " = " armel" ]; }; then
109
- # If a major version was provided explicitly, and it was too old, find a newer compiler instead
110
- if ! command -v " $compiler " > /dev/null; then
111
- echo " Error: Found clang version $majorVersion which is not supported on arm/armel architectures, and there is no clang in PATH."
112
- exit 1
113
- fi
114
-
115
- CC=" $( command -v " $compiler " 2> /dev/null) "
116
- CXX=" $( command -v " $cxxCompiler " 2> /dev/null) "
117
- set_compiler_version_from_CC
118
- fi
119
111
fi
120
112
else
121
113
desired_version=" $( check_version_exists " $majorVersion " " $minorVersion " ) "
0 commit comments