2
2
#
3
3
# This file detects the C/C++ compiler and exports it to the CC/CXX environment variables
4
4
#
5
- # NOTE: some scripts source this file and rely on stdout being empty, make sure to not output anything here!
5
+ # NOTE: some scripts source this file and rely on stdout being empty, make sure
6
+ # to not output *anything* here, unless it is an error message that fails the
7
+ # build.
6
8
7
9
if [ -z " $build_arch " ] || [ -z " $compiler " ]; then
8
10
echo " Usage..."
@@ -62,6 +64,7 @@ if [ -z "$CLR_CC" ]; then
62
64
63
65
# Set default versions
64
66
if [ -z " $majorVersion " ]; then
67
+
65
68
# note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero.
66
69
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"
67
70
elif [ " $compiler " = " gcc" ]; then versions=" 13 12 11 10 9 8 7 6 5 4.9" ; fi
@@ -75,11 +78,14 @@ if [ -z "$CLR_CC" ]; then
75
78
76
79
if [ -z " $majorVersion " ]; then
77
80
if command -v " $compiler " > /dev/null; then
78
- if [ " $( uname) " != " Darwin" ]; then
79
- echo " Warning: Specific version of $compiler not found, falling back to use the one in PATH."
80
- fi
81
81
CC=" $( command -v " $compiler " ) "
82
82
CXX=" $( command -v " $cxxCompiler " ) "
83
+ version=" $( " $CC " -dumpversion) "
84
+ # gcc and clang often display 3 part versions. However, gcc can show only 1 part in some environments.
85
+ IFS=. read -r majorVersion minorVersion patchVersion << EOF
86
+ $version
87
+ EOF
88
+ unset patchVersion
83
89
else
84
90
echo " No usable version of $compiler found."
85
91
exit 1
@@ -88,7 +94,6 @@ if [ -z "$CLR_CC" ]; then
88
94
if [ " $compiler " = " clang" ] && [ " $majorVersion " -lt 5 ]; then
89
95
if [ " $build_arch " = " arm" ] || [ " $build_arch " = " armel" ]; then
90
96
if command -v " $compiler " > /dev/null; then
91
- echo " Warning: Found clang version $majorVersion which is not supported on arm/armel architectures, falling back to use clang from PATH."
92
97
CC=" $( command -v " $compiler " ) "
93
98
CXX=" $( command -v " $cxxCompiler " ) "
94
99
else
@@ -110,6 +115,12 @@ if [ -z "$CLR_CC" ]; then
110
115
CC=" $( command -v " $compiler$desired_version " ) "
111
116
CXX=" $( command -v " $cxxCompiler$desired_version " ) "
112
117
if [ -z " $CXX " ]; then CXX=" $( command -v " $cxxCompiler " ) " ; fi
118
+ version=" $( " $CC " -dumpversion) "
119
+ # gcc and clang often display 3 part versions. However, gcc can show only 1 part in some environments.
120
+ IFS=. read -r majorVersion minorVersion patchVersion << EOF
121
+ $version
122
+ EOF
123
+ unset patchVersion
113
124
fi
114
125
else
115
126
if [ ! -f " $CLR_CC " ]; then
0 commit comments