summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSitsofe Wheeler <sitsofe@yahoo.com>2017-09-23 22:48:12 +0100
committerSitsofe Wheeler <sitsofe@yahoo.com>2017-09-24 10:24:41 +0100
commitb73af7389a47bb04d841d749eb8a4e996eb5a271 (patch)
tree0589af0ece7639d52e65fe01e5df8f10f1ce9cd2
parent5580d200d7ae49cdb4f30913e3ef2d74e431ff60 (diff)
downloadfio-b73af7389a47bb04d841d749eb8a4e996eb5a271.tar.gz
fio-b73af7389a47bb04d841d749eb8a4e996eb5a271.tar.bz2
configure: update compiler probing
- Allow clang to be always guessable as a fallback compiler after gcc. This increases the likelihood we have a compiler when one wasn't explicitly set before we search through #define definitions to guess what platform we're targeting. The fallback can be overridden later (e.g. to prefer clang above other fallbacks on specific platforms). - Add comments to explain the preferred compiler search (inspired by comments in QEMU's ./configure). - Change from only checking $CC to also checking $cross_prefix before overriding. - Switch from setting CC to setting cc when overriding. This fixes the case where cc is "gcc" but CC is "i686-w64-mingw32-gcc" on Cygwin64 when building a 32 bit fio. - Because it is now possible for no compiler to be set, bail out with an explicit error message if we find this is the case. - Add macOS/Darwin to the platforms that prefer clang as the fallback compiler. - Minor refactoring. Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
-rwxr-xr-xconfigure48
1 files changed, 31 insertions, 17 deletions
diff --git a/configure b/configure
index cefd6103..749cb1fb 100755
--- a/configure
+++ b/configure
@@ -225,7 +225,20 @@ if test "$show_help" = "yes" ; then
fi
cross_prefix=${cross_prefix-${CROSS_COMPILE}}
-cc="${CC-${cross_prefix}gcc}"
+# Preferred compiler (can be overriden later after we know the platform):
+# ${CC} (if set)
+# ${cross_prefix}gcc (if cross-prefix specified)
+# gcc if available
+# clang if available
+if test -z "${CC}${cross_prefix}"; then
+ if has gcc; then
+ cc=gcc
+ elif has clang; then
+ cc=clang
+ fi
+else
+ cc="${CC-${cross_prefix}gcc}"
+fi
if check_define __ANDROID__ ; then
targetos="Android"
@@ -301,16 +314,16 @@ SunOS)
CYGWIN*)
# We still force some options, so keep this message here.
echo "Forcing some known good options on Windows"
- if test -z "$CC" ; then
+ if test -z "${CC}${cross_prefix}"; then
if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
- CC="i686-w64-mingw32-gcc"
+ cc="i686-w64-mingw32-gcc"
if test -e "../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
echo "Building with zlib support"
output_sym "CONFIG_ZLIB"
echo "LIBS=../zlib/contrib/vstudio/vc14/x86/ZlibStatReleaseWithoutAsm/zlibstat.lib" >> $config_host_mak
fi
else
- CC="x86_64-w64-mingw32-gcc"
+ cc="x86_64-w64-mingw32-gcc"
if test -e "../zlib/contrib/vstudio/vc14/x64/ZlibStatReleaseWithoutAsm/zlibstat.lib"; then
echo "Building with zlib support"
output_sym "CONFIG_ZLIB"
@@ -340,11 +353,24 @@ CYGWIN*)
tls_thread="yes"
static_assert="yes"
ipv6="yes"
- echo "CC=$CC" >> $config_host_mak
echo "BUILD_CFLAGS=$CFLAGS -I../zlib -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
;;
esac
+# Now we know the target platform we can have another guess at the preferred
+# compiler when it wasn't explictly set
+if test -z "${CC}${cross_prefix}"; then
+ if test "$targetos" = "FreeBSD" || test "$targetos" = "Darwin"; then
+ if has clang; then
+ cc=clang
+ fi
+ fi
+fi
+if test -z "$cc"; then
+ echo "configure: failed to find compiler"
+ exit 1
+fi
+
if test ! -z "$cpu" ; then
# command line argument
:
@@ -415,18 +441,6 @@ case "$cpu" in
;;
esac
-if test -z "$CC" ; then
- if test "$targetos" = "FreeBSD"; then
- if has clang; then
- CC=clang
- else
- CC=gcc
- fi
- fi
-fi
-
-cc="${CC-${cross_prefix}gcc}"
-
##########################################
# check cross compile