diff options
-rwxr-xr-x | config.tests/unix/arch.test | 77 | ||||
-rwxr-xr-x | configure | 81 | ||||
-rw-r--r-- | configure.json | 37 | ||||
-rw-r--r-- | configure.pri | 98 | ||||
-rw-r--r-- | mkspecs/features/qt_configure.prf | 23 |
5 files changed, 120 insertions, 196 deletions
diff --git a/config.tests/unix/arch.test b/config.tests/unix/arch.test deleted file mode 100755 index cfb47def4f..0000000000 --- a/config.tests/unix/arch.test +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -QMKSPEC=$1 -VERBOSE=$2 -SRCDIR=$3 -OUTDIR=$4 -RESULTFILE=$5 -TARGET=$6 -QMAKE=$7 -QTCONF=$8 -shift 8 - -if [ "$TARGET" = "host" ]; then - VARPREFIX="CFG_HOST" - PROSUFFIX="_host" -else - VARPREFIX="CFG" - PROSUFFIX="" -fi - -LFLAGS="$SYSROOT_FLAG" -CXXFLAGS="$SYSROOT_FLAG" - -while [ "$#" -gt 0 ]; do - PARAM=$1 - case $PARAM in - -L*|-l*) - LFLAGS="$LFLAGS \"$PARAM\"" - ;; - -I*) - INC=`echo $PARAM | sed -e 's/^-I//'` - INCLUDEPATH="$INCLUDEPATH \"$INC\"" - ;; - -D*) - CXXFLAGS="$CXXFLAGS \"$PARAM\"" - ;; - *) ;; - esac - shift -done - -# debuggery -[ "$VERBOSE" = "yes" ] && echo "Determining architecture... ($*)" - -# build a test program but don't run it -test -d "$OUTDIR/config.tests/arch" || mkdir -p "$OUTDIR/config.tests/arch" -cd "$OUTDIR/config.tests/arch" -[ -f Makefile ] && $MAKE distclean >/dev/null 2>&1 -OUTDIR=$OUTDIR "$QMAKE" -qtconf "$QTCONF" -nocache -spec "$QMKSPEC" "LIBS+=$LFLAGS" "QMAKE_CXXFLAGS+=$CXXFLAGS" "INCLUDEPATH+=$INCLUDEPATH" "CONFIG-=app_bundle" "$SRCDIR/config.tests/arch/arch$PROSUFFIX.pro" >/dev/null 2>&1 || echo "qmake is broken" >&2 - - -ARCH="" -[ "$VERBOSE" = "yes" ] && $MAKE || $MAKE >/dev/null 2>&1 - -if [ -f ./arch.exe ]; then - binary=./arch.exe -elif [ -f ./arch ]; then - binary=./arch -elif [ -f ./libarch.so ]; then - binary=./libarch.so -else - [ "$VERBOSE" = "yes" ] && echo "Unable to determine architecture!" - exit 2 -fi - -if strings - $binary 2>/dev/null | \ - awk -F: '/\=\=Qt\=magic\=Qt\=\= Architecture/ { print "'$VARPREFIX'_ARCH=\"" $2 "\"" } - /\=\=Qt\=magic\=Qt\=\= Sub-architecture/ { print "'$VARPREFIX'_CPUFEATURES=\"" $2 "\"" }' > "$RESULTFILE" -then - [ "$VERBOSE" = "yes" ] && echo " Found architecture in binary" && \ - cat "$RESULTFILE" -else - [ "$VERBOSE" = "yes" ] && echo "Unable to determine architecture!" - exit 2 -fi - -$MAKE distclean >/dev/null 2>&1 @@ -486,13 +486,6 @@ CFG_NOBUILD_PARTS="" CFG_SKIP_MODULES="" CFG_ANDROID_STYLE_ASSETS=yes -# Target architecture -CFG_ARCH= -CFG_CPUFEATURES= -# Host architecture, same as CFG_ARCH when not cross-compiling -CFG_HOST_ARCH= -CFG_HOST_CPUFEATURES= - XPLATFORM= # This seems to be the QMAKESPEC, like "linux-g++" XPLATFORM_MAC=no # Whether target platform is OS X, iOS or tvOS XPLATFORM_IOS=no # Whether target platform is iOS @@ -526,7 +519,6 @@ QT_INSTALL_SETTINGS= QT_INSTALL_EXAMPLES= QT_INSTALL_TESTS= CFG_SYSROOT= -CFG_GCC_SYSROOT="yes" QT_HOST_PREFIX= QT_HOST_BINS= QT_HOST_LIBS= @@ -722,9 +714,6 @@ while [ "$#" -gt 0 ]; do sysroot) CFG_SYSROOT="$VAL" ;; - gcc-sysroot) - CFG_GCC_SYSROOT="$VAL" - ;; external-hostbindir) CFG_HOST_QT_TOOLS_PATH="$VAL" HostVar set HOST_QT_TOOLS "$VAL" @@ -1396,13 +1385,6 @@ if [ "$XPLATFORM_ANDROID" != "yes" ]; then fi fi -if [ -n "$CFG_SYSROOT" ] && [ "$CFG_GCC_SYSROOT" = "yes" ]; then - SYSROOT_FLAG="--sysroot=$CFG_SYSROOT" -else - SYSROOT_FLAG= -fi -export SYSROOT_FLAG # used by config.tests/unix/{compile.test,arch.test} - #setup the build parts if [ -z "$CFG_BUILD_PARTS" ]; then CFG_BUILD_PARTS="$QT_DEFAULT_BUILD_PARTS" @@ -1977,71 +1959,14 @@ if [ $? != "0" ]; then fi #------------------------------------------------------------------------------- -# determine the target and host architectures -#------------------------------------------------------------------------------- - -# Use config.tests/arch/arch.pro to have the compiler tell us what the target architecture is -OUTFILE=$outpath/arch.result -"$unixtests/arch.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "target" $CFG_QMAKE_PATH $QTCONFFILE $I_FLAGS $D_FLAGS $L_FLAGS -if [ $? -eq 0 ]; then - eval `cat "$OUTFILE"` -else - echo - echo "Could not determine the target architecture!" - echo "Turn on verbose messaging (-v) to see the final report." -fi -rm -f "$OUTFILE" 2>/dev/null -[ -z "$CFG_ARCH" ] && CFG_ARCH="unknown" - -if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then - # Do the same test again, using the host compiler - SYSROOT_FLAG= "$unixtests/arch.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "$OUTFILE" "host" $CFG_QMAKE_PATH $QTCONFFILE $I_FLAGS $D_FLAGS $L_FLAGS - if [ $? -eq 0 ]; then - eval `cat "$OUTFILE"` - else - echo - echo "Could not determine the host architecture!" - echo "Turn on verbose messaging (-v) to see the final report." - fi - rm -f "$OUTFILE" 2>/dev/null - [ -z "$CFG_HOST_ARCH" ] && CFG_HOST_ARCH="unknown" -else - # not cross compiling, host == target - CFG_HOST_ARCH="$CFG_ARCH" - CFG_HOST_CPUFEATURES="$CFG_CPUFEATURES" -fi -unset OUTFILE - -if [ "$OPT_VERBOSE" = "yes" ]; then - echo "System architecture: '$CFG_ARCH'" - echo "Host architecture: '$CFG_HOST_ARCH'" -fi - -#------------------------------------------------------------------------------- # run configure tests #------------------------------------------------------------------------------- # copy some variables that are still being computed in the shell script into an input file for configure # This should go away in the future -QMAKE_TESTED_FEATURES="cpufeatures host_cpufeatures" -echo "# Feature defaults set by configure command line" > $outpath/config.tests/configure.cfg -for feature in $QMAKE_TESTED_FEATURES; do - if [ -n "$BASH_VERSION" ] && [ "${BASH_VERSION%%.*}" -gt 3 ]; then - upper=${feature^^*} - elif [ -n "$ZSH_VERSION" ]; then - upper=${(U)feature} - else - upper=`echo $feature | tr a-z A-Z` - fi - upper=`echo $upper | sed 's,-,_,g'` - eval "res=\$CFG_$upper" - if [ "$res" != "auto" ]; then - echo "config.input.$feature=$res" >> $relpath/config.tests/configure.cfg - fi -done - -cat >> "$outpath/config.tests/configure.cfg" <<EOF +cat > "$outpath/config.tests/configure.cfg" <<EOF +# Feature defaults set by configure command line config.input.qt_build_parts = $CFG_BUILD_PARTS config.input.extra_features = $CFG_FEATURES config.input.skip_modules = $CFG_SKIP_MODULES @@ -2071,7 +1996,7 @@ set +f IFS=$SAVED_IFS # redirect qmake's output to a dummy Makefile -$CFG_QMAKE_PATH -o Makefile.cfg -qtconf "$QTCONFFILE" QT_ARCH=$CFG_ARCH QT_HOST_ARCH=$CFG_HOST_ARCH $relpath/configure.pri -- "$@" || exit 101 +$CFG_QMAKE_PATH -o Makefile.cfg -qtconf "$QTCONFFILE" $relpath/configure.pri -- "$@" || exit 101 rm Makefile.cfg # Re-use old file if unchanged, to avoid needless rebuilds diff --git a/configure.json b/configure.json index 87fd5d7190..440e6a6b6a 100644 --- a/configure.json +++ b/configure.json @@ -200,6 +200,20 @@ }, "tests": { + "architecture": { + "description": "target architecture", + "type": "architecture", + "test": "arch", + "log": "arch" + }, + "host_architecture": { + "description": "host architecture", + "type": "architecture", + "test": "arch", + "host": true, + "pro": "arch_host.pro", + "log": "arch" + }, "GNUmake": { "description": "GNU make", "type": "gnumake" @@ -933,7 +947,7 @@ "description": "Verbose configure output", "autoDetect": false, "output": [ "verbose" ], - "priority": -3 + "priority": -4 }, "shared": { @@ -946,7 +960,7 @@ { "type": "publicQtConfig", "negative": true, "name": "static" }, { "type": "publicConfig", "negative": true, "name": "static" } ], - "priority": -2 + "priority": -3 }, "cross_compile": { "description": "Cross compiling", @@ -955,13 +969,24 @@ }, "compiler-flags": { "output": [ "compilerFlags" ], - "priority": -2 + "priority": -3 }, "gcc-sysroot": { "output": [ "gccSysroot" ], "condition": "input.sysroot != ''", + "priority": -3 + }, + "use_gold_linker": { + "description": "Using gold linker", + "condition": "tests.use_gold_linker", + "output": [ "privateConfig", "useGoldLinker" ], "priority": -2 }, + "architecture": { + "description": "Architecture", + "output": [ "architecture" ], + "priority": -1 + }, "pkg-config": { "description": "Using pkg-config", "autoDetect": "!config.darwin", @@ -972,12 +997,6 @@ ], "priority": -1 }, - "use_gold_linker": { - "description": "Using gold linker", - "condition": "tests.use_gold_linker", - "output": [ "privateConfig", "useGoldLinker" ], - "priority": -1 - }, "developer-build": { "description": "Developer build", diff --git a/configure.pri b/configure.pri index f2e26073c7..7ed7544053 100644 --- a/configure.pri +++ b/configure.pri @@ -53,6 +53,37 @@ defineReplace(qtConfFunc_crossCompile) { # custom tests +defineTest(qtConfTest_architecture) { + !qtConfTest_compile($${1}): \ + error("Could not determine $$eval($${1}.description). See config.log for details.") + + test = $$eval($${1}.test) + test_out_dir = $$shadowed($$QMAKE_CONFIG_TESTS_DIR/$$test) + exists($$test_out_dir/arch): \ + content = $$cat($$test_out_dir/arch, blob) + else: exists($$test_out_dir/arch.exe): \ + content = $$cat($$test_out_dir/arch.exe, blob) + else: exists($$test_out_dir/libarch.so): \ + content = $$cat($$test_out_dir/libarch.so, blob) + else: \ + error("$$eval($${1}.description) detection binary not found.") + + arch_magic = ".*==Qt=magic=Qt== Architecture:([^\\0]*).*" + subarch_magic = ".*==Qt=magic=Qt== Sub-architecture:([^\\0]*).*" + + !contains(content, $$arch_magic)|!contains(content, $$subarch_magic): \ + error("$$eval($${1}.description) detection binary does not contain expected data.") + + $${1}.arch = $$replace(content, $$arch_magic, "\\1") + $${1}.subarch = $$replace(content, $$subarch_magic, "\\1") + $${1}.subarch = $$split($${1}.subarch, " ") + export($${1}.arch) + export($${1}.subarch) + qtLog("Detected architecture: $$eval($${1}.arch) ($$eval($${1}.subarch))") + + return(true) +} + defineTest(qtConfTest_avx_test_apple_clang) { !*g++*:!*-clang*: return(true) @@ -151,7 +182,7 @@ defineTest(qtConfTest_detectPkgConfig) { } defineTest(qtConfTest_neon) { - contains(config.input.cpufeatures, "neon"): return(true) + contains(config.tests.architecture.subarch, "neon"): return(true) return(false) } @@ -329,6 +360,43 @@ defineTest(qtConfOutput_shared) { export(CONFIG) } +defineTest(qtConfOutput_architecture) { + arch = $$qtConfEvaluate("tests.architecture.arch") + + $$qtConfEvaluate("features.cross_compile") { + host_arch = $$qtConfEvaluate("tests.host_architecture.arch") + + privatePro = \ + "host_build {" \ + " QT_CPU_FEATURES.$$host_arch = $$qtConfEvaluate('tests.host_architecture.subarch')" \ + "} else {" \ + " QT_CPU_FEATURES.$$arch = $$qtConfEvaluate('tests.architecture.subarch')" \ + "}" + publicPro = \ + "host_build {" \ + " QT_ARCH = $$host_arch" \ + " QT_TARGET_ARCH = $$arch" \ + "} else {" \ + " QT_ARCH = $$arch" \ + "}" + + } else { + privatePro = \ + "QT_CPU_FEATURES.$$arch = $$qtConfEvaluate('tests.architecture.subarch')" + publicPro = \ + "QT_ARCH = $$arch" + } + + config.output.publicPro += $$publicPro + export(config.output.publicPro) + config.output.privatePro += $$privatePro + export(config.output.privatePro) + + # setup QT_ARCH variable used by qtConfEvaluate + QT_ARCH = $$arch + export(QT_ARCH) +} + defineTest(qtConfOutput_verbose) { !$${2}: return() @@ -454,16 +522,7 @@ defineTest(qtConfOutput_extraFeatures) { defineTest(qtConfOutputPostProcess_privatePro) { - output = \ - "host_build {" \ - " QT_CPU_FEATURES.$$QT_HOST_ARCH = $$config.input.host_cpufeatures" \ - "} else {" \ - " QT_CPU_FEATURES.$$QT_ARCH = $$config.input.cpufeatures" \ - "}" - - output += $$cat($$OUT_PWD/.qmake.vars, lines) - - config.output.privatePro += $$output + config.output.privatePro += $$cat($$OUT_PWD/.qmake.vars, lines) export(config.output.privatePro) } @@ -538,14 +597,7 @@ defineTest(qtConfOutputPostProcess_publicPro) { "QT_VERSION = $$qt_version" \ "QT_MAJOR_VERSION = $$section(qt_version, '.', 0, 0)" \ "QT_MINOR_VERSION = $$section(qt_version, '.', 1, 1)" \ - "QT_PATCH_VERSION = $$section(qt_version, '.', 2, 2)" \ - \ - "host_build {" \ - " QT_ARCH = $$QT_HOST_ARCH" \ - " QT_TARGET_ARCH = $$QT_ARCH" \ - "} else {" \ - " QT_ARCH = $$QT_ARCH" \ - "}" + "QT_PATCH_VERSION = $$section(qt_version, '.', 2, 2)" #libinfix and namespace !isEmpty(config.input.qt_libinfix): output += "QT_LIBINFIX = $$config.input.qt_libinfix" @@ -593,11 +645,11 @@ defineTest(qtConfReport_buildParts) { } defineTest(qtConfReport_buildTypeAndConfig) { - equals(QT_ARCH, $$QT_HOST_ARCH) { - qtConfAddReport("Build type: $$QT_ARCH") + !$$qtConfEvaluate("features.cross_compile") { + qtConfAddReport("Build type: $$qtConfEvaluate('tests.architecture.arch')") } else { - qtConfAddReport("Building on: $$QT_HOST_ARCH") - qtConfAddReport("Building for: $$QT_ARCH") + qtConfAddReport("Building on: $$qtConfEvaluate('tests.host_architecture.arch')") + qtConfAddReport("Building for: $$qtConfEvaluate('tests.architecture.arch')") } qtConfAddReport() qtConfAddReport("Configuration: $$config.output.privatePro.append.CONFIG $$config.output.publicPro.append.QT_CONFIG") diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 4372da6499..c4f24cddd8 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -360,12 +360,16 @@ defineTest(qtConfTest_getPkgConfigVariable) { defineTest(qtConfTest_compile) { test = $$eval($${1}.test) + host = $$eval($${1}.host) + isEmpty(host): host = false # get package config information qtConfTest_pkgConfig($${1}) test_dir = $$QMAKE_CONFIG_TESTS_DIR/$$test test_out_dir = $$shadowed($$test_dir) + !isEmpty($${1}.pro): \ + test_dir = $$test_dir/$$eval($${1}.pro) test_cmd_base = "cd $$system_quote($$system_path($$test_out_dir)) &&" # Disable qmake features which are typically counterproductive for tests @@ -383,13 +387,16 @@ defineTest(qtConfTest_compile) { winrt: \ qmake_configs += " \"QMAKE_LFLAGS += /ENTRY:main\"" - # add compiler flags - !isEmpty(EXTRA_DEFINES): \ - qmake_configs += "\"DEFINES += $$EXTRA_DEFINES\"" - !isEmpty(EXTRA_LIBS) \ - qmake_configs += "\"LIBS += $$EXTRA_LIBS\"" - !isEmpty(EXTRA_INCLUDEPATH): \ - qmake_configs += "\"INCLUDEPATH += $$EXTRA_INCLUDEPATH\"" + !$$host { + # add compiler flags, these are set for the target and should not be applied to host tests + !isEmpty(EXTRA_DEFINES): \ + qmake_configs += "\"DEFINES += $$EXTRA_DEFINES\"" + !isEmpty(EXTRA_LIBS) \ + qmake_configs += "\"LIBS += $$EXTRA_LIBS\"" + !isEmpty(EXTRA_INCLUDEPATH): \ + qmake_configs += "\"INCLUDEPATH += $$EXTRA_INCLUDEPATH\"" + qmake_configs += $$EXTRA_QMAKE_ARGS + } libs = $$eval($${1}.libs) !isEmpty(libs): \ @@ -399,8 +406,6 @@ defineTest(qtConfTest_compile) { !isEmpty(includedir): \ qmake_configs += "\"INCLUDEPATH *= $$includedir\"" - qmake_configs += $$EXTRA_QMAKE_ARGS - # Clean up after previous run exists($$test_out_dir/Makefile): qtRunLoggedCommand("$$test_cmd_base $$QMAKE_MAKE distclean") |