From ba6952b28d17b6b34f65510be645e414fa1ef6a2 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 14 Feb 2012 10:01:17 +0100 Subject: [PATCH] Remove -arch argument and #define QT_ARCH from configures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not try to detect the host or target architectures using uname or similar, and do not override with the -arch or -host-arch configure arguments. The configures will still accept the -arch and -host-arch arguments, but it ignores them and instead outputs a warning stating that these arguments are obsolete and should not be used. Set QT_ARCH and QT_HOST_ARCH qconfig.pri variables based on the compiler target. This is done by running qmake (twice when cross-compiling) on config.tests/arch/arch.pro, which preprocesses a file that contains all knowns processors. On Windows, configure.exe has never run any config.tests before, and does not currently have a function to run a program and capture its output. Use _popen() to accomplish this (as qmake does for its system() function). This needs to be done after qmake is built, as does the mkspecs/qconfig.pri generation. As a side effect, the configure steps have been slightly re-ordered, but the overall result is the same. The displayConfig() call is moved to just before generating Makefiles, so that it can show the detected architecture(s). Change-Id: I77666c77a93b48848f87648d08e79a42f721683f Reviewed-by: Morten Johan Sørvig Reviewed-by: Oswald Buddenhagen --- config.tests/arch/arch.cpp | 70 ++++++ config.tests/arch/arch.pro | 7 + configure | 299 +++++++---------------- src/corelib/global/qprocessordetection.h | 4 + tools/configure/configureapp.cpp | 121 +++++++-- tools/configure/configureapp.h | 2 + tools/configure/environment.cpp | 22 ++ tools/configure/environment.h | 1 + tools/configure/main.cpp | 10 +- 9 files changed, 297 insertions(+), 239 deletions(-) create mode 100644 config.tests/arch/arch.cpp create mode 100644 config.tests/arch/arch.pro diff --git a/config.tests/arch/arch.cpp b/config.tests/arch/arch.cpp new file mode 100644 index 00000000000..0c12565f7c7 --- /dev/null +++ b/config.tests/arch/arch.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// NOTE: This file is not meant to be compiled, only preprocessed. +#include "../../src/corelib/global/qprocessordetection.h" +#if defined(Q_PROCESSOR_ALPHA) +alpha +#elif defined(Q_PROCESSOR_ARM) +arm +#elif defined(Q_PROCESSOR_AVR32) +avr32 +#elif defined(Q_PROCESSOR_BLACKFIN) +bfin +#elif defined(Q_PROCESSOR_X86_32) +i386 +#elif defined(Q_PROCESSOR_X86_64) +x86_64 +#elif defined(Q_PROCESSOR_IA64) +ia64 +#elif defined(Q_PROCESSOR_MIPS) +mips +#elif defined(Q_PROCESSOR_POWER) +power +#elif defined(Q_PROCESSOR_S390) +s390 +#elif defined(Q_PROCESSOR_SH) +sh +#elif defined(Q_PROCESSOR_SPARC) +sparc +#else +unknown +#endif diff --git a/config.tests/arch/arch.pro b/config.tests/arch/arch.pro new file mode 100644 index 00000000000..108f262a557 --- /dev/null +++ b/config.tests/arch/arch.pro @@ -0,0 +1,7 @@ +CONFIG -= qt debug_and_release +# Detect target by preprocessing a file that uses Q_PROCESSOR_* macros from qprocessordetection.h +COMMAND = $$QMAKE_CXX $$QMAKE_CXXFLAGS -E $$PWD/arch.cpp +# 'false' as second argument to system() prevents qmake from stripping newlines +COMPILER_ARCH = $$system($$COMMAND, false) +# Message back to configure so that it can set QT_ARCH and QT_HOST_ARCH +message($$COMPILER_ARCH) diff --git a/configure b/configure index e2df6028fd3..04f6005a8b9 100755 --- a/configure +++ b/configure @@ -693,8 +693,13 @@ CFG_V8SNAPSHOT=auto CFG_DECLARATIVE_DEBUG=yes CFG_JAVASCRIPTCORE_JIT=auto +# Target architecture CFG_ARCH= +# Host architecture, same as CFG_ARCH when not cross-compiling CFG_HOST_ARCH= +# Set when the -arch or -host-arch arguments are used +OPT_OBSOLETE_HOST_ARG=no + CFG_USE_GNUMAKE=no CFG_IM=yes CFG_XINPUT2=auto @@ -742,7 +747,6 @@ CFG_GETIFADDRS=auto CFG_INOTIFY=auto CFG_RPATH=yes CFG_FRAMEWORK=auto -CFG_MAC_ARCHS= MAC_CONFIG_TEST_COMMANDLINE= # used to make the configure tests run with the correct arch's and SDK settings CFG_MAC_DWARF2=auto CFG_MAC_HARFBUZZ=no @@ -1201,17 +1205,8 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; - arch) - # if this is a Mac then "windows" probably means - # we are cross-compiling for MinGW - if [ "$BUILD_ON_MAC" = "yes" ] && [ "$VAL" != "windows" ]; then - CFG_MAC_ARCHS="$CFG_MAC_ARCHS $VAL" - else - CFG_ARCH=$VAL - fi - ;; - host-arch) - CFG_HOST_ARCH=$VAL + arch|host-arch) + OPT_OBSOLETE_HOST_ARG=yes ;; harfbuzz) if [ "$BUILD_ON_MAC" = "yes" ] && [ "$VAL" = "yes" ]; then @@ -2420,13 +2415,6 @@ if [ "$UNAME_SYSTEM" = "SunOS" ]; then fi fi -#------------------------------------------------------------------------------- -# determine the system architecture -#------------------------------------------------------------------------------- -if [ "$OPT_VERBOSE" = "yes" ]; then - echo "Determining system architecture... ($UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_MACHINE)" -fi - if [ "$CFG_RTOS_ENABLED" = "no" ]; then case `basename "$XPLATFORM"` in qnx-* | vxworks-*) @@ -2441,153 +2429,6 @@ if [ "$CFG_RTOS_ENABLED" = "no" ]; then esac fi -if [ -z "${CFG_HOST_ARCH}" ]; then - case "$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_MACHINE" in - GNU:*:*) - CFG_HOST_ARCH=`echo ${UNAME_MACHINE} | sed -e 's,[-/].*$,,'` - case "$CFG_HOST_ARCH" in - i?86) - CFG_HOST_ARCH=i386 - ;; - esac - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " GNU/Hurd ($CFG_HOST_ARCH)" - fi - ;; - IRIX*:*:*) - CFG_HOST_ARCH=`uname -p` - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " SGI ($CFG_HOST_ARCH)" - fi - ;; - SunOS:5*:*) - case "$UNAME_MACHINE" in - sun4u*|sun4v*) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " Sun SPARC (sparc)" - fi - CFG_HOST_ARCH=sparc - ;; - i86pc) - case "$PLATFORM" in - *-64*) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " 64-bit AMD 80x86 (x86_64)" - fi - CFG_HOST_ARCH=x86_64 - ;; - *) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " 32-bit Intel 80x86 (i386)" - fi - CFG_HOST_ARCH=i386 - ;; - esac - esac - ;; - AIX:*:00????????00) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " 64-bit IBM PowerPC (powerpc)" - fi - CFG_HOST_ARCH=powerpc - ;; - HP-UX:*:9000*) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " HP PA-RISC (parisc)" - fi - CFG_HOST_ARCH=parisc - ;; - *:*:i?86) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " 32-bit Intel 80x86 (i386)" - fi - CFG_HOST_ARCH=i386 - ;; - *:*:x86_64|*:*:amd64) - if [ "$PLATFORM" = "linux-g++-32" -o "$PLATFORM" = "linux-icc-32" ]; then - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " 32 bit on 64-bit AMD 80x86 (i386)" - fi - CFG_HOST_ARCH=i386 - else - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " 64-bit AMD 80x86 (x86_64)" - fi - CFG_HOST_ARCH=x86_64 - fi - ;; - *:*:ppc) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " 32-bit PowerPC (powerpc)" - fi - CFG_HOST_ARCH=powerpc - ;; - *:*:ppc64) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " 64-bit PowerPC (powerpc)" - fi - CFG_HOST_ARCH=powerpc - ;; - *:*:s390*) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " IBM S/390 (s390)" - fi - CFG_HOST_ARCH=s390 - ;; - *:*:arm*) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " ARM (arm)" - fi - CFG_HOST_ARCH=arm - ;; - Linux:*:sparc*) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " Linux on SPARC" - fi - CFG_HOST_ARCH=sparc - ;; - QNX:*:*) - case "$UNAME_MACHINE" in - x86pc) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " QNX on Intel 80x86 (i386)" - fi - CFG_HOST_ARCH=i386 - ;; - esac - ;; - *:*:*) - if [ "$OPT_VERBOSE" = "yes" ]; then - echo " Trying '$UNAME_MACHINE'..." - fi - CFG_HOST_ARCH="$UNAME_MACHINE" - ;; - esac -fi - -if [ "$XPLATFORM_MINGW" = "yes" ]; then - [ -z "$CFG_ARCH" ] && CFG_ARCH="windows" -elif [ "$PLATFORM_MAC" = "yes" ] || [ -z "$CFG_ARCH" ]; then - CFG_ARCH=$CFG_HOST_ARCH -fi - -# for compatibility -COMPAT_ARCH= -case "$CFG_ARCH" in -arm*) - # previously, armv6 was a different arch - CFG_ARCH=arm - COMPAT_ARCH=armv6 - ;; -esac - -if [ "$OPT_VERBOSE" = "yes" ]; then - echo "System architecture: '$CFG_ARCH'" - if [ "$PLATFORM_QPA" = "yes" ]; then - echo "Host architecture: '$CFG_HOST_ARCH'" - fi -fi - #------------------------------------------------------------------------------- # tests that don't need qmake (must be run before displaying help) #------------------------------------------------------------------------------- @@ -3548,9 +3389,6 @@ Qt/Mac only: * -dwarf2 ............ Enable dwarf2 debugging symbols. -no-dwarf2 ......... Disable dwarf2 debugging symbols. - -arch ....... Build Qt for . Supported arch values: x86 x86_64. - Only one arch value can be specified. - -sdk ......... Build Qt using Apple provided SDK . This option requires gcc 4. To use a different SDK with gcc 3.3, set the SDKROOT environment variable. @@ -4038,6 +3876,33 @@ fi # Build qmake # tests that need qmake #------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +# determine the target and host architectures +#------------------------------------------------------------------------------- + +# Use config.tests/arch/arch.pro to has the compiler tell us what the target architecture is +CFG_ARCH=`"$outpath/bin/qmake" -spec "$XQMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -e "s,^Project MESSAGE: ,," -e "s,^#.*$,,g" | grep -v "^$"` +[ -z "$CFG_ARCH" ] && CFG_ARCH="unknown" +if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then + # Do the same test again, using the host compiler + CFG_HOST_ARCH=`"$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -e "s,^Project MESSAGE: ,," -e "s,^#.*$,,g" | grep -v "^$"` + [ -z "$CFG_HOST_ARCH" ] && CFG_HOST_ARCH="unknown" +else + # not cross compiling, host == target + CFG_HOST_ARCH="$CFG_ARCH" +fi + +if [ "$OPT_VERBOSE" = "yes" ]; then + echo "System architecture: '$CFG_ARCH'" + if [ "$PLATFORM_QPA" = "yes" ]; then + echo "Host architecture: '$CFG_HOST_ARCH'" + fi +fi + +#------------------------------------------------------------------------------- +# functionality tests +#------------------------------------------------------------------------------- + # detect availability of float math.h functions if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/floatmath "floatmath" $L_FLAGS $I_FLAGS $l_FLAGS; then CFG_USE_FLOATMATH=yes @@ -4143,6 +4008,8 @@ if [ "$CFG_ARCH" = "arm" ] && [ "${CFG_NEON}" = "auto" ]; then else CFG_NEON=no fi +elif [ "$CFG_ARCH" != "arm" ]; then + CFG_NEON=no fi [ "$XPLATFORM_MINGW" = "yes" ] && QMakeVar add styles "windowsxp windowsvista" @@ -5522,29 +5389,27 @@ if [ "$CFG_MAC_DWARF2" = "yes" ]; then QT_CONFIG="$QT_CONFIG dwarf2" fi -# Set the default Mac OS X arch if there are no "-arch" arguments on the configure line +# Detect the default arch (x86 or x86_64) on Mac OS X if [ "$BUILD_ON_MAC" = "yes" ]; then - DEFAULT_ARCH="$CFG_MAC_ARCHS" - if [ -z "$DEFAULT_ARCH" ]; then - case `file "${outpath}/bin/qmake"` in - *i?86) - DEFAULT_ARCH=x86 - ;; - *x86_64) - DEFAULT_ARCH=x86_64 - ;; - *ppc|*ppc64|*) - # unsupported/unknown - ;; - esac - fi + DEFAULT_ARCH= + case `file "${outpath}/bin/qmake"` in + *i?86) + DEFAULT_ARCH=x86 + ;; + *x86_64) + DEFAULT_ARCH=x86_64 + ;; + *ppc|*ppc64|*) + # unsupported/unknown + ;; + esac + if [ -n "$DEFAULT_ARCH" ]; then [ "$OPT_VERBOSE" = "yes" ] && echo "Setting default Mac OS X architechture to $DEFAULT_ARCH." QT_CONFIG="$QT_CONFIG $DEFAULT_ARCH" QMAKE_CONFIG="$QMAKE_CONFIG $DEFAULT_ARCH" - # Make the application arch follow the Qt arch for single arch builds. - # (for multiple-arch builds, set CONFIG manually in the application .pro file) - [ `echo "$DEFAULT_ARCH" | wc -w` -eq 1 ] && QTCONFIG_CONFIG="$QTCONFIG_CONFIG $DEFAULT_ARCH" + # Make the application arch follow the Qt arch + QTCONFIG_CONFIG="$QTCONFIG_CONFIG $DEFAULT_ARCH" fi fi @@ -6156,17 +6021,6 @@ cat >>"$outpath/src/corelib/global/qconfig.h.new" <>"$outpath/src/corelib/global/qconfig.h.new" <>"$outpath/src/corelib/global/qconfig.h.new" [ '!' -z "$LicenseKeyExt" ] && echo "#define QT_PRODUCT_LICENSEKEY \"$LicenseKeyExt\"" >>"$outpath/src/corelib/global/qconfig.h.new" @@ -6389,6 +6243,7 @@ cat >>"$QTCONFIG.tmp" < will be used (when + available). The generic implementations are generally as fast + as and always as safe as a specialized implementation. + + If no generic implementation is available, Qt will use a + fallback UNIX implementation which uses a single + pthread_mutex_t to protect all atomic operations. This implementation is the slow (but safe) fallback implementation for architectures Qt does not yet support. EOF @@ -7042,6 +6900,21 @@ cat <] [-qt-sql-]\n" - "[-plugin-sql-] [-system-sqlite] [-arch ]\n" + "[-plugin-sql-] [-system-sqlite]\n" "[-D ] [-I ] [-L ]\n" "[-help] [-no-dsp] [-dsp] [-no-vcproj] [-vcproj]\n" "[-no-qmake] [-qmake] [-dont-process] [-process]\n" @@ -1623,13 +1617,6 @@ bool Configure::displayHelp() desc("DIRECTWRITE", "no", "-no-directwrite", "Do not build support for DirectWrite font rendering"); desc("DIRECTWRITE", "yes", "-directwrite", "Build support for DirectWrite font rendering (experimental, requires DirectWrite availability on target systems, e.g. Windows Vista with Platform Update, Windows 7, etc.)"); - desc( "-arch ", "Specify an architecture.\n" - "Available values for :"); - desc("ARCHITECTURE","windows", "", " windows", ' '); - desc("ARCHITECTURE","windowsce", "", " windowsce", ' '); - desc("ARCHITECTURE","boundschecker", "", " boundschecker", ' '); - desc("ARCHITECTURE","generic", "", " generic\n", ' '); - desc( "-no-style-