~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/plugins/projectexplorer/gcctoolchain.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-12-02 09:16:15 UTC
  • mfrom: (1.1.29)
  • Revision ID: timo.jyrinki@canonical.com-20131202091615-xbj1os1f604ber1m
New upstream release candidate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
    return data;
112
112
}
113
113
 
 
114
static const QStringList gccPredefinedMacrosOptions()
 
115
{
 
116
    return QStringList() << QLatin1String("-xc++") << QLatin1String("-E") << QLatin1String("-dM");
 
117
}
 
118
 
114
119
static QByteArray gccPredefinedMacros(const FileName &gcc, const QStringList &args, const QStringList &env)
115
120
{
116
 
    QStringList arguments;
117
 
    arguments << QLatin1String("-xc++")
118
 
              << QLatin1String("-E")
119
 
              << QLatin1String("-dM");
120
 
    foreach (const QString &a, args) {
121
 
        if (a == QLatin1String("-m128bit-long-double") || a == QLatin1String("-m32")
122
 
                || a == QLatin1String("-m3dnow") || a == QLatin1String("-m3dnowa")
123
 
                || a == QLatin1String("-m64") || a == QLatin1String("-m96bit-long-double")
124
 
                || a == QLatin1String("-mabm") || a == QLatin1String("-maes")
125
 
                || a.startsWith(QLatin1String("-march=")) || a == QLatin1String("-mavx")
126
 
                || a.startsWith(QLatin1String("-masm=")) || a == QLatin1String("-mcx16")
127
 
                || a == QLatin1String("-mfma") || a == QLatin1String("-mfma4")
128
 
                || a == QLatin1String("-mlwp") || a == QLatin1String("-mpclmul")
129
 
                || a == QLatin1String("-mpopcnt") || a == QLatin1String("-msse")
130
 
                || a == QLatin1String("-msse2") || a == QLatin1String("-msse2avx")
131
 
                || a == QLatin1String("-msse3") || a == QLatin1String("-msse4")
132
 
                || a == QLatin1String("-msse4.1") || a == QLatin1String("-msse4.2")
133
 
                || a == QLatin1String("-msse4a") || a == QLatin1String("-mssse3")
134
 
                || a.startsWith(QLatin1String("-mtune=")) || a == QLatin1String("-mxop")
135
 
                || a == QLatin1String("-Os") || a == QLatin1String("-O0") || a == QLatin1String("-O1")
136
 
                || a == QLatin1String("-O2") || a == QLatin1String("-O3")
137
 
                || a == QLatin1String("-ffinite-math-only") || a == QLatin1String("-fshort-double")
138
 
                || a == QLatin1String("-fshort-wchar") || a == QLatin1String("-fsignaling-nans")
139
 
                || a == QLatin1String("-fno-inline") || a == QLatin1String("-fno-exceptions")
140
 
                || a == QLatin1String("-fstack-protector") || a == QLatin1String("-fstack-protector-all")
141
 
                || a == QLatin1String("-fsanitize=address") || a == QLatin1String("-fno-rtti")
142
 
                || a.startsWith(QLatin1String("-std=")) || a.startsWith(QLatin1String("-stdlib="))
143
 
                || a.startsWith(QLatin1String("-specs="))
144
 
                || a == QLatin1String("-ansi") || a == QLatin1String("-undef")
145
 
                || a.startsWith(QLatin1String("-D")) || a.startsWith(QLatin1String("-U"))
146
 
                || a == QLatin1String("-fopenmp") || a == QLatin1String("-Wno-deprecated"))
147
 
            arguments << a;
148
 
    }
149
 
 
 
121
    QStringList arguments = args;
150
122
    arguments << QLatin1String("-");
151
123
 
152
124
    QByteArray predefinedMacros = runGcc(gcc, arguments, env);
153
125
    // Sanity check in case we get an error message instead of real output:
154
 
    QTC_CHECK(predefinedMacros.startsWith("#define "));
 
126
    QTC_CHECK(predefinedMacros.isNull() || predefinedMacros.startsWith("#define "));
155
127
    if (Utils::HostOsInfo::isMacHost()) {
156
128
        // Turn off flag indicating Apple's blocks support
157
129
        const QByteArray blocksDefine("#define __BLOCKS__ 1");
169
141
 
170
142
const int GccToolChain::PREDEFINED_MACROS_CACHE_SIZE = 16;
171
143
 
172
 
QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &args,
173
 
                                               const QStringList &env, const FileName &sysrootPath)
 
144
QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &arguments,
 
145
                                               const QStringList &env)
