turn off exceptions by default where they aren't required

This significantly reduces the size of the generated code
in places where we don't need exceptions.

The -(no-)exceptions configure flag has been removed in the
process, as there is now a fine grained way to control this
on a per module level, and Qt is being compiled without
exceptions in most places.

Change-Id: I99a15c5d03339db1fbffd4987935d0d671cdbc32
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2012-05-09 18:52:44 +02:00 committed by Qt by Nokia
parent d07982b104
commit 2b21dd69d6
16 changed files with 33 additions and 119 deletions

92
configure vendored
View File

@ -645,7 +645,6 @@ MIN_DBUS_1_VERSION=0.93
# initalize internal variables
CFG_CONFIGURE_EXIT_ON_ERROR=yes
CFG_PROFILE=no
CFG_EXCEPTIONS=unspecified
CFG_GUI=auto # (yes|no|auto)
CFG_WIDGETS=yes
CFG_QCONFIG=full
@ -891,7 +890,7 @@ while [ "$#" -gt 0 ]; do
VAL=no
;;
#Qt style yes options
-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-xinput2|-egl|-reduce-exports|-pch|-separate-debug-info|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-xcb|-eglfs|-directfb|-nis|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-debug-and-release|-exceptions|-harfbuzz|-prefix-install|-silent|-optimized-qmake|-reduce-relocations|-sse|-openssl|-openssl-linked|-phonon-backend|-audio-backend|-qml-debug|-javascript-jit|-rpath|-pkg-config|-force-pkg-config|-icu|-force-asserts|-testcocoon)
-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-xinput2|-egl|-reduce-exports|-pch|-separate-debug-info|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-xcb|-eglfs|-directfb|-nis|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-debug-and-release|-harfbuzz|-prefix-install|-silent|-optimized-qmake|-reduce-relocations|-sse|-openssl|-openssl-linked|-phonon-backend|-audio-backend|-qml-debug|-javascript-jit|-rpath|-pkg-config|-force-pkg-config|-icu|-force-asserts|-testcocoon)
VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
VAL=yes
;;
@ -1209,15 +1208,6 @@ while [ "$#" -gt 0 ]; do
QTCONFIG_CONFIG="$QTCONFIG_CONFIG testcocoon"
fi
;;
exceptions|g++-exceptions)
if [ "$VAL" = "no" ]; then
CFG_EXCEPTIONS=no
elif [ "$VAL" = "yes" ]; then
CFG_EXCEPTIONS=yes
else
UNKNOWN_OPT=yes
fi
;;
platform)
PLATFORM="$VAL"
# keep compatibility with old platform names
@ -2842,8 +2832,7 @@ Usage: $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir
[-translationdir <dir>] [-sysconfdir <dir>] [-examplesdir <dir>] [-testsdir <dir>]
[-release] [-debug] [-debug-and-release]
[-developer-build] [-shared] [-static] [-no-fast] [-fast] [-no-largefile]
[-largefile] [-no-exceptions] [-exceptions] [-no-accessibility]
[-accessibility] [-no-sql-<driver>] [-sql-<driver>]
[-largefile] [-no-accessibility] [-accessibility] [-no-sql-<driver>] [-sql-<driver>]
[-plugin-sql-<driver>] [-system-sqlite]
[-platform] [-D <string>] [-I <string>] [-L <string>] [-help]
[-qt-zlib] [-system-zlib] [-no-gif] [-no-libpng] [-qt-libpng] [-system-libpng]
@ -2944,9 +2933,6 @@ Configure options:
-no-largefile ...... Disables large file support.
+ -largefile ......... Enables Qt to access files larger than 4 GB.
-no-exceptions ..... Disable exceptions on compilers that support it.
* -exceptions ........ Enable exceptions on compilers that support it.
-no-accessibility .. Do not compile Accessibility support.
* -accessibility ..... Compile Accessibility support.
@ -5196,17 +5182,6 @@ if [ '!' -z "$W_FLAGS" ]; then
QMakeVar add QMAKE_OBJECTIVE_CFLAGS_WARN_ON "$W_FLAGS"
fi
# turn off exceptions for the compilers that support it
if [ "$XPLATFORM" != "$PLATFORM" ]; then
COMPILER=`echo $XPLATFORM | cut -f 2- -d-`
else
COMPILER=`echo $PLATFORM | cut -f 2- -d-`
fi
if [ "$CFG_EXCEPTIONS" != "no" ]; then
QTCONFIG_CONFIG="$QTCONFIG_CONFIG exceptions"
fi
if [ "$XPLATFORM_MINGW" = "yes" ]; then
# mkspecs/features/win32/default_pre.prf sets "no-rtti".
# Follow default behavior of configure.exe by overriding with "rtti".
@ -5412,28 +5387,6 @@ if [ "$CFG_QML_DEBUG" = "no" ]; then
QCONFIG_FLAGS="$QCONFIG_FLAGS QT_QML_NO_DEBUGGER"
fi
if [ "$CFG_EXCEPTIONS" = "no" ]; then
case "$COMPILER" in
g++*)
QMakeVar add QMAKE_CFLAGS -fno-exceptions
QMakeVar add QMAKE_CXXFLAGS -fno-exceptions
QMakeVar add QMAKE_LFLAGS -fno-exceptions
;;
cc*)
case "$PLATFORM" in
irix-cc*)
QMakeVar add QMAKE_CFLAGS -LANG:exceptions=off
QMakeVar add QMAKE_CXXFLAGS -LANG:exceptions=off
QMakeVar add QMAKE_LFLAGS -LANG:exceptions=off
;;
*) ;;
esac
;;
*) ;;
esac
QMAKE_CONFIG="$QMAKE_CONFIG exceptions_off"
fi
case "$COMPILER" in
g++*)
# GNU C++
@ -5553,7 +5506,6 @@ QMakeVar set sql-plugins "$SQL_PLUGINS"
[ "$CFG_PNG" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_PNG"
[ "$CFG_JPEG" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IMAGEFORMAT_JPEG"
[ "$CFG_ZLIB" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_ZLIB"
[ "$CFG_EXCEPTIONS" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EXCEPTIONS"
[ "$CFG_SXE" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SXE"
[ "$CFG_DBUS" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_DBUS"
@ -5860,46 +5812,6 @@ fi
#-------------------------------------------------------------------------------
exec 3>&1 1>$outpath/config.summary # redirect output temporarily to config.summary
case "$COMPILER" in
g++*)
if [ "$CFG_EXCEPTIONS" != "no" ]; then
cat <<EOF
This target is using the GNU C++ compiler ($PLATFORM).
Recent versions of this compiler automatically include code for
exceptions, which increase both the size of the Qt libraries and
the amount of memory taken by your applications.
You may choose to re-run `basename $0` with the -no-exceptions
option to compile Qt without exceptions. This is completely binary
compatible, and existing applications will continue to work.
EOF
fi
;;
cc*)
case "$PLATFORM" in
irix-cc*)
if [ "$CFG_EXCEPTIONS" != "no" ]; then
cat <<EOF
This target is using the MIPSpro C++ compiler ($PLATFORM).
You may choose to re-run `basename $0` with the -no-exceptions
option to compile Qt without exceptions. This will make the
size of the Qt library smaller and reduce the amount of memory
taken by your applications.
EOF
fi
;;
*) ;;
esac
;;
*) ;;
esac
echo
if [ "$XPLATFORM" = "$PLATFORM" ]; then
echo "Build type: $PLATFORM"

6
dist/changes-5.0.0 vendored
View File

@ -238,6 +238,12 @@ information about a particular change.
the raw values are available as QT_INSTALL_.../raw and the sysroot as QT_SYSROOT.
The new QT_HOST_... properties can be used to refer to the Qt host tools.
* Several functions and built-in variables were modified to return normalized paths.
* The -(no-)exception flags in configure have been removed. Qt modules are now compiled
without exceptions by default, as they do not use them and can neither handle them
properly. Qt Core still has exceptions enabled to correctly throw bad_alloc exceptions
in our tool classes.
Whether code should be compiled with exception support enabled or disabled can be
controlled by a CONFIG += exceptions/exceptions_off setting in the .pro file.
- QTextCodecPlugin has been removed since it is no longer used. All text codecs
are now built into QtCore.

View File

@ -43,6 +43,7 @@ QMAKE_CFLAGS_STATIC_LIB += -fPIC
QMAKE_CFLAGS_APP += -fPIE
QMAKE_CFLAGS_YACC += -Wno-unused -Wno-parentheses
QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden
QMAKE_CFLAGS_EXCEPTIONS_OFF += -fno-exceptions
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS
@ -55,9 +56,10 @@ QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB
QMAKE_CXXFLAGS_APP += $$QMAKE_CFLAGS_APP
QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
QMAKE_CXXFLAGS_EXCEPTIONS_OFF += $$QMAKE_CFLAGS_EXCEPTIONS_OFF
QMAKE_LFLAGS +=
QMAKE_LFLAGS_DEBUG +=
QMAKE_LFLAGS_APP +=
QMAKE_LFLAGS_RELEASE +=
QMAKE_LFLAGS_EXCEPTIONS_OFF +=

View File

@ -1,6 +1,6 @@
load(exclusive_builds)
### Qt 5: remove "uic" and "resources" - or add "qt"
CONFIG = lex yacc warn_on debug uic resources $$CONFIG
CONFIG = lex yacc warn_on debug uic resources exceptions $$CONFIG
!build_pass:exists($$_PRO_FILE_PWD_/sync.profile) {
PRO_BASENAME = $$basename(_PRO_FILE_)

View File

@ -2,4 +2,5 @@ CONFIG -= exceptions_off
QMAKE_CFLAGS *= $$QMAKE_CFLAGS_EXCEPTIONS_ON
QMAKE_CXXFLAGS *= $$QMAKE_CXXFLAGS_EXCEPTIONS_ON
QMAKE_LFLAGS *= $$QMAKE_LFLAGS_EXCEPTIONS_ON
DEFINES -= QT_NO_EXCEPTIONS

View File

@ -2,4 +2,4 @@ CONFIG -= exceptions
QMAKE_CFLAGS += $$QMAKE_CFLAGS_EXCEPTIONS_OFF
QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_EXCEPTIONS_OFF
QMAKE_LFLAGS += $$QMAKE_LFLAGS_EXCEPTIONS_OFF
DEFINES += QT_NO_EXCEPTIONS

View File

@ -28,3 +28,6 @@ mac {
CONFIG += absolute_library_soname
}
}
# Qt modules get compiled without exceptions enabled by default
CONFIG += exceptions_off

View File

@ -56,6 +56,7 @@ QMAKE_CFLAGS_SHLIB =
QMAKE_CFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_SHLIB
QMAKE_CFLAGS_YACC = -woff 1110,1174,3262
QMAKE_CFLAGS_THREAD =
QMAKE_CFLAGS_EXCEPTIONS_OFF = -LANG:exceptions=off
QMAKE_CXX = CC
QMAKE_CXXFLAGS = -64 -signed -LANG:std:libc_in_namespace_std=ON -woff 1209,1355,1375,1424,3303
@ -68,6 +69,7 @@ QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB
QMAKE_CXXFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_STATIC_LIB
QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_THREAD =
QMAKE_CXXFLAGS_EXCEPTIONS_OFF = $$QMAKE_CFLAGS_EXCEPTIONS_OFF
QMAKE_INCDIR =
QMAKE_LIBDIR =
@ -89,6 +91,7 @@ QMAKE_LFLAGS_SONAME = -Wl,-soname,
QMAKE_LFLAGS_THREAD =
QMAKE_LFLAGS_NOUNDEF = -Wl,-no_unresolved
QMAKE_LFLAGS_RPATH = -Wl,-rpath,
QMAKE_LFLAGS_EXCEPTIONS_OFF = $$QMAKE_CFLAGS_EXCEPTIONS_OFF
QMAKE_LIBS =
QMAKE_LIBS_DYNLOAD =

View File

@ -56,6 +56,7 @@ QMAKE_CFLAGS_SHLIB =
QMAKE_CFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_SHLIB
QMAKE_CFLAGS_YACC = -woff 1110,1174,3262
QMAKE_CFLAGS_THREAD =
QMAKE_CFLAGS_EXCEPTIONS_OFF = -LANG:exceptions=off
QMAKE_CXX = CC
QMAKE_CXXFLAGS = -n32 -signed -LANG:std:libc_in_namespace_std=ON -woff 1209,1355,1375,1424,3303
@ -68,6 +69,7 @@ QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB
QMAKE_CXXFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_STATIC_LIB
QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_THREAD =
QMAKE_CXXFLAGS_EXCEPTIONS_OFF = $$QMAKE_CFLAGS_EXCEPTIONS_OFF
QMAKE_INCDIR =
QMAKE_LIBDIR =
@ -89,6 +91,7 @@ QMAKE_LFLAGS_SONAME = -Wl,-soname,
QMAKE_LFLAGS_THREAD =
QMAKE_LFLAGS_NOUNDEF = -Wl,-no_unresolved
QMAKE_LFLAGS_RPATH = -Wl,-rpath,
QMAKE_LFLAGS_EXCEPTIONS_OFF = $$QMAKE_CFLAGS_EXCEPTIONS_OFF
QMAKE_LIBS =
QMAKE_LIBS_DYNLOAD =

View File

@ -4,7 +4,7 @@ TARGET = QtConcurrent
QPRO_PWD = $$PWD
QT = core-private
CONFIG += module
CONFIG += module exceptions
MODULE_PRI = ../modules/qt_concurrent.pri
DEFINES += QT_BUILD_CONCURRENT_LIB QT_NO_USING_NAMESPACE

View File

@ -4,7 +4,7 @@ TARGET = QtCore
QPRO_PWD = $$PWD
QT =
CONFIG += module
CONFIG += module exceptions
MODULE = core # not corelib, as per project file
MODULE_PRI = ../modules/qt_core.pri

View File

@ -659,11 +659,10 @@ inline void qt_noop(void) {}
Use the QT_NO_EXCEPTIONS macro to protect your code instead.
*/
#ifdef QT_BOOTSTRAPPED
# define QT_NO_EXCEPTIONS
#endif
#if !defined(QT_NO_EXCEPTIONS) && defined(Q_CC_GNU) && !defined (__EXCEPTIONS) && !defined(Q_MOC_RUN)
# define QT_NO_EXCEPTIONS
#if !defined(QT_NO_EXCEPTIONS)
# if defined(QT_BOOTSTRAPPED) || (defined(Q_CC_GNU) && !defined (__EXCEPTIONS) && !defined(Q_MOC_RUN))
# define QT_NO_EXCEPTIONS
# endif
#endif
#ifdef QT_NO_EXCEPTIONS

View File

@ -4,7 +4,7 @@ TARGET = QtTest
QPRO_PWD = $$PWD
QT = core
CONFIG += module
CONFIG += module exceptions
MODULE_PRI = ../modules/qt_testlib.pri
INCLUDEPATH += .

View File

@ -5,6 +5,7 @@ build_all:!build_pass {
CONFIG += release
}
CONFIG -= app_bundle
CONFIG += exceptions_off
DEFINES += \
QT_BOOTSTRAPPED \

View File

@ -4,6 +4,7 @@ CONFIG += staticlib
CONFIG += console qtinc
CONFIG -= qt
CONFIG += exceptions_off
build_all:!build_pass {
CONFIG -= build_all
CONFIG += release

View File

@ -200,7 +200,6 @@ Configure::Configure(int& argc, char** argv)
dictionary[ "QMAKE_INTERNAL" ] = "no";
dictionary[ "FAST" ] = "no";
dictionary[ "NOPROCESS" ] = "no";
dictionary[ "EXCEPTIONS" ] = "yes";
dictionary[ "WIDGETS" ] = "yes";
dictionary[ "RTTI" ] = "yes";
dictionary[ "SSE2" ] = "auto";
@ -769,11 +768,6 @@ void Configure::parseCmdLine()
else if (configCmdLine.at(i) == "-no-fast")
dictionary[ "FAST" ] = "no";
else if (configCmdLine.at(i) == "-exceptions")
dictionary[ "EXCEPTIONS" ] = "yes";
else if (configCmdLine.at(i) == "-no-exceptions")
dictionary[ "EXCEPTIONS" ] = "no";
else if (configCmdLine.at(i) == "-widgets")
dictionary[ "WIDGETS" ] = "yes";
else if (configCmdLine.at(i) == "-no-widgets")
@ -1365,7 +1359,6 @@ void Configure::applySpecSpecifics()
dictionary[ "FREETYPE" ] = "no";
dictionary[ "OPENGL" ] = "no";
dictionary[ "OPENSSL" ] = "no";
dictionary[ "EXCEPTIONS" ] = "no";
dictionary[ "RTTI" ] = "no";
dictionary[ "SSE2" ] = "no";
dictionary[ "IWMMXT" ] = "no";
@ -1388,7 +1381,6 @@ void Configure::applySpecSpecifics()
dictionary[ "GFX_DRIVERS" ] = "linuxfb";
dictionary[ "MOUSE_DRIVERS" ] = "pc linuxtp";
dictionary[ "OPENGL" ] = "no";
dictionary[ "EXCEPTIONS" ] = "no";
dictionary[ "DBUS"] = "no";
dictionary[ "QT_QWS_DEPTH" ] = "4 8 16 24 32";
dictionary[ "QT_SXE" ] = "no";
@ -1446,7 +1438,7 @@ bool Configure::displayHelp()
if (dictionary[ "HELP" ] == "yes") {
desc("Usage: configure\n"
"[-release] [-debug] [-debug-and-release] [-shared] [-static]\n"
"[-no-fast] [-fast] [-no-exceptions] [-exceptions]\n"
"[-no-fast] [-fast] \n"
"[-no-accessibility] [-accessibility] [-no-rtti] [-rtti]\n"
"[-no-sql-<driver>] [-qt-sql-<driver>]\n"
"[-plugin-sql-<driver>] [-system-sqlite]\n"
@ -1525,9 +1517,6 @@ bool Configure::displayHelp()
desc( "", qPrintable(QString(" %1").arg(defaultBuildParts.at(i))), false, ' ');
desc( "-nomake <part>", "Exclude part from the list of parts to be built.\n");
desc("EXCEPTIONS", "no", "-no-exceptions", "Disable exceptions on platforms that support it.");
desc("EXCEPTIONS", "yes","-exceptions", "Enable exceptions on platforms that support it.\n");
desc("WIDGETS", "no", "-no-widgets", "Disable QtWidgets module\n");
desc("ACCESSIBILITY", "no", "-no-accessibility", "Do not compile Windows Active Accessibility support.");
@ -2606,10 +2595,6 @@ void Configure::generateQConfigPri()
if (dictionary[ "LTCG" ] == "yes")
configStream << " ltcg";
if (dictionary[ "EXCEPTIONS" ] == "yes")
configStream << " exceptions";
if (dictionary[ "EXCEPTIONS" ] == "no")
configStream << " exceptions_off";
if (dictionary[ "RTTI" ] == "yes")
configStream << " rtti";
if (dictionary[ "SSE2" ] == "yes")
@ -2805,7 +2790,6 @@ void Configure::generateConfigfiles()
}
if (dictionary["ACCESSIBILITY"] == "no") qconfigList += "QT_NO_ACCESSIBILITY";
if (dictionary["EXCEPTIONS"] == "no") qconfigList += "QT_NO_EXCEPTIONS";
if (dictionary["WIDGETS"] == "no") qconfigList += "QT_NO_WIDGETS";
if (dictionary["OPENGL"] == "no") qconfigList += "QT_NO_OPENGL";
if (dictionary["OPENVG"] == "no") qconfigList += "QT_NO_OPENVG";
@ -3027,7 +3011,6 @@ void Configure::displayConfig()
cout << "Debug symbols..............." << (dictionary[ "BUILD" ] == "debug" ? "yes" : "no") << endl;
cout << "Link Time Code Generation..." << dictionary[ "LTCG" ] << endl;
cout << "Accessibility support......." << dictionary[ "ACCESSIBILITY" ] << endl;
cout << "Exception support..........." << dictionary[ "EXCEPTIONS" ] << endl;
cout << "RTTI support................" << dictionary[ "RTTI" ] << endl;
cout << "SSE2 support................" << dictionary[ "SSE2" ] << endl;
cout << "IWMMXT support.............." << dictionary[ "IWMMXT" ] << endl;