From c5544c30f29bf43b86913df92b332c56d903ebe7 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 3 Nov 2020 00:20:05 +0100 Subject: [PATCH] WebAssembly: Fix Qt 5.15 for WebAssemby ABI detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Qt 5.15 for WebAssembly binaries published via the Qt SDK installer have a different binary format. Like in previous versions, the static libraries are in the "ar" format. However, the packaged .obj files, from Qt 5.15 on, have the '∖0asm' magic number. Fixes: QTCREATORBUG-24891 Change-Id: Idc6004dfc0949280a1d5f257c462d094fa51f5a6 Reviewed-by: Christian Kandeler Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/abi.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/abi.cpp b/src/plugins/projectexplorer/abi.cpp index b1d7574bccc..6c88c4fe1a0 100644 --- a/src/plugins/projectexplorer/abi.cpp +++ b/src/plugins/projectexplorer/abi.cpp @@ -413,9 +413,13 @@ static Abis abiOf(const QByteArray &data) result.append(macAbiForCpu(type)); pos += 20; } - } else if (getUint8(data, 0) == 'B' && getUint8(data, 1) == 'C' - && getUint8(data, 2) == 0xc0 && getUint8(data, 3) == 0xde) { - // https://llvm.org/docs/BitCodeFormat.html#llvm-ir-magic-number + } else if (// Qt 5.15+ https://webassembly.github.io/spec/core/binary/modules.html#binary-module + (getUint8(data, 0) == 0 && getUint8(data, 1) == 'a' + && getUint8(data, 2) == 's' && getUint8(data, 3) == 'm') + + // Qt < 5.15 https://llvm.org/docs/BitCodeFormat.html#llvm-ir-magic-number + || (getUint8(data, 0) == 'B' && getUint8(data, 1) == 'C' + && getUint8(data, 2) == 0xc0 && getUint8(data, 3) == 0xde)) { result.append(Abi(Abi::AsmJsArchitecture, Abi::UnknownOS, Abi::UnknownFlavor, Abi::EmscriptenFormat, 32)); } else if (data.size() >= 64){ @@ -1319,9 +1323,12 @@ void ProjectExplorer::ProjectExplorerPlugin::testAbiOfBinary_data() QTest::newRow("static QtCore: linux 64bit") << QString::fromLatin1("%1/static/linux-64bit-release.a").arg(prefix) << (QStringList() << QString::fromLatin1("x86-linux-generic-elf-64bit")); - QTest::newRow("static QtCore: asmjs emscripten 32bit") + QTest::newRow("static QtCore: asmjs emscripten 32bit (Qt < 5.15)") << QString::fromLatin1("%1/static/asmjs-emscripten.a").arg(prefix) << (QStringList() << QString::fromLatin1("asmjs-unknown-unknown-emscripten-32bit")); + QTest::newRow("static QtCore: asmjs emscripten 32bit (Qt >= 5.15)") + << QString::fromLatin1("%1/static/asmjs-emscripten-5.15.a").arg(prefix) + << (QStringList() << QString::fromLatin1("asmjs-unknown-unknown-emscripten-32bit")); QTest::newRow("static stdc++: mac fat") << QString::fromLatin1("%1/static/mac-fat.a").arg(prefix)