@@ -945,162 +945,6 @@ then
945
945
fi
946
946
fi
947
947
948
- # If the clang isn't already enabled, check for GCC, and if it is missing, turn
949
- # on clang as a backup.
950
- if [ -z " $CFG_ENABLE_CLANG " ]
951
- then
952
- CFG_GCC_VERSION=$( " $CFG_GCC " --version 2>&1 )
953
- if [ $? -ne 0 ]
954
- then
955
- step_msg " GCC not installed, will try using Clang"
956
- CFG_ENABLE_CLANG=1
957
- fi
958
- fi
959
-
960
- # Okay, at this point, we have made up our minds about whether we are
961
- # going to force CFG_ENABLE_CLANG or not; save the setting if so.
962
- if [ -n " $CFG_ENABLE_CLANG " ]
963
- then
964
- putvar CFG_ENABLE_CLANG
965
- fi
966
-
967
- # Same with jemalloc. save the setting here.
968
- if [ -n " $CFG_DISABLE_JEMALLOC " ]
969
- then
970
- putvar CFG_DISABLE_JEMALLOC
971
- fi
972
-
973
- if [ -n " $CFG_LLVM_ROOT " -a -z " $CFG_DISABLE_LLVM_VERSION_CHECK " -a -e " $CFG_LLVM_ROOT /bin/llvm-config" ]
974
- then
975
- step_msg " using custom LLVM at $CFG_LLVM_ROOT "
976
-
977
- LLVM_CONFIG=" $CFG_LLVM_ROOT /bin/llvm-config"
978
- LLVM_VERSION=$( $LLVM_CONFIG --version)
979
-
980
- case $LLVM_VERSION in
981
- (3.[5-8]* )
982
- msg " found ok version of LLVM: $LLVM_VERSION "
983
- ;;
984
- (* )
985
- err " bad LLVM version: $LLVM_VERSION , need >=3.5"
986
- ;;
987
- esac
988
- fi
989
-
990
- # Even when the user overrides the choice of CC, still try to detect
991
- # clang to disable some clang-specific warnings. We here draw a
992
- # distinction between:
993
- #
994
- # CFG_ENABLE_CLANG : passed --enable-clang, or host "requires" clang,
995
- # CFG_USING_CLANG : compiler (clang / gcc / $CC) looks like clang.
996
- #
997
- # This distinction is important because there are some safeguards we
998
- # would prefer to skip when merely CFG_USING_CLANG is set; but when
999
- # CFG_ENABLE_CLANG is set, that indicates that we are opting into
1000
- # running such safeguards.
1001
-
1002
- if [ -n " $CC " ]
1003
- then
1004
- msg " skipping compiler inference steps; using provided CC=$CC "
1005
- CFG_CC=" $CC "
1006
-
1007
- CFG_OSX_CC_VERSION=$( " $CFG_CC " --version 2>&1 | grep " clang" )
1008
- if [ $? -eq 0 ]
1009
- then
1010
- step_msg " note, user-provided CC looks like clang; CC=$CC ."
1011
- CFG_USING_CLANG=1
1012
- putvar CFG_USING_CLANG
1013
- fi
1014
- else
1015
- if [ -n " $CFG_ENABLE_CLANG " ]
1016
- then
1017
- if [ -z " $CFG_CLANG " ]
1018
- then
1019
- err " clang requested but not found"
1020
- fi
1021
- CFG_CC=" $CFG_CLANG "
1022
- CFG_USING_CLANG=1
1023
- putvar CFG_USING_CLANG
1024
- else
1025
- CFG_CC=" gcc"
1026
- fi
1027
- fi
1028
-
1029
- if [ -n " $CFG_ENABLE_CLANG " ]
1030
- then
1031
- case " $CC " in
1032
- (' ' |* clang)
1033
- CFG_CLANG_REPORTED_VERSION=$( $CFG_CC --version | grep version)
1034
-
1035
- if echo $CFG_CLANG_REPORTED_VERSION | grep -q " (based on LLVM " ; then
1036
- CFG_CLANG_VERSION=$( echo $CFG_CLANG_REPORTED_VERSION | sed ' s/.*(based on LLVM \(.*\))/\1/' )
1037
- elif echo $CFG_CLANG_REPORTED_VERSION | grep -q " Apple LLVM" ; then
1038
- CFG_OSX_CLANG_VERSION=$( echo $CFG_CLANG_REPORTED_VERSION | sed ' s/.*version \(.*\) .*/\1/' )
1039
- else
1040
- CFG_CLANG_VERSION=$( echo $CFG_CLANG_REPORTED_VERSION | sed ' s/.*version \(.*\) .*/\1/' )
1041
- fi
1042
-
1043
- if [ -n " $CFG_OSX_CLANG_VERSION " ]
1044
- then
1045
- case $CFG_OSX_CLANG_VERSION in
1046
- (7.0* )
1047
- step_msg " found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION "
1048
- ;;
1049
- (* )
1050
- err " bad APPLE CLANG version: $CFG_OSX_CLANG_VERSION , need >=7.0"
1051
- ;;
1052
- esac
1053
- else
1054
- case $CFG_CLANG_VERSION in
1055
- (3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7* | 3.8* )
1056
- step_msg " found ok version of CLANG: $CFG_CLANG_VERSION "
1057
- ;;
1058
- (* )
1059
- err " bad CLANG version: $CFG_CLANG_VERSION , need >=3.0svn"
1060
- ;;
1061
- esac
1062
- fi
1063
-
1064
- if [ -z " $CC " ]
1065
- then
1066
- CFG_CC=" clang"
1067
- CFG_CXX=" clang++"
1068
- fi
1069
- esac
1070
- fi
1071
-
1072
- if [ -n " $CFG_ENABLE_CCACHE " ]
1073
- then
1074
- if [ -z " $CFG_CCACHE " ]
1075
- then
1076
- err " ccache requested but not found"
1077
- fi
1078
-
1079
- CFG_CC=" ccache $CFG_CC "
1080
- fi
1081
-
1082
- if [ -z " $CC " -a -z " $CFG_ENABLE_CLANG " -a -z " $CFG_GCC " ]
1083
- then
1084
- err " either clang or gcc is required"
1085
- fi
1086
-
1087
- # All safeguards based on $CFG_ENABLE_CLANG should occur before this
1088
- # point in the script; after this point, script logic should inspect
1089
- # $CFG_USING_CLANG rather than $CFG_ENABLE_CLANG.
1090
-
1091
- # Set CFG_{CC,CXX,CPP,CFLAGS,CXXFLAGS}
1092
- envopt CC
1093
- envopt CXX
1094
- envopt CPP
1095
- envopt CFLAGS
1096
- envopt CXXFLAGS
1097
-
1098
- # stdc++ name in use
1099
- # used to manage non-standard name (on OpenBSD for example)
1100
- program_transform_name=$( $CFG_CC -v 2>&1 | sed -n " s/.*--program-transform-name='\([^']*\)'.*/\1/p" )
1101
- CFG_STDCPP_NAME=$( echo " stdc++" | sed " ${program_transform_name} " )
1102
- putvar CFG_STDCPP_NAME
1103
-
1104
948
# a little post-processing of various config values
1105
949
CFG_PREFIX=${CFG_PREFIX%/ }
1106
950
CFG_MANDIR=${CFG_MANDIR%/ }
@@ -1214,15 +1058,18 @@ $ pacman -R python2 && pacman -S mingw-w64-x86_64-python2
1214
1058
"
1215
1059
fi
1216
1060
1217
- # MSVC requires cmake because that's how we're going to build LLVM
1218
- probe_need CFG_CMAKE cmake
1219
-
1220
- # There are three builds of cmake on windows: MSVC, MinGW and Cygwin
1221
- # The Cygwin build does not have generators for Visual Studio, so
1222
- # detect that here and error.
1223
- if ! " $CFG_CMAKE " --help | sed -n ' /^Generators/,$p' | grep ' Visual Studio' > /dev/null
1061
+ # Only probe for cmake if we actually need to build LLVM
1062
+ if [ -z $CFG_LLVM_ROOT ]
1224
1063
then
1225
- err "
1064
+ # MSVC requires cmake because that's how we're going to build LLVM
1065
+ probe_need CFG_CMAKE cmake
1066
+
1067
+ # There are three builds of cmake on windows: MSVC, MinGW and Cygwin
1068
+ # The Cygwin build does not have generators for Visual Studio, so
1069
+ # detect that here and error.
1070
+ if ! " $CFG_CMAKE " --help | sed -n ' /^Generators/,$p' | grep ' Visual Studio' > /dev/null
1071
+ then
1072
+ err "
1226
1073
1227
1074
cmake does not support Visual Studio generators.
1228
1075
@@ -1235,6 +1082,7 @@ package instead of cmake:
1235
1082
1236
1083
$ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
1237
1084
"
1085
+ fi
1238
1086
fi
1239
1087
1240
1088
# Use the REG program to figure out where VS is installed
@@ -1300,6 +1148,162 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
1300
1148
esac
1301
1149
done
1302
1150
1151
+ # If we're not targetting MSVC, and clang isn't already enabled, check for GCC,
1152
+ # and if it is missing, turn on clang as a backup.
1153
+ if [ -z " $CFG_MSVC_ROOT " -a -z " $CFG_ENABLE_CLANG " ]
1154
+ then
1155
+ CFG_GCC_VERSION=$( " $CFG_GCC " --version 2>&1 )
1156
+ if [ $? -ne 0 ]
1157
+ then
1158
+ step_msg " GCC not installed, will try using Clang"
1159
+ CFG_ENABLE_CLANG=1
1160
+ fi
1161
+ fi
1162
+
1163
+ # Okay, at this point, we have made up our minds about whether we are
1164
+ # going to force CFG_ENABLE_CLANG or not; save the setting if so.
1165
+ if [ -n " $CFG_ENABLE_CLANG " ]
1166
+ then
1167
+ putvar CFG_ENABLE_CLANG
1168
+ fi
1169
+
1170
+ # Same with jemalloc. save the setting here.
1171
+ if [ -n " $CFG_DISABLE_JEMALLOC " ]
1172
+ then
1173
+ putvar CFG_DISABLE_JEMALLOC
1174
+ fi
1175
+
1176
+ if [ -n " $CFG_LLVM_ROOT " -a -z " $CFG_DISABLE_LLVM_VERSION_CHECK " -a -e " $CFG_LLVM_ROOT /bin/llvm-config" ]
1177
+ then
1178
+ step_msg " using custom LLVM at $CFG_LLVM_ROOT "
1179
+
1180
+ LLVM_CONFIG=" $CFG_LLVM_ROOT /bin/llvm-config"
1181
+ LLVM_VERSION=$( $LLVM_CONFIG --version)
1182
+
1183
+ case $LLVM_VERSION in
1184
+ (3.[5-8]* )
1185
+ msg " found ok version of LLVM: $LLVM_VERSION "
1186
+ ;;
1187
+ (* )
1188
+ err " bad LLVM version: $LLVM_VERSION , need >=3.5"
1189
+ ;;
1190
+ esac
1191
+ fi
1192
+
1193
+ # Even when the user overrides the choice of CC, still try to detect
1194
+ # clang to disable some clang-specific warnings. We here draw a
1195
+ # distinction between:
1196
+ #
1197
+ # CFG_ENABLE_CLANG : passed --enable-clang, or host "requires" clang,
1198
+ # CFG_USING_CLANG : compiler (clang / gcc / $CC) looks like clang.
1199
+ #
1200
+ # This distinction is important because there are some safeguards we
1201
+ # would prefer to skip when merely CFG_USING_CLANG is set; but when
1202
+ # CFG_ENABLE_CLANG is set, that indicates that we are opting into
1203
+ # running such safeguards.
1204
+
1205
+ if [ -n " $CC " ]
1206
+ then
1207
+ msg " skipping compiler inference steps; using provided CC=$CC "
1208
+ CFG_CC=" $CC "
1209
+
1210
+ CFG_OSX_CC_VERSION=$( " $CFG_CC " --version 2>&1 | grep " clang" )
1211
+ if [ $? -eq 0 ]
1212
+ then
1213
+ step_msg " note, user-provided CC looks like clang; CC=$CC ."
1214
+ CFG_USING_CLANG=1
1215
+ putvar CFG_USING_CLANG
1216
+ fi
1217
+ else
1218
+ if [ -n " $CFG_ENABLE_CLANG " ]
1219
+ then
1220
+ if [ -z " $CFG_CLANG " ]
1221
+ then
1222
+ err " clang requested but not found"
1223
+ fi
1224
+ CFG_CC=" $CFG_CLANG "
1225
+ CFG_USING_CLANG=1
1226
+ putvar CFG_USING_CLANG
1227
+ else
1228
+ CFG_CC=" gcc"
1229
+ fi
1230
+ fi
1231
+
1232
+ if [ -n " $CFG_ENABLE_CLANG " ]
1233
+ then
1234
+ case " $CC " in
1235
+ (' ' |* clang)
1236
+ CFG_CLANG_REPORTED_VERSION=$( $CFG_CC --version | grep version)
1237
+
1238
+ if echo $CFG_CLANG_REPORTED_VERSION | grep -q " (based on LLVM " ; then
1239
+ CFG_CLANG_VERSION=$( echo $CFG_CLANG_REPORTED_VERSION | sed ' s/.*(based on LLVM \(.*\))/\1/' )
1240
+ elif echo $CFG_CLANG_REPORTED_VERSION | grep -q " Apple LLVM" ; then
1241
+ CFG_OSX_CLANG_VERSION=$( echo $CFG_CLANG_REPORTED_VERSION | sed ' s/.*version \(.*\) .*/\1/' )
1242
+ else
1243
+ CFG_CLANG_VERSION=$( echo $CFG_CLANG_REPORTED_VERSION | sed ' s/.*version \(.*\) .*/\1/' )
1244
+ fi
1245
+
1246
+ if [ -n " $CFG_OSX_CLANG_VERSION " ]
1247
+ then
1248
+ case $CFG_OSX_CLANG_VERSION in
1249
+ (7.0* )
1250
+ step_msg " found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION "
1251
+ ;;
1252
+ (* )
1253
+ err " bad APPLE CLANG version: $CFG_OSX_CLANG_VERSION , need >=7.0"
1254
+ ;;
1255
+ esac
1256
+ else
1257
+ case $CFG_CLANG_VERSION in
1258
+ (3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7* | 3.8* )
1259
+ step_msg " found ok version of CLANG: $CFG_CLANG_VERSION "
1260
+ ;;
1261
+ (* )
1262
+ err " bad CLANG version: $CFG_CLANG_VERSION , need >=3.0svn"
1263
+ ;;
1264
+ esac
1265
+ fi
1266
+
1267
+ if [ -z " $CC " ]
1268
+ then
1269
+ CFG_CC=" clang"
1270
+ CFG_CXX=" clang++"
1271
+ fi
1272
+ esac
1273
+ fi
1274
+
1275
+ if [ -n " $CFG_ENABLE_CCACHE " ]
1276
+ then
1277
+ if [ -z " $CFG_CCACHE " ]
1278
+ then
1279
+ err " ccache requested but not found"
1280
+ fi
1281
+
1282
+ CFG_CC=" ccache $CFG_CC "
1283
+ fi
1284
+
1285
+ if [ -z " $CFG_MSVC_ROOT " -a -z " $CC " -a -z " $CFG_ENABLE_CLANG " -a -z " $CFG_GCC " ]
1286
+ then
1287
+ err " either clang or gcc is required"
1288
+ fi
1289
+
1290
+ # All safeguards based on $CFG_ENABLE_CLANG should occur before this
1291
+ # point in the script; after this point, script logic should inspect
1292
+ # $CFG_USING_CLANG rather than $CFG_ENABLE_CLANG.
1293
+
1294
+ # Set CFG_{CC,CXX,CPP,CFLAGS,CXXFLAGS}
1295
+ envopt CC
1296
+ envopt CXX
1297
+ envopt CPP
1298
+ envopt CFLAGS
1299
+ envopt CXXFLAGS
1300
+
1301
+ # stdc++ name in use
1302
+ # used to manage non-standard name (on OpenBSD for example)
1303
+ program_transform_name=$( $CFG_CC -v 2>&1 | sed -n " s/.*--program-transform-name='\([^']*\)'.*/\1/p" )
1304
+ CFG_STDCPP_NAME=$( echo " stdc++" | sed " ${program_transform_name} " )
1305
+ putvar CFG_STDCPP_NAME
1306
+
1303
1307
if [ -n " $CFG_PERF " ]
1304
1308
then
1305
1309
HAVE_PERF_LOGFD=` $CFG_PERF stat --log-fd 2>&1 | grep ' unknown option' `
0 commit comments