Compilers

qbs 1.1.0 released

Published Wednesday November 6th, 2013 | by

It’s been a while since qbs 1.0.0 has come out, and things have been adding up – time for qbs 1.1.0!

What’s newsworthy?

  • Projects can now be nested, making it very easy to embed a stand-alone project into another one.
  • Change tracking has improved a lot: We now catch more factors that (may) require parts of a project to be rebuilt, and on the other hand we also do less unnecessary re-builds. For future releases, we aim at more improvements in this area.
  • Due to more thorough checks for mistakes such as syntax errors in project files or missing information in profiles, we are able to provide more helpful error messages, which should make life considerably easier for users.
  • The API provides more information to IDEs, which enables better qbs project support in the upcoming Qt Creator 3.0.
  • A lot of documentation has been added, particularly for the project file language. This area was seriously lacking in the first release.
  • There is now a GUI application for editing profiles and other settings.

Of course, there have also been countless bugfixes and smaller improvements. In particular, we would like to thank Jake Petroules for his continuous efforts in making and keeping the OSX platform well-supported.

Where do I get it?

Source packages and a binary package for Windows can be found here.
Commercial customers can download the enterprise version of qbs from the Customer Portal.

Other resources

Wiki: http://qt-project.org/wiki/qbs
Documentation: http://doc-snapshot.qt-project.org/qbs
Bug tracker: https://bugreports.qt-project.org/browse/QBS
Mailing list: http://lists.qt-project.org/mailman/listinfo/qbs

19 Comments


Posted in Build system, Compilers, Releases

Using gcc’s 4.8.0 Address Sanitizer with Qt

Published Wednesday April 17th, 2013 | by

One of the cool new features of gcc 4.8 is the built in “Address Sanitizer”: a memory error detector for C/C++ that will tell you instantly when you e.g. access already deleted memory. This is actually a Google project from Clang/LLVM, so for LLVM users this might be old stuff, but it wasn’t for me :) Since documentation on every day use is still a bit scarce on the web, I’m dumping the gist of how to put it to good use here, especially in the Qt context …

How does it work?

It basically overwrites malloc and free, and does check the memory before every access (see the project wiki for the details). Apparently it does that in a very efficient manner, since the slow down is only about 2x compared to uninstrumented execution! Who knows, maybe we can enable it for the Qt-Project CI system at one point?

