strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.77k stars 306 forks source link

Error compiling on Debian/x32 #1367

Closed fancycode closed 2 weeks ago

fancycode commented 2 weeks ago

Building 1.19.1 for Debian failed on the x32 platform (not to be confused with i386).

Relevant log output:

In file included from /usr/include/c++/14/string:51,
                 from /<<PKGBUILDDIR>>/libheif/common_utils.h:26,
                 from /<<PKGBUILDDIR>>/libheif/box.h:25,
                 from /<<PKGBUILDDIR>>/libheif/file.h:24,
                 from /<<PKGBUILDDIR>>/libheif/file.cc:21:
In function ‘constexpr typename __gnu_cxx::__enable_if<std::__is_byte<_Tp>::__value, void>::__type std::__fill_a1(_Tp*, _Tp*, const _Tp&) [with _Tp = unsigned char]’,
    inlined from ‘constexpr void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = unsigned char*; _Tp = unsigned char]’ at /usr/include/c++/14/bits/stl_algobase.h:998:21,
    inlined from ‘constexpr _OutputIterator std::__fill_n_a(_OutputIterator, _Size, const _Tp&, random_access_iterator_tag) [with _OutputIterator = unsigned char*; _Size = unsigned int; _Tp = unsigned char]’ at /usr/include/c++/14/bits/stl_algobase.h:1151:20,
    inlined from ‘constexpr _OI std::fill_n(_OI, _Size, const _Tp&) [with _OI = unsigned char*; _Size = unsigned int; _Tp = unsigned char]’ at /usr/include/c++/14/bits/stl_algobase.h:1180:29,
    inlined from ‘static constexpr _ForwardIterator std::__uninitialized_default_n_1<true>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = unsigned char*; _Size = unsigned int]’ at /usr/include/c++/14/bits/stl_uninitialized.h:668:29,
    inlined from ‘static constexpr _ForwardIterator std::__uninitialized_default_n_1<true>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = unsigned char*; _Size = unsigned int]’ at /usr/include/c++/14/bits/stl_uninitialized.h:660:9,
    inlined from ‘constexpr _ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = unsigned char*; _Size = unsigned int]’ at /usr/include/c++/14/bits/stl_uninitialized.h:712:20,
    inlined from ‘constexpr _ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = unsigned char*; _Size = unsigned int; _Tp = unsigned char]’ at /usr/include/c++/14/bits/stl_uninitialized.h:779:44,
    inlined from ‘constexpr void std::vector<_Tp, _Alloc>::_M_default_append(size_type) [with _Tp = unsigned char; _Alloc = std::allocator<unsigned char>]’ at /usr/include/c++/14/bits/vector.tcc:821:35,
    inlined from ‘constexpr void std::vector<_Tp, _Alloc>::resize(size_type) [with _Tp = unsigned char; _Alloc = std::allocator<unsigned char>]’ at /usr/include/c++/14/bits/stl_vector.h:1016:21,
    inlined from ‘Error HeifFile::set_item_data(const std::shared_ptr<Box_infe>&, const uint8_t*, size_t, heif_metadata_compression)’ at /<<PKGBUILDDIR>>/libheif/file.cc:1223:22:
/usr/include/c++/14/bits/stl_algobase.h:972:25: error: ‘void* __builtin_memset(void*, int, unsigned int)’ offset 0 is out of the bounds [0, 0] [-Werror=array-bounds=]
  972 |         __builtin_memset(__first, static_cast<unsigned char>(__tmp), __len);
      |         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

Full build log available at https://buildd.debian.org/status/fetch.php?pkg=libheif&arch=x32&ver=1.19.1-1&stamp=1730713177&raw=0

This is using gcc 14.2.0:

-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0

Maybe similar to #1360? Although this was working fine in older versions up to 1.18.2.

farindk commented 2 weeks ago

Looks like a similar compiler bug. I cannot see anything suspicious in the code.

The cmake preset for "Release" sets CMAKE_COMPILE_WARNING_AS_ERROR: OFF because of these kinds of compiler glitches. Are you using the cmake preset for building the package as a basis?

fancycode commented 2 weeks ago

Looks like a similar compiler bug. I cannot see anything suspicious in the code.

Ok, thanks for looking.

The cmake preset for "Release" sets CMAKE_COMPILE_WARNING_AS_ERROR: OFF because of these kinds of compiler glitches. Are you using the cmake preset for building the package as a basis?

No, in order to have full control over any options without needing libheif to provide everything I need, I set flags manually: https://salsa.debian.org/multimedia-team/libheif/-/blob/fb00da8fec71ffa81ff9d2dd88c0a274774c0985/debian/rules#L22-51

CMAKE_COMPILE_WARNING_AS_ERROR is not part of it yet, so maybe it's a good idea to start adding it.

farindk commented 2 weeks ago

Can we close this?

fancycode commented 2 weeks ago

Yeah, I'll workaround this somehow in packaging.