174
146
{
175
147
    QList<HeaderPath> systemHeaderPaths;
176
 
    QStringList arguments;
177
 
    if (!sysrootPath.isEmpty())
178
 
        arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath.toString()));
179
 
    foreach (const QString &a, args) {
180
 
        if (a.startsWith(QLatin1String("-stdlib=")))
181
 
            arguments << a;
182
 
    }
183
 
 
184
 
    arguments << QLatin1String("-xc++")
185
 
              << QLatin1String("-E")
186
 
              << QLatin1String("-v")
187
 
              << QLatin1String("-");
188
 
 
189
148
    QByteArray line;
190
149
    QByteArray data = runGcc(gcc, arguments, env);
191
150
    QBuffer cpp(&data);
238
197
    Abi::BinaryFormat format = guessed.binaryFormat();
239
198
    int width = guessed.wordWidth();
240
199
 
241
 
    if (os == Abi::MacOS && arch != Abi::ArmArchitecture) {
 
200
    if (macros.contains("#define __SIZEOF_SIZE_T__ 8"))
 
201
        width = 64;
 
202
    else if (macros.contains("#define __SIZEOF_SIZE_T__ 4"))
 
203
        width = 32;
 
204
 
 
205
    if (os == Abi::MacOS) {
242
206
        // Apple does PPC and x86!
243
207
        abiList << Abi(arch, os, flavor, format, width);
244
208
        abiList << Abi(arch, os, flavor, format, width == 64 ? 32 : 64);
245
 
        abiList << Abi(arch == Abi::X86Architecture ? Abi::PowerPCArchitecture : Abi::X86Architecture, os, flavor, format, width);
246
 
        abiList << Abi(arch == Abi::X86Architecture ? Abi::PowerPCArchitecture : Abi::X86Architecture, os, flavor, format, width == 64 ? 32 : 64);
247
209
    } else if (arch == Abi::X86Architecture && (width == 0 || width == 64)) {
248
 
        if (macros.contains("#define __x86_64 1"))
249
 
            abiList << Abi(arch, os, flavor, format, 64);
 
210
        abiList << Abi(arch, os, flavor, format, 64);
250
211
        abiList << Abi(arch, os, flavor, format, 32);
251
212
    } else {
252
213
        abiList << Abi(arch, os, flavor, format, width);
255
216
}
256
217
 
257
218
static QList<Abi> guessGccAbi(const FileName &path, const QStringList &env,
 
219
                              const QByteArray &macros,
258
220
                              const QStringList &extraArgs = QStringList())
259
221
{
260
222
    if (path.isEmpty())
265
227
    QString machine = QString::fromLocal8Bit(runGcc(path, arguments, env)).trimmed();
266
228
    if (machine.isEmpty())
267
229
        return QList<Abi>(); // no need to continue if running failed once...
268
 
    QByteArray macros = gccPredefinedMacros(path, QStringList(), env);
269
230
    return guessGccAbi(machine, macros);
270
231
}
271
232
 
297
258
    m_version(tc.m_version)
298
259
{ }
299
260
 
 
261
void GccToolChain::setMacroCache(const QStringList &allCxxflags, const QByteArray &macros) const
 
262
{
 
263
    if (macros.isNull())
 
264
        return;
 
265
 
 
266
    CacheItem runResults;
 
267
    QByteArray data = macros;
 
268
    runResults.first = allCxxflags;
 
269
    if (macros.isNull())
 
270
        data = QByteArray("");
 
271
    runResults.second = data;
 
272
 
 
273
    m_predefinedMacros.push_back(runResults);
 
274
    if (m_predefinedMacros.size() > PREDEFINED_MACROS_CACHE_SIZE)
 
275
        m_predefinedMacros.pop_front();
 
276
}
 
277
 
 
278
QByteArray GccToolChain::macroCache(const QStringList &allCxxflags) const
 
279
{
 
280
    for (GccCache::iterator it = m_predefinedMacros.begin(); it != m_predefinedMacros.end(); ++it) {
 
281
        if (it->first == allCxxflags) {
 
282
            // Increase cached item priority
 
283
            CacheItem pair = *it;
 
284
            m_predefinedMacros.erase(it);
 
285
            m_predefinedMacros.push_back(pair);
 
286
 
 
287
            return pair.second;
 
288
        }
 
289
    }
 
290
    return QByteArray();
 
291
}
 
292
 
300
293
QString GccToolChain::defaultDisplayName() const
301
294
{
302
295
    if (!m_targetAbi.isValid())
370
363
QByteArray GccToolChain::predefinedMacros(const QStringList &cxxflags) const
371
364
{
372
365
    QStringList allCxxflags = m_platformCodeGenFlags + cxxflags;  // add only cxxflags is empty?
373
 
    typedef QPair<QStringList, QByteArray> CacheItem;
374
 
 
375
 
    for (GccCache::iterator it = m_predefinedMacros.begin(); it != m_predefinedMacros.end(); ++it)
376
 
        if (it->first == allCxxflags) {
377
 
            // Increase cached item priority
378
 
            CacheItem pair = *it;
379
 
            m_predefinedMacros.erase(it);
380
 
            m_predefinedMacros.push_back(pair);
381
 
 
382
 
            return pair.second;
383
 
        }
384
 
 
385
 
    CacheItem runResults;
386
 
    runResults.first = allCxxflags;
 
366
 
 
367
    QByteArray macros = macroCache(allCxxflags);
 
368
    if (!macros.isNull())
 
369
        return macros;
387
370
 
388
371
    // Using a clean environment breaks ccache/distcc/etc.
389
372
    Environment env = Environment::systemEnvironment();
390
373
    addToEnvironment(env);
391
 
    runResults.second = gccPredefinedMacros(m_compilerCommand, allCxxflags, env.toStringList());
392
 
 
393
 
    m_predefinedMacros.push_back(runResults);
394
 
    if (m_predefinedMacros.size() > PREDEFINED_MACROS_CACHE_SIZE)
395
 
        m_predefinedMacros.pop_front();
396
 
 
397
 
    return runResults.second;
 
374
    QStringList arguments = gccPredefinedMacrosOptions();
 
375
    for (int iArg = 0; iArg < allCxxflags.length(); ++iArg) {
 
376
        const QString &a = allCxxflags.at(iArg);
 
377
        if (a == QLatin1String("-arch") || a == QLatin1String("-sysroot")
 
378
                || a == QLatin1String("-isysroot")) {
 
379
            if (++iArg < allCxxflags.length())
 
380
                arguments << a << allCxxflags.at(iArg);
 
381
        } else if (a == QLatin1String("-m128bit-long-double") || a == QLatin1String("-m32")
 
382
                || a == QLatin1String("-m3dnow") || a == QLatin1String("-m3dnowa")
 
383
                || a == QLatin1String("-m64") || a == QLatin1String("-m96bit-long-double")
 
384
                || a == QLatin1String("-mabm") || a == QLatin1String("-maes")
 
385
                || a.startsWith(QLatin1String("-march=")) || a == QLatin1String("-mavx")
 
386
                || a.startsWith(QLatin1String("-masm=")) || a == QLatin1String("-mcx16")
 
387
                || a == QLatin1String("-mfma") || a == QLatin1String("-mfma4")
 
388
                || a == QLatin1String("-mlwp") || a == QLatin1String("-mpclmul")
 
389
                || a == QLatin1String("-mpopcnt") || a == QLatin1String("-msse")
 
390
                || a == QLatin1String("-msse2") || a == QLatin1String("-msse2avx")
 
391
                || a == QLatin1String("-msse3") || a == QLatin1String("-msse4")
 
392
                || a == QLatin1String("-msse4.1") || a == QLatin1String("-msse4.2")
 
393
                || a == QLatin1String("-msse4a") || a == QLatin1String("-mssse3")
 
394
                || a.startsWith(QLatin1String("-mtune=")) || a == QLatin1String("-mxop")
 
395
                || a == QLatin1String("-Os") || a == QLatin1String("-O0") || a == QLatin1String("-O1")
 
396
                || a == QLatin1String("-O2") || a == QLatin1String("-O3")
 
397
                || a == QLatin1String("-ffinite-math-only") || a == QLatin1String("-fshort-double")
 
398
                || a == QLatin1String("-fshort-wchar") || a == QLatin1String("-fsignaling-nans")
 
399
                || a == QLatin1String("-fno-inline") || a == QLatin1String("-fno-exceptions")
 
400
                || a == QLatin1String("-fstack-protector") || a == QLatin1String("-fstack-protector-all")
 
401
                || a == QLatin1String("-fsanitize=address") || a == QLatin1String("-fno-rtti")
 
402
                || a.startsWith(QLatin1String("-std=")) || a.startsWith(QLatin1String("-stdlib="))
 
403
                || a.startsWith(QLatin1String("-specs="))
 
404
                || a == QLatin1String("-ansi") || a == QLatin1String("-undef")
 
405
                || a.startsWith(QLatin1String("-D")) || a.startsWith(QLatin1String("-U"))
 
406
                || a == QLatin1String("-fopenmp") || a == QLatin1String("-Wno-deprecated"))
 
407
            arguments << a;
 
408
    }
 
409
    macros = gccPredefinedMacros(m_compilerCommand, reinterpretOptions(arguments),
 
410
                                 env.toStringList());
 
411
 
 
412
    setMacroCache(allCxxflags, macros);
 
413
    return macros;
398
414
}
399
415
 
400
416
/**
501
517
        // Using a clean environment breaks ccache/distcc/etc.
502
518
        Environment env = Environment::systemEnvironment();
503
519
        addToEnvironment(env);
504
 
        m_headerPaths = gccHeaderPaths(m_compilerCommand, m_platformCodeGenFlags + cxxflags , // add only cxxflags is empty?
505
 
                                       env.toStringList(), sysRoot);
 
520
        // Prepare arguments
 
521
        QStringList arguments;
 
522
        if (!sysRoot.isEmpty())
 
523
            arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysRoot.toString()));
 
524
 
 
525
        QStringList flags;
 
526
        flags << m_platformCodeGenFlags << cxxflags;
 
527
        foreach (const QString &a, flags) {
 
528
            if (a.startsWith(QLatin1String("-stdlib=")))
 
529
                arguments << a;
 
530
        }
 
531
 
 
532
        arguments << QLatin1String("-xc++")
 
533
                  << QLatin1String("-E")
 
534
                  << QLatin1String("-v")
 
535
                  << QLatin1String("-");
 
536
 
 
537
        m_headerPaths = gccHeaderPaths(m_compilerCommand, reinterpretOptions(arguments), env.toStringList());
506
538
    }
507
539
    return m_headerPaths;
508
540
}
699
731
{
700
732
    Environment env = Environment::systemEnvironment();
701
733
    addToEnvironment(env);
702
 
    return guessGccAbi(m_compilerCommand, env.toStringList(), platformCodeGenFlags());
 
734
    QByteArray macros = predefinedMacros(QStringList());
 
735
    return guessGccAbi(m_compilerCommand, env.toStringList(), macros, platformCodeGenFlags());
703
736
}
704
737
 
705
738
QString GccToolChain::detectVersion() const
778
811
        return result;
779
812
 
780
813
    GccToolChain::addCommandPathToEnvironment(compilerPath, systemEnvironment);
781
 
    QList<Abi> abiList = guessGccAbi(compilerPath, systemEnvironment.toStringList());
 
814
    QByteArray macros
 
815
            = gccPredefinedMacros(compilerPath, gccPredefinedMacrosOptions(), systemEnvironment.toStringList());
 
816
    QList<Abi> abiList = guessGccAbi(compilerPath, systemEnvironment.toStringList(), macros);
782
817
    if (!abiList.contains(requiredAbi)) {
783
818
        if (requiredAbi.wordWidth() != 64
784
819
                || !abiList.contains(Abi(requiredAbi.architecture(), requiredAbi.os(), requiredAbi.osFlavor(),
788
823
 
789
824
    foreach (const Abi &abi, abiList) {
790
825
        QScopedPointer<GccToolChain> tc(createToolChain(true));
 
826
        tc->setMacroCache(QStringList(), macros);
791
827
        if (tc.isNull())
792
828
            return result;
793
829
 
850
886
    tc->setDisplayName(displayName); // reset display name
851
887
    tc->setPlatformCodeGenFlags(splitString(m_platformCodeGenFlagsLineEdit->text()));
852
888
    tc->setPlatformLinkerFlags(splitString(m_platformLinkerFlagsLineEdit->text()));
 
889
    tc->setMacroCache(tc->platformCodeGenFlags(), m_macros);
853
890
}
854
891
 
855
892
void GccToolChainConfigWidget::setFromToolchain()
902
939
 
903
940
void GccToolChainConfigWidget::handleCompilerCommandChange()
904
941
{
 
942
    bool haveCompiler = false;
 
943
    Abi currentAbi = m_abiWidget->currentAbi();
 
944
    bool customAbi = m_abiWidget->isCustomAbi();
905
945
    FileName path = m_compilerCommand->fileName();
906
946
    QList<Abi> abiList;
907
 
    bool haveCompiler = false;
 
947
 
908
948
    if (!path.isEmpty()) {
909
949
        QFileInfo fi(path.toFileInfo());
910
950
        haveCompiler = fi.isExecutable() && fi.isFile();
912
952
    if (haveCompiler) {
913
953
        Environment env = Environment::systemEnvironment();
914
954
        GccToolChain::addCommandPathToEnvironment(path, env);
915
 
        abiList = guessGccAbi(path, env.toStringList(),
 
955
        QStringList args = gccPredefinedMacrosOptions() + splitString(m_platformCodeGenFlagsLineEdit->text());
 
956
        m_macros = gccPredefinedMacros(path, args, env.toStringList());
 
957
        abiList = guessGccAbi(path, env.toStringList(), m_macros,
916
958
                              splitString(m_platformCodeGenFlagsLineEdit->text()));
917
959
    }
918
960
    m_abiWidget->setEnabled(haveCompiler);
919
 
    Abi currentAbi = m_abiWidget->currentAbi();
920
 
    m_abiWidget->setAbis(abiList, abiList.contains(currentAbi) ? currentAbi : Abi());
 
961
 
 
962
    // Find a good ABI for the new compiler:
 
963
    Abi newAbi;
 
964
    if (customAbi)
 
965
        newAbi = currentAbi;
 
966
    else if (abiList.contains(currentAbi))
 
967
        newAbi = currentAbi;
 
968
 
 
969
    m_abiWidget->setAbis(abiList, newAbi);
921
970
    emit dirty();
922
971
}
923
972
 
1008
1057
    if (abi.os() == Abi::MacOS)
1009
1058
        return QList<FileName>()
1010
1059
                << FileName::fromString(QLatin1String("macx-clang"))
 
1060
                << FileName::fromString(QLatin1String("macx-clang-32"))
1011
1061
                << FileName::fromString(QLatin1String("unsupported/macx-clang"))
1012
1062
                << FileName::fromString(QLatin1String("macx-ios-clang"));
1013
1063
    else if (abi.os() == Abi::LinuxOS)
1357
1407
            << (QStringList());
1358
1408
    QTest::newRow("empty input (with macros)")
1359
1409
            << QString::fromLatin1("")
1360
 
            << QByteArray("#define __x86_64 1\n#define __Something\n")
 
1410
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\n#define __Something\n")
1361
1411
            << (QStringList());
1362
 
    QTest::newRow("broken input")
1363
 
            << QString::fromLatin1("arm-none-foo-gnueabi")
1364
 
            << QByteArray("#define __ARM_64 1\n#define __Something\n")
 
1412
    QTest::newRow("broken input -- 64bit")
 
1413
            << QString::fromLatin1("arm-none-foo-gnueabi")
 
1414
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\n#define __Something\n")
 
1415
            << (QStringList() << QLatin1String("arm-unknown-unknown-unknown-64bit"));
 
1416
    QTest::newRow("broken input -- 32bit")
 
1417
            << QString::fromLatin1("arm-none-foo-gnueabi")
 
1418
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\n#define __Something\n")
1365
1419
            << (QStringList() << QLatin1String("arm-unknown-unknown-unknown-32bit"));
1366
 
    QTest::newRow("totally broken input")
 
1420
    QTest::newRow("totally broken input -- 32bit")
1367
1421
            << QString::fromLatin1("foo-bar-foo")
1368
 
            << QByteArray("#define __ARM_64 1\n#define __Something\n")
 
1422
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\n#define __Something\n")
1369
1423
            << (QStringList());
1370
1424
 
1371
1425
    QTest::newRow("Linux 1 (32bit intel)")
1372
1426
            << QString::fromLatin1("i686-linux-gnu")
1373
 
            << QByteArray("")
 
1427
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
1374
1428
            << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"));
1375
1429
    QTest::newRow("Linux 2 (32bit intel)")
1376
1430
            << QString::fromLatin1("i486-linux-gnu")
1377
 
            << QByteArray("")
 
1431
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
1378
1432
            << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"));
1379
1433
    QTest::newRow("Linux 3 (64bit intel)")
1380
1434
            << QString::fromLatin1("x86_64-linux-gnu")
1381
 
            << QByteArray("#define __x86_64 1\n")
 
1435
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
1382
1436
            << (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
1383
1437
                              << QLatin1String("x86-linux-generic-elf-32bit"));
1384
1438
    QTest::newRow("Linux 3 (64bit intel -- non 64bit)")
1385
1439
            << QString::fromLatin1("x86_64-linux-gnu")
1386
 
            << QByteArray()
 
1440
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
1387
1441
            << (QStringList() << QLatin1String("x86-linux-generic-elf-32bit"));
1388
1442
    QTest::newRow("Linux 4 (32bit mips)")
1389
1443
            << QString::fromLatin1("mipsel-linux-uclibc")
1390
 
            << QByteArray()
 
1444
            << QByteArray("#define __SIZEOF_SIZE_T__ 4")
1391
1445
            << (QStringList() << QLatin1String("mips-linux-generic-elf-32bit"));
1392
1446
    QTest::newRow("Linux 5 (QTCREATORBUG-4690)") // from QTCREATORBUG-4690
1393
1447
            << QString::fromLatin1("x86_64-redhat-linux6E")
1394
 
            << QByteArray("#define __x86_64 1\n")
 
1448
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
1395
1449
            << (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
1396
1450
                              << QLatin1String("x86-linux-generic-elf-32bit"));
1397
1451
    QTest::newRow("Linux 6 (QTCREATORBUG-4690)") // from QTCREATORBUG-4690
1398
1452
            << QString::fromLatin1("x86_64-redhat-linux")
1399
 
            << QByteArray("#define __x86_64 1\n")
 
1453
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
1400
1454
            << (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
1401
1455
                              << QLatin1String("x86-linux-generic-elf-32bit"));
1402
1456
    QTest::newRow("Linux 7 (arm)")
1403
1457
                << QString::fromLatin1("armv5tl-montavista-linux-gnueabi")
1404
 
                << QByteArray()
 
1458
                << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
1405
1459
                << (QStringList() << QLatin1String("arm-linux-generic-elf-32bit"));
1406
1460
    QTest::newRow("Linux 8 (arm)")
1407
1461
                << QString::fromLatin1("arm-angstrom-linux-gnueabi")
1408
 
                << QByteArray()
 
1462
                << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
1409
1463
                << (QStringList() << QLatin1String("arm-linux-generic-elf-32bit"));
1410
1464
    QTest::newRow("Linux 9 (ppc)")
1411
1465
                << QString::fromLatin1("powerpc-nsg-linux")
1412
 
                << QByteArray()
 
1466
                << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
1413
1467
                << (QStringList() << QLatin1String("ppc-linux-generic-elf-32bit"));
1414
1468
    QTest::newRow("Linux 10 (ppc 64bit)")
1415
1469
                << QString::fromLatin1("powerpc64-suse-linux")
1416
 
                << QByteArray()
 
1470
                << QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
1417
1471
                << (QStringList() << QLatin1String("ppc-linux-generic-elf-64bit"));
1418
1472
 
1419
1473
    QTest::newRow("Mingw 1 (32bit)")
1420
1474
            << QString::fromLatin1("i686-w64-mingw32")
1421
 
            << QByteArray()
 
1475
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\r\n")
1422
1476
            << (QStringList() << QLatin1String("x86-windows-msys-pe-32bit"));
1423
1477
    QTest::newRow("Mingw 2 (64bit)")
1424
1478
            << QString::fromLatin1("i686-w64-mingw32")
1425
 
            << QByteArray("#define __x86_64 1\r\n")
 
1479
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\r\n")
1426
1480
            << (QStringList() << QLatin1String("x86-windows-msys-pe-64bit")
1427
1481
                              << QLatin1String("x86-windows-msys-pe-32bit"));
1428
1482
    QTest::newRow("Mingw 3 (32 bit)")
1429
1483
            << QString::fromLatin1("mingw32")
1430
 
            << QByteArray()
 
1484
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\r\n")
1431
1485
            << (QStringList() << QLatin1String("x86-windows-msys-pe-32bit"));
1432
1486
    QTest::newRow("Cross Mingw 1 (64bit)")
1433
1487
            << QString::fromLatin1("amd64-mingw32msvc")
1434
 
            << QByteArray("#define __x86_64 1\r\n")
 
1488
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\r\n")
1435
1489
            << (QStringList() << QLatin1String("x86-windows-msys-pe-64bit")
1436
1490
                              << QLatin1String("x86-windows-msys-pe-32bit"));
1437
1491
    QTest::newRow("Cross Mingw 2 (32bit)")
1438
1492
            << QString::fromLatin1("i586-mingw32msvc")
1439
 
            << QByteArray()
 
1493
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\r\n")
1440
1494
            << (QStringList() << QLatin1String("x86-windows-msys-pe-32bit"));
1441
1495
    QTest::newRow("Clang 1: windows")
1442
1496
            << QString::fromLatin1("x86_64-pc-win32")
1443
 
            << QByteArray("#define __x86_64 1\r\n")
 
1497
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\r\n")
1444
1498
            << (QStringList() << QLatin1String("x86-windows-msys-pe-64bit")
1445
1499
                              << QLatin1String("x86-windows-msys-pe-32bit"));
1446
1500
    QTest::newRow("Clang 1: linux")
1447
1501
            << QString::fromLatin1("x86_64-unknown-linux-gnu")
1448
 
            << QByteArray("#define __x86_64 1\n")
 
1502
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
1449
1503
            << (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
1450
1504
                              << QLatin1String("x86-linux-generic-elf-32bit"));
1451
1505
    QTest::newRow("Mac 1")
1452
1506
            << QString::fromLatin1("i686-apple-darwin10")
1453
 
            << QByteArray("#define __x86_64 1\n")
 
1507
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
1454
1508
            << (QStringList() << QLatin1String("x86-macos-generic-mach_o-64bit")
1455
 
                              << QLatin1String("x86-macos-generic-mach_o-32bit")
1456
 
                              << QLatin1String("ppc-macos-generic-mach_o-64bit")
1457
 
                              << QLatin1String("ppc-macos-generic-mach_o-32bit"));
 
1509
                              << QLatin1String("x86-macos-generic-mach_o-32bit"));
1458
1510
    QTest::newRow("Mac 2")
1459
1511
            << QString::fromLatin1("powerpc-apple-darwin10")
1460
 
            << QByteArray("#define __x86_64 1\n")
 
1512
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
1461
1513
            << (QStringList() << QLatin1String("ppc-macos-generic-mach_o-64bit")
1462
 
                              << QLatin1String("ppc-macos-generic-mach_o-32bit")
1463
 
                              << QLatin1String("x86-macos-generic-mach_o-64bit")
1464
 
                              << QLatin1String("x86-macos-generic-mach_o-32bit"));
 
1514
                              << QLatin1String("ppc-macos-generic-mach_o-32bit"));
1465
1515
    QTest::newRow("Mac 3")
1466
1516
            << QString::fromLatin1("i686-apple-darwin9")
1467
 
            << QByteArray("#define __x86_64 1\n")
 
1517
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
1468
1518
            << (QStringList() << QLatin1String("x86-macos-generic-mach_o-32bit")
1469
 
                              << QLatin1String("x86-macos-generic-mach_o-64bit")
1470
 
                              << QLatin1String("ppc-macos-generic-mach_o-32bit")
1471
 
                              << QLatin1String("ppc-macos-generic-mach_o-64bit"));
 
1519
                              << QLatin1String("x86-macos-generic-mach_o-64bit"));
1472
1520
    QTest::newRow("Mac IOS")
1473
1521
            << QString::fromLatin1("arm-apple-darwin9")
1474
 
            << QByteArray()
1475
 
            << (QStringList() << QLatin1String("arm-macos-generic-mach_o-32bit"));
 
1522
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
 
1523
            << (QStringList() << QLatin1String("arm-macos-generic-mach_o-32bit")
 
1524
                              << QLatin1String("arm-macos-generic-mach_o-64bit"));
1476
1525
    QTest::newRow("Intel 1")
1477
1526
            << QString::fromLatin1("86_64 x86_64 GNU/Linux")
1478
 
            << QByteArray("#define __x86_64 1\n")
 
1527
            << QByteArray("#define __SIZEOF_SIZE_T__ 8\n")
1479
1528
            << (QStringList() << QLatin1String("x86-linux-generic-elf-64bit")
1480
1529
                              << QLatin1String("x86-linux-generic-elf-32bit"));
1481
1530
    QTest::newRow("FreeBSD 1")
1482
1531
            << QString::fromLatin1("i386-portbld-freebsd9.0")
1483
 
            << QByteArray()
 
1532
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
1484
1533
            << (QStringList() << QLatin1String("x86-bsd-freebsd-elf-32bit"));
1485
1534
    QTest::newRow("FreeBSD 2")
1486
1535
            << QString::fromLatin1("i386-undermydesk-freebsd")
1487
 
            << QByteArray()
 
1536
            << QByteArray("#define __SIZEOF_SIZE_T__ 4\n")
1488
1537
            << (QStringList() << QLatin1String("x86-bsd-freebsd-elf-32bit"));
1489
1538
}
1490
1539