KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
2.9k stars 816 forks source link

Error compiling for MIPS #3529

Open tpimh opened 4 months ago

tpimh commented 4 months ago

When building for MIPS, I get the following errors in SPVRemapper.cpp:

In file included from /source/glslang/SPIRV/SPVRemapper.cpp:36:
/source/glslang/SPIRV/SPVRemapper.h: In member function ‘spv::Id& spv::spirvbin_t::asId(unsigned int)’:
/source/glslang/SPIRV/SPVRemapper.h:162:72: error: cannot bind non-const lvalue reference of type ‘spv::Id&’ {aka ‘unsigned int&’} to a value of type ‘__gnu_cxx::__alloc_traits<std::allocator<long unsigned int>, long unsigned int>::value_type’ {aka ‘long unsigned int’}
  162 |    spv::Id&        asId(unsigned word)                { return spv[word]; }
      |                                                                        ^
/source/glslang/SPIRV/SPVRemapper.h: In member function ‘const spv::Id& spv::spirvbin_t::asId(unsigned int) const’:
/source/glslang/SPIRV/SPVRemapper.h:163:72: warning: returning reference to temporary [-Wreturn-local-addr]
  163 |    const spv::Id&  asId(unsigned word)          const { return spv[word]; }
      |                                                                        ^
/source/glslang/SPIRV/SPVRemapper.cpp: In member function ‘void spv::spirvbin_t::mapRemainder()’:
/source/glslang/SPIRV/SPVRemapper.cpp:369:32: error: no matching function for call to ‘max(spv::spirvbin_t::spirword_t&, spv::Id)’
  369 |             maxBound = std::max(maxBound, localId(id) + 1);
      |                        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/13.2.0/string:51,
                 from /source/glslang/SPIRV/SPVRemapper.h:39:
/usr/local/include/c++/13.2.0/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/local/include/c++/13.2.0/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
/source/glslang/SPIRV/SPVRemapper.cpp:369:32: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long unsigned int’ and ‘spv::Id’ {aka ‘unsigned int’})
  369 |             maxBound = std::max(maxBound, localId(id) + 1);
      |                        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/13.2.0/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/local/include/c++/13.2.0/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
/source/glslang/SPIRV/SPVRemapper.cpp:369:32: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long unsigned int’ and ‘spv::Id’ {aka ‘unsigned int’})
  369 |             maxBound = std::max(maxBound, localId(id) + 1);
      |                        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/13.2.0/functional:67,
                 from /source/glslang/SPIRV/SPVRemapper.h:71:
/usr/local/include/c++/13.2.0/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/local/include/c++/13.2.0/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
/source/glslang/SPIRV/SPVRemapper.cpp:369:32: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long unsigned int’
  369 |             maxBound = std::max(maxBound, localId(id) + 1);
      |                        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/13.2.0/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/local/include/c++/13.2.0/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
/source/glslang/SPIRV/SPVRemapper.cpp:369:32: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long unsigned int’
  369 |             maxBound = std::max(maxBound, localId(id) + 1);
      |                        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
arcady-lunarg commented 4 months ago

Well that's annoying. The issue is spv::Id is defined as unsigned int whereas the underlying type of the vector is spirword_t which is defined as uint32_t which sounds like on your system is unsigned long.

tpimh commented 4 months ago

As I understand, I need to modify platform specific type definitions, but I can't find them.