[Interest] tst_qatomicinteger build failure (5.9 i386/x86_64)

Constantin Makshin cmakshin at gmail.com
Fri Sep 1 17:10:18 CEST 2017


Hi Christian.

May be changing

template <typename T>
class QBasicAtomicInteger

in "src/corelib/thread/qbasicatomic.h" to

template <typename T>
class Q_DECL_ALIGN(Q_ALIGNOF(typename QAtomicOps<T>::Type))
QBasicAtomicInteger

will fix the problem.

On 09/01/2017 11:10 AM, Christian Gagneraud wrote:
> On 1 September 2017 at 19:21, Christian Gagneraud <chgans at gmail.com> wrote:
>> On 1 September 2017 at 18:37, Christian Gagneraud <chgans at gmail.com> wrote:
>>> Hi there,
>>>
>>> Back on my 32 bits build of Qt
>>>
>>> I'm having a build failure on tst_qatomicinteger for qlonglong.
>>>
>>> Static failure: Q_STATIC_ASSERT(Q_ALIGNOF(QAtomicInteger<T>) ==
>>> Q_ALIGNOF(TypeInStruct));
>>>
>>> Sounds very much like a 32/64 bits issue.
>>
>> Actually i have more test build failure:
>>
>> 2 about qlonglong and qulonglong, and a bunch of other that look like
>> this (simple) one:
>>
>> g++ -m32 -Wl,-O1 -fuse-ld=gold -Wl,--enable-new-dtags
>> -Wl,-rpath,/home/krys/Projects/qt5/qtbase/lib -o tst_qline
>> .obj/tst_qline.o   -lm -L/home/krys/Projects/qt5/qtbase/lib -lQt5Test
>> -lQt5Core -lpthread
>> .obj/tst_qline.o(.qtversion+0x0): error: unexpected reloc 3 against
>> global symbol qt_version_tag without base register in object file when
>> generating a position-independent output file
>> collect2: error: ld returned 1 exit status
>>
>> Should I disabled the gold linker? I've heard of problems with it
>> while cross building Qt...
> 
> OK, so disabling the gold linker fixed the weird symbols issues.
> 
> So I'm down to only 2 build failure, static asserts about alignment of
> QAtomicInteger using qlonglong and qulonglong
> 
> Looking at tst_qatomicinteger.cpp
> 
> I'm passing the first static assert:
>     Q_STATIC_ASSERT(sizeof(QAtomicInteger<T>) == sizeof(T));
> 
> But fail the second one:
>     Q_STATIC_ASSERT(Q_ALIGNOF(QAtomicInteger<T>) == Q_ALIGNOF(TypeInStruct));
> 
> TypeInStruct is, as the name suggest, as simple as a variable of the
> tested type inside a struct:
> struct TypeInStruct { TEST_TYPE type; };
> 
> So QAtomicInteger<qlonglong> has the same size as qlonglong, but not
> the same alignment!?!
> 
> Looking at qglobal.h, i've found this interesting piece of code:
>     // x86 ABI weirdness
>     // Alignment of naked type is 8, but inside struct has alignment 4.
>     template <> struct AlignOf<double>  :
> AlignOf_WorkaroundForI386Abi<double> {};
>     template <> struct AlignOf<qint64>  :
> AlignOf_WorkaroundForI386Abi<qint64> {};
>     template <> struct AlignOf<quint64> :
> AlignOf_WorkaroundForI386Abi<quint64> {};
> 
> And my Qt configure says:
> [...]
> Checking for target architecture... i386s
> [...]
> Checking for 64 bit atomics... yes
> [...]
> 
> So does that mean that QAtomicInteger is broken or cannot be used on linux-32 ?
> Which by the way is not supported anymore since Qt-5.6...
> 
> Any insight, comment or suggestion on how to get that fixed are very welcome! ;)
> 
> Thanks,
> Chris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 862 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170901/5acde918/attachment.sig>


More information about the Interest mailing list