cellist
cellist

Reputation: 1

AIX: C++ application with shared Qt5Core lib dependency has thread-local-storage runtime issue

I am on IBM AIX-7.2 and have this sample C++ code:

#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QDateTime>
#include <cstring>

int main(int argc, char *argv[]) {
    QCoreApplication app(argc, argv);

    char const* utf8Str = "Logging output using Qt5Core";
    QString       logMe = QString::fromUtf8(utf8Str, std::strlen(utf8Str));

    // Get the current date and time
    QDateTime currentDateTime = QDateTime::currentDateTime();

    // Format the date and time as a string
    QString timeStamp = currentDateTime.toString("yyyy-MM-dd hh:mm:ss.zzz");

    // Output the log message with the time stamp
    qDebug() << "[" << timeStamp << "]" << logMe;

    app.exit();
    return 0;
}

to test with Qt5. However, I always get a run-time error:

        0509-187 The local-exec model was used for thread-local
                   storage, but the module is not the main program.
        0509-193 Examine the .loader section header with the
                 'dump -Hv' command.

no matter which tls-model option is use for that application. I am using gcc-11 on AIX (unfortunately, I cannot use gnu-ld, but the IBM ld only), and I also tried the different tls-models when compiling QT5 itself from source.

For reference, I checked the manual page of gcc-11, as well as the following hints: about thread local storage IBM guide on tls

I would appreciate any more pointers or hints, as I am out of ideas right now ...

I tried the following (always with -maix64, so 64bit-mode):

  1. provide TLS models via -ftls-model= to the compilation of the app
  2. same for building Qt5 itself
  3. different combinations of -f[no-]pic, -fpie, -fPIC, -f[no-]extern-tls-init
  4. -D_THREAD_SAFE yes/no
  5. -Wl,-bbigtls or -Wl,-bbigtoc

Upvotes: 0

Views: 71

Answers (1)

Lorinczy Zsigmond
Lorinczy Zsigmond

Reputation: 1910

This problem occurs if you compile shared objects without compiler-flags -fPIC -DPIC. Also -pthread flag should be used at every compilation and linkage step.

Upvotes: 0

Related Questions