Be warned though that it only works so far on Linux and Mac. No luck for MinGW :(

How to enable it?

Since it is part of the compiler suite enabling it is easy: just add -fsanitize=address -fno-omit-frame-pointer to the compiler calls, and -fsanitize=address to the linker calls. Anyhow, to catch issues where the memory is allocated, de-allocated or accessed by Qt you do not only have to instrument your application, but also Qt. There’s a tentative patch for Qt 5.2 which makes this easy:

https://codereview.qt-project.org/#change,43420

It is scheduled for the dev branch (Qt 5.2) because it’s a new feature, but you should be fine cherry-picking it to e.g. Qt 5.0. You can then configure Qt with -address-sanitizer, and run qmake CONFIG+=address_sanitizer for your own applications.

If you don’t want to cherry-pick, you can also pass the additional command line arguments to qmake by explicitly setting QMAKE_CXXFLAGS, QMAKE_CFLAGS, and QMAKE_LFLAGS manually:

$ qmake QMAKE_CXXFLAGS+="-fsanitize=address -fno-omit-frame-pointer" \
QMAKE_CFLAGS+="-fsanitize=address -fno-omit-frame-pointer" \
QMAKE_LFLAGS+="-fsanitize=address"

How to use it?

Just run your application! If you happen to hit a memory issue it will abort, and show you a stack trace with module names and addresses. You will need a separate tool called asan_symbolize.py to get the symbols, and then maybe c++filt to de-mangle the C++ symbols.

Demo!

$ mkdir addresssanitizertest
$ echo '
#include <QDebug>
int main(int, char *[]) {
const char *str = QString("Evil!").toLocal8Bit().constData();
qDebug() << str;
}
' > addresssanitizertest/main.cpp
$ cd addresssanitizertest && qmake -project && qmake CONFIG+=address_sanitizer

$ ./addresssanitizertest 2>&1 | asan_symbolize.py | c++filt
=================================================================
==32195== ERROR: AddressSanitizer: heap-use-after-free on address 0x600c0000bcd8 at pc 0x4016ce bp 0x7fff7ccd86c0 sp 0x7fff7ccd86b8
READ of size 1 at 0x600c0000bcd8 thread T0
    #0 0x4016cd in QString::fromUtf8(char const*, int) /home/kkoehne/dev/qt/qt-5.1-gcc-4.8.0-64/qtbase/include/QtCore/../../../../qt-5.1/qtbase/src/corelib/tools/qstring.h:478
    #1 0x401b1e in QDebug::operator<<(char const*) /home/kkoehne/dev/qt/qt-5.1-gcc-4.8.0-64/qtbase/include/QtCore/../../../../qt-5.1/qtbase/src/corelib/io/qdebug.h:117
    #2 0x401282 in main /tmp/addresssanitizertest/main.cpp:6 (discriminator 1)
    #3 0x7fac5c1e3a14 in __libc_start_main ??:?
    #4 0x401118 in _start /home/abuild/rpmbuild/BUILD/glibc-2.17/csu/../sysdeps/x86_64/start.S:123
0x600c0000bcd8 is located 24 bytes inside of 64-byte region [0x600c0000bcc0,0x600c0000bd00)
freed by thread T0 here:
    #0 0x7fac5eab9c5a in __interceptor_free _asan_rtl_
    #1 0x7fac5d353e59 in QArrayData::deallocate(QArrayData*, unsigned long, unsigned long) /home/kkoehne/dev/qt/qt-5.1/qtbase/src/corelib/tools/qarraydata.cpp:125 (discriminator 2)
    #2 0x401c21 in QTypedArrayData::deallocate(QArrayData*) /home/kkoehne/dev/qt/qt-5.1-gcc-4.8.0-64/qtbase/include/QtCore/../../../../qt-5.1/qtbase/src/corelib/tools/qarraydata.h:230
    #3 0x401630 in QByteArray::~QByteArray() /home/kkoehne/dev/qt/qt-5.1-gcc-4.8.0-64/qtbase/include/QtCore/../../../../qt-5.1/qtbase/src/corelib/tools/qbytearray.h:396 (discriminator 1)
    #4 0x401231 in main /tmp/addresssanitizertest/main.cpp:5 (discriminator 1)
    #5 0x7fac5c1e3a14 in __libc_start_main ??:?
previously allocated by thread T0 here:
    #0 0x7fac5eab9e7f in __interceptor_realloc _asan_rtl_
    #1 0x7fac5d35944e in QByteArray::reallocData(unsigned int, QFlags) /home/kkoehne/dev/qt/qt-5.1/qtbase/src/corelib/tools/qbytearray.cpp:1472
    #2 0x7fac5d358d05 in QByteArray::resize(int) /home/kkoehne/dev/qt/qt-5.1/qtbase/src/corelib/tools/qbytearray.cpp:1431
    #3 0x7fac5d77e452 in QUtf8::convertFromUnicode(QChar const*, int, QTextCodec::ConverterState*) /home/kkoehne/dev/qt/qt-5.1/qtbase/src/corelib/codecs/qutfcodec.cpp:130
    #4 0x7fac5d780e91 in QUtf8Codec::convertFromUnicode(QChar const*, int, QTextCodec::ConverterState*) const /home/kkoehne/dev/qt/qt-5.1/qtbase/src/corelib/codecs/qutfcodec.cpp:507
    #5 0x7fac5d77a483 in QTextCodec::fromUnicode(QString const&) const /home/kkoehne/dev/qt/qt-5.1/qtbase/src/corelib/codecs/qtextcodec.cpp:807
    #6 0x7fac5d48dd26 in QString::toLocal8Bit() const /home/kkoehne/dev/qt/qt-5.1/qtbase/src/corelib/tools/qstring.cpp:4020
    #7 0x401215 in main /tmp/addresssanitizertest/main.cpp:5
    #8 0x7fac5c1e3a14 in __libc_start_main ??:?
Shadow bytes around the buggy address:
  0x0c01ffff9740: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c01ffff9750: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c01ffff9760: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c01ffff9770: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c01ffff9780: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c01ffff9790: fa fa fa fa fa fa fa fa fd fd fd[fd]fd fd fd fd
  0x0c01ffff97a0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
  0x0c01ffff97b0: 00 00 00 00 00 00 00 fa fa fa fa fa 00 00 00 00
  0x0c01ffff97c0: 00 00 00 fa fa fa fa fa 00 00 00 00 00 00 00 fa
  0x0c01ffff97d0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
  0x0c01ffff97e0: 00 00 00 00 00 00 01 fa fa fa fa fa 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:     fa
  Heap righ redzone:     fb
  Freed Heap region:     fd
  Stack left redzone:    f1
  Stack mid redzone:     f2
  Stack right redzone:   f3
  Stack partial redzone: f4
  Stack after return:    f5
  Stack use after scope: f8
  Global redzone:        f9
  Global init order:     f6
  Poisoned by user:      f7
  ASan internal:         fe
==32195== ABORTING

Have fun hunting down memory issues :)

