On Sun Jul 24, 2022 at 10:40:00PM -0600, k...@openbsd.org wrote:
> Bulk build on sparc64-0a.ports.openbsd.org
> 
> Started : Fri Jul 22 09:17:32 MDT 2022
> Finished: Sun Jul 24 22:39:26 MDT 2022
> Duration: 2 Days 13 hours 22 minutes
> 
> Built using OpenBSD 7.2-beta (GENERIC.MP) #1386: Thu Jul 21 08:50:25 MDT 2022
> 
> Built 9315 packages
> 
> Number of packages built each day:
> Jul 22: 7026
> Jul 23: 1482
> Jul 24: 807
> 
> 
> Critical path missing pkgs:
> http://build-failures.rhaalovely.net/sparc64/2022-07-22/summary.log
> 
> Build failures: 38
> http://build-failures.rhaalovely.net/sparc64/2022-07-22/x11/qt6/qtdeclarative.log
> 

https://bugreports.qt.io/browse/QTBUG-100125?gerritReviewStatus=All

OpenSUSE confirmed that with following patch they can build Qt on SPARC:

https://github.com/bmwiedemann/openSUSE/blob/934d586b71984cbf31d8ecb30dc8ac7f90369929/packages/q/qt6-shadertools/0001-Fix-encoding-decoding-of-string-literals-for-big-end.patch

OK?

Index: Makefile
===================================================================
RCS file: /cvs/ports/x11/qt6/qtshadertools/Makefile,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 Makefile
--- Makefile    12 May 2022 09:40:33 -0000      1.4
+++ Makefile    26 Jul 2022 20:27:24 -0000
@@ -1,6 +1,7 @@
 QT6NAME =              QtShaderTools
 
 COMMENT =              Qt6 shader tools module
+REVISION =             0
 
 PKGSPEC =              qt6-qtshadertools-${QT6_PKGSPEC}
 
