Bug#876901: QFINDTESTDATA uses __FILE__

Ximin Luo infinity0 at debian.org
Thu Nov 16 13:22:00 UTC 2017

Lisandro Damián Nicanor Pérez Meyer:
> [..]
> Yes, we do understand that your workaround solves the issue, but we do also 
> understand that we should not be using this workaround in the first place.
> Guillem: the thread is long, but be sure that we Qt/KDE maintainers consider 
> that this change will be insta-RC I'm afraid.

Guillem: the TL;DR is that some QT tests fail (with our reproducibility GCC and dpkg patch) because they depend on __FILE__ to point to a real path, but the patched dpkg rewrites it in all packages so that a prefix $PWD changes to $srcpkg-$version, which doesn't exist.

A simple fix on the dpkg side would be to instead rewrite $PWD to ".", much like -fdebug-prefix-map is done currently. However this loses some information and makes it hard to distinguish different packages that might share filetree structure. But that is the best fallback option IMO, if we decide that we don't want to auto-break QT tests for using  __FILE__ (IMO, inappropriately).

> Xi: you have found a *wonderful* way to find where bugs are, please try to fix 
> the relevant code and not paper over it, because in the Qt case it is not a 
> bug on our side.

I pointed to the various C standards documents, as well as documentation from multiple compilers, stating that __FILE__ is the "name of the source file" and in no way guarantees that the expansion can later be re-used as the path to an actual file. GCC documentation even explicitly states the expansion is arbitrarily chosen by the implementation of the preprocessor, and is explicitly "not [..] the input file name argument".

So I do consider this a bug in the QT test suite.

The ideal solution would be to not use __FILE__ - that has numerous other benefits as well. But if this is too complex to change, I also suggested a 1-line addition to d/rules - which I agree would be "papering over" the issue. However, it's a simple 1-line change so I don't understand why there is so much resistance to it.

There are several other possible solutions, all of which are low-cost and unintrusive, and could be done in a QT build helper in one single place:

- define a custom macro, QT_TEST_SOURCE_BASE, and set that in the test build scripts, instead of using __FILE__
- symlink "$srcpkg-$version" -> "."

I would be very happy to send you the patches myself if you don't want to do the work, since writing 1-line patches to a few QT projects, costs far less time than patching 1800 packages across Debian.


GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE

More information about the Reproducible-builds mailing list