Update: Apparently a stock gcc 4.8.0 has still issues with address-sanitizer: libasan isn’t linked automatically, an internal compiler error in qtbase … I’m personally using a gcc from 4.8 branch.

19 Comments


Posted in Build system, C++, Compilers, Debugging, Qt | Tags: , , , ,

Qt 5.0.1 Released

Published Thursday January 31st, 2013 | by

It’s been six weeks since we published the Qt 5.0.0 release and we are now introducing Qt 5.0.1 – the first patch release. Qt 5.0.0 release has been well received and we have seen a great amount of interest towards it.

With over 400 improvements compared to Qt 5.0.0 the Qt 5.0.1 is a great next step for the Qt 5 series. As a patch release it does not introduce new functionality, just error corrections and improvements. In addition to these, it also adds MinGW 4.7 pre-built binary installer, which has been highly requested. MinGW is the first but not the last new pre-built binary installer which we are going to bring along on later Qt 5.0.x releases.

For detailed list of changes in Qt 5.0.1, please have a look into the changes file included to each module – or check the three most important ones: qtbaseqtdeclarative and qtmultimedia.

As always, Qt 5.0.1 maintains both forward and backward source compatibility with Qt 5.0.0. However, to fix a bug we detected after the Qt 5.0.0 release, this release has a limited binary compatibility break related to multimedia functionality (please see details from here). We therefore recommend all users to recompile their applications that provided QtMultimedia plugins or dealt with them directly. This is an exceptional case: binary compatibility will be kept for further releases.

As with every release, also this one has a few issues left that we know about. We are continuously ironing out the glitches and improving quality with every new release. If you encounter a problem, please check the known issues page first, where you can find solutions and workarounds for common problems. If you find any other bug in Qt 5, please help us to improve the product in future releases by reporting it to bugreports.qt-project.org, or contact us via our Customer Portal if you have a commercial license.

Qt 5.0.1 is now tagged in the Qt Project repository. The source packages and installers for Qt 5.0.1 are available for download at qt-project.org/downloads for open-source users, as well as via the Customer Portal for commercial licensees.

99 Comments


Posted in Compilers, News, Qt, Releases

Getting more out of Qt on Windows Embedded Compact 7 & ARM processors

Published Tuesday January 29th, 2013 | by

At the moment most of the buzz is probably around Qt5, but it is good to remember that Qt4 is still alive. While we are working to increase platform coverage on Qt5, there are still some platforms that are officially supported by Digia only with the Qt4 codebase. One of those platforms is Windows Embedded Compact 7. In this blog post I wanted to share with you a small tip that can bring you big performance benefits on Windows Embedded Compact 7.

Windows Embedded Compact 7 is tied to Visual Studio 2008, and if you are targeting an ARM based device you might have realized that the Visual Studio 2008 toolchain only supports ARMV4 and ARVM4i instruction sets for ARM architecture. Due to this limitation, Qt mkspecs for Windows Embedded Compact 7 defaults to ARMV4i instruction set. However, there also exists a version of the Visual Studio 2008 compiler which can generate code for more recent ARM instruction sets and CPU cores. This compiler is included in the Platform Builder (the tool used to generate Windows Embedded Compact 7 OS images and SDKs). If you have Platform Builder installed, you can build Qt for ARMv7 instruction set and also benefit from the more advanced floating point units of the latest CPU cores. To build Qt 4.8.x with ARMV7 instruction set and to use the latest floating point instructions supported by ARM you can do the following:

In the mkspec you are using for WEC7 ARM build, change the value of CE_ARCH variable from armv4i to armv7, and add the following code block there:

QMAKE_CFLAGS    += -QRarch7 -arch:VFPv3-D32 -QRfpe-
QMAKE_CXXFLAGS   = $$QMAKE_CFLAGS

Then make sure that you have the cl.exe from platform builder (c:\WINCE700\SDK\BIN\i386\ARM) in your path before visual studio 2008, and just reconfigure and build Qt and your Qt application. That’s it – now just enjoy the better performance!

For more detailed information about the different Visual Studio 2008 compiler versions, and the options used for QMAKE_CFLAGS, please check the paper written by Adeneo Embedded. With the upcoming Windows Embedded 2013, Microsoft has also updated the Windows Embedded Compact toolchain to Visual Studio 2012.

12 Comments


Posted in Build system, Compilers, Embedded, Performance, Qt

Visual Studio Add-In 1.2.0 for Qt 5 Released

Published Wednesday December 19th, 2012 | by

This week we released Qt 5.0 with Qt Creator integrated into the package. Today I have good news for those who prefer to use Visual Studio. We have now released new Visual Studio Add-In 1.2.0 for Qt 5. In addition to supporting Qt 5 it provides some additional goodies such as support to Visual Studio 2012.

The new Visual Studio Add-In 1.2.0 supports Visual Studio 2012, 2010 and 2008 for developing Qt 5 applications. It understands the new modularized structure of Qt 5, and includes the new documentation. Functionality and requirements are otherwise similar as with the previous Add-In, so you will need at least Visual Studio Professional to use it.

Highlights of Visual Studio Add-In 1.2.0 include:

  • Project creation wizards updated to follow Qt 5 module structure
  • Project settings form updated to follow Qt 5 module structure
  • Help documents updated to Qt 5.0
  • Support for Visual Studio 2012, 2010 and 2008
  • Parameter passing to lupdate fixed (QTVSADDINBUG-131)

You can find the detailed list of changes to the Visual Studio Add-In 1.2.0 here.

One thing to note is that there is no Qt 4 project creation wizards and project settings in the Qt 5 Visual Studio Add-In, and unfortunately it is currently not possible to use both the Qt 4 and Qt 5 Visual Studio Add-Ins simultaneously. We plan to release an updated version of the Qt 4 Add-In during Q1/13 to address this issue.

The new Visual Studio Add-In 1.2.0 is available for both commercial and open-source users. If you hold a valid commercial license, you can download the new Visual Studio Add-In from the Customer Portal. The open-source version can be downloaded from the Qt Project.

I hope you enjoy developing Qt 5 applications with Visual Studio. Please provide us with feedback either through the commercial support or via the Qt Project mailing lists.

PS. I changed the release date visible in the blog so that Qt 5.0.0 stays at the top. The real date of this release is 21st December 2012.

 

36 Comments


Posted in Announcements, Compilers, desktop, Qt, Windows | Tags:

LALR(1) and Trolltech’s Creative Fridays

Published Friday March 9th, 2007 | by

If you followed labs.trolltech.com, you’ve seen a new addition: QLALR. It’s a LALR(1) parser generator, created by Roberto Raggi of Qt Designer and KDevelop fame. Originally developed as Creative Friday project, it quickly got used in various projects within Trolltech. One example is the new script engine – no surprise, Roberto also had his fingers in this one – but also the new XML stream-reader. Writing a fast bottom-up XML parser was a welcome challenge, and with the flexibility of QLALR actually an enjoyable ride.

QLALR is not very well documented, but if you do understand LALR(1) and have used tools like yacc before, you should get along well with the examples. Admittingly, knowing Roberto has also helped. For the lexer, you can use QLALR with whatever scanner generator you like, or you handcraft it. I’ve also seen a few scanner generators in Trolltech, maybe one will make it on labs some day.

Btw, the last link demonstrates another new feature of our web site: we finally have the snapshot documentation online, regenerated from the source code repository daily.

1 Comment


Posted in Compilers, Labs, News, QLALR, Qt