Index: patches/patch-src_3rdparty_glslang_SPIRV_SPVRemapper_cpp
===================================================================
RCS file: patches/patch-src_3rdparty_glslang_SPIRV_SPVRemapper_cpp
diff -N patches/patch-src_3rdparty_glslang_SPIRV_SPVRemapper_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_3rdparty_glslang_SPIRV_SPVRemapper_cpp    26 Jul 2022 
20:27:24 -0000
@@ -0,0 +1,39 @@
+Per SPIR-V spec, a string literal's UTF-8 octets are encoded packed into
+words with little-endian convention. Explicitly perform that encoding
+instead of assuming that the host system is little-endian.
+
+Note that this change requires corresponding fixes in SPIRV-Tools.
+
+Fixes #202
+https://bugreports.qt.io/browse/QTBUG-100125?gerritReviewStatus=All
+Index: src/3rdparty/glslang/SPIRV/SPVRemapper.cpp
+--- src/3rdparty/glslang/SPIRV/SPVRemapper.cpp.orig
++++ src/3rdparty/glslang/SPIRV/SPVRemapper.cpp
+@@ -297,15 +297,21 @@ namespace spv {
+     std::string spirvbin_t::literalString(unsigned word) const
+     {
+         std::string literal;
++        const spirword_t * pos = spv.data() + word;
+ 
+         literal.reserve(16);
+ 
+-        const char* bytes = reinterpret_cast<const char*>(spv.data() + word);
+-
+-        while (bytes && *bytes)
+-            literal += *bytes++;
+-
+-        return literal;
++        do {
++            spirword_t word = *pos;
++            for (int i = 0; i < 4; i++) {
++                char c = word & 0xff;
++                if (c == '\0')
++                    return literal;
++                literal += c;
++                word >>= 8;
++            }
++            pos++;
++        } while (true);
+     }
+ 
+     void spirvbin_t::applyMap()
Index: patches/patch-src_3rdparty_glslang_SPIRV_disassemble_cpp
===================================================================
RCS file: patches/patch-src_3rdparty_glslang_SPIRV_disassemble_cpp
diff -N patches/patch-src_3rdparty_glslang_SPIRV_disassemble_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_3rdparty_glslang_SPIRV_disassemble_cpp    26 Jul 2022 
20:27:24 -0000
@@ -0,0 +1,104 @@
+Per SPIR-V spec, a string literal's UTF-8 octets are encoded packed into
+words with little-endian convention. Explicitly perform that encoding
+instead of assuming that the host system is little-endian.
+
+Note that this change requires corresponding fixes in SPIRV-Tools.
+
+Fixes #202
+https://bugreports.qt.io/browse/QTBUG-100125?gerritReviewStatus=All
+Index: src/3rdparty/glslang/SPIRV/disassemble.cpp
+--- src/3rdparty/glslang/SPIRV/disassemble.cpp.orig
++++ src/3rdparty/glslang/SPIRV/disassemble.cpp
+@@ -43,6 +43,7 @@
+ #include <stack>
+ #include <sstream>
+ #include <cstring>
++#include <utility>
+ 
+ #include "disassemble.h"
+ #include "doc.h"
+@@ -100,6 +101,7 @@ class SpirvStream { (protected)
+     void outputMask(OperandClass operandClass, unsigned mask);
+     void disassembleImmediates(int numOperands);
+     void disassembleIds(int numOperands);
++    std::pair<int, std::string> decodeString();
+     int disassembleString();
+     void disassembleInstruction(Id resultId, Id typeId, Op opCode, int 
numOperands);
+ 
+@@ -290,31 +292,44 @@ void SpirvStream::disassembleIds(int numOperands)
+     }
+ }
+ 
+-// return the number of operands consumed by the string
+-int SpirvStream::disassembleString()
++// decode string from words at current position (non-consuming)
++std::pair<int, std::string> SpirvStream::decodeString()
+ {
+-    int startWord = word;
+-
+-    out << " \"";
+-
+-    const char* wordString;
++    std::string res;
++    int wordPos = word;
++    char c;
+     bool done = false;
++
+     do {
+-        unsigned int content = stream[word];
+-        wordString = (const char*)&content;
++        unsigned int content = stream[wordPos];
+         for (int charCount = 0; charCount < 4; ++charCount) {
+-            if (*wordString == 0) {
++            c = content & 0xff;
++            content >>= 8;
++            if (c == '\0') {
+                 done = true;
+                 break;
+             }
+-            out << *(wordString++);
++            res += c;
+         }
+-        ++word;
+-    } while (! done);
++        ++wordPos;
++    } while(! done);
+ 
++    return std::make_pair(wordPos - word, res);
++}
++
++// return the number of operands consumed by the string
++int SpirvStream::disassembleString()
++{
++    out << " \"";
++
++    std::pair<int, std::string> decoderes = decodeString();
++
++    out << decoderes.second;
+     out << "\"";
+ 
+-    return word - startWord;
++    word += decoderes.first;
++
++    return decoderes.first;
+ }
+ 
+ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op 
opCode, int numOperands)
+@@ -331,7 +346,7 @@ void SpirvStream::disassembleInstruction(Id resultId, 
+             nextNestedControl = 0;
+         }
+     } else if (opCode == OpExtInstImport) {
+-        idDescriptor[resultId] = (const char*)(&stream[word]);
++        idDescriptor[resultId] = decodeString().second;
+     }
+     else {
+         if (resultId != 0 && idDescriptor[resultId].size() == 0) {
+@@ -428,7 +443,7 @@ void SpirvStream::disassembleInstruction(Id resultId, 
+             --numOperands;
+             // Get names for printing "(XXX)" for readability, *after* this id
+             if (opCode == OpName)
+-                idDescriptor[stream[word - 1]] = (const char*)(&stream[word]);
++                idDescriptor[stream[word - 1]] = decodeString().second;
+             break;
+         case OperandVariableIds:
+             disassembleIds(numOperands);
Index: patches/patch-src_3rdparty_glslang_SPIRV_spvIR_h
===================================================================
RCS file: patches/patch-src_3rdparty_glslang_SPIRV_spvIR_h
diff -N patches/patch-src_3rdparty_glslang_SPIRV_spvIR_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_3rdparty_glslang_SPIRV_spvIR_h    26 Jul 2022 20:27:24 
-0000
@@ -0,0 +1,48 @@
+Per SPIR-V spec, a string literal's UTF-8 octets are encoded packed into
+words with little-endian convention. Explicitly perform that encoding
+instead of assuming that the host system is little-endian.
+
+Note that this change requires corresponding fixes in SPIRV-Tools.
+
+Fixes #202
+https://bugreports.qt.io/browse/QTBUG-100125?gerritReviewStatus=All
+Index: src/3rdparty/glslang/SPIRV/spvIR.h
+--- src/3rdparty/glslang/SPIRV/spvIR.h.orig
++++ src/3rdparty/glslang/SPIRV/spvIR.h
+@@ -111,27 +111,23 @@ class Instruction { (public)
+ 
+     void addStringOperand(const char* str)
+     {
+-        unsigned int word;
+-        char* wordString = (char*)&word;
+-        char* wordPtr = wordString;
+-        int charCount = 0;
++        unsigned int word = 0;
++        unsigned int shiftAmount = 0;
+         char c;
++
+         do {
+             c = *(str++);
+-            *(wordPtr++) = c;
+-            ++charCount;
+-            if (charCount == 4) {
++            word |= ((unsigned int)c) << shiftAmount;
++            shiftAmount += 8;
++            if (shiftAmount == 32) {
+                 addImmediateOperand(word);
+-                wordPtr = wordString;
+-                charCount = 0;
++                word = 0;
++                shiftAmount = 0;
+             }
+         } while (c != 0);
+ 
+         // deal with partial last word
+-        if (charCount > 0) {
+-            // pad with 0s
+-            for (; charCount < 4; ++charCount)
+-                *(wordPtr++) = 0;
++        if (shiftAmount > 0) {
+             addImmediateOperand(word);
+         }
+     }

Reply via email to