Bug 458033 - Failure to build with XSIMD support
Summary: Failure to build with XSIMD support
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (other bugs)
Version First Reported In: 5.1.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: amyspark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-18 15:01 UTC by Timo Gurr
Modified: 2022-08-25 17:45 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
krita-5.1.0_build.log (1006.28 KB, text/x-log)
2022-08-18 15:02 UTC, Timo Gurr
Details
krita-5.1.0-xsimd.patch (1.20 KB, patch)
2022-08-18 19:24 UTC, Timo Gurr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timo Gurr 2022-08-18 15:01:18 UTC
STEPS TO REPRODUCE
1.  Try to build with XSIMD

OBSERVED RESULT
Running into compile error (complete build log is attached as file).

[...]
-- Available architectures for xsimd: x86-64
-- Found xsimd: /usr/x86_64-pc-linux-gnu/lib64/cmake/xsimd/xsimdConfig.cmake (found suitable version "8.1.0", minimum required is "8.1.0") 
[...]
[ 11%] Building CXX object libs/pigment/CMakeFiles/kritapigment.dir/KoOptimizedCompositeOpFactoryPerArch_AVX.cpp.o
cd /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/pigment && /usr/bin/x86_64-pc-linux-gnu-c++ -DBOOST_ALL_NO_LIB -DHAVE_X11 -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x50900 -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_URL_CAST_FROM_STRING -DQT_SQL_LIB -DQT_STRICT_ITERATORS -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_QSTRINGBUILDER -DQT_WIDGETS_LIB -DQT_XML_LIB -DTRANSLATION_DOMAIN=\"krita\" -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -Dkritapigment_EXPORTS -DXSIMD_IMPL=AVX -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/pigment -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/pigment/kritapigment_autogen/include -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/interfaces -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0 -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/resources -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/koplugin -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/koplugin -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/store -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/store -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/global -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/global -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/version -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/version -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/resources -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/resources -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/multiarch -I/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/multiarch -isystem /usr/x86_64-pc-linux-gnu/include/qt5 -isystem /usr/x86_64-pc-linux-gnu/include/qt5/QtCore -isystem /usr/x86_64-pc-linux-gnu/lib/qt5/mkspecs/linux-g++ -isystem /usr/x86_64-pc-linux-gnu/include/qt5/QtConcurrent -isystem /usr/x86_64-pc-linux-gnu/include/qt5/QtGui -isystem /usr/x86_64-pc-linux-gnu/include/qt5/QtWidgets -isystem /usr/x86_64-pc-linux-gnu/include/qt5/QtXml -isystem /usr/x86_64-pc-linux-gnu/include/KF5/KI18n -isystem /usr/x86_64-pc-linux-gnu/include/KF5 -isystem /usr/x86_64-pc-linux-gnu/include/qt5/QtSql -isystem /usr/x86_64-pc-linux-gnu/include/OpenEXR -isystem /usr/x86_64-pc-linux-gnu/include/Imath -isystem /usr/x86_64-pc-linux-gnu/include/KF5/KConfig -isystem /usr/x86_64-pc-linux-gnu/include/KF5/KConfigCore -march=native -O2 -pipe -DNDEBUG -DQT_NO_DEBUG -fno-operator-names -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Werror=init-self -Wvla -Wdate-time -Wsuggest-override -Wlogical-op  -fext-numeric-literals -fexceptions -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wno-suggest-override -Wextra -Wno-class-memaccess -fPIC -std=gnu++14  -Wabi -fabi-version=0 -fabi-compat-version=0 -ffp-contract=fast -fPIC -mavx -MD -MT libs/pigment/CMakeFiles/kritapigment.dir/KoOptimizedCompositeOpFactoryPerArch_AVX.cpp.o -MF CMakeFiles/kritapigment.dir/KoOptimizedCompositeOpFactoryPerArch_AVX.cpp.o.d -o CMakeFiles/kritapigment.dir/KoOptimizedCompositeOpFactoryPerArch_AVX.cpp.o -c /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/pigment/KoOptimizedCompositeOpFactoryPerArch_AVX.cpp
In file included from /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/global/KisHalfTraits.h:14,
                 from /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/KoColorSpaceMaths.h:109,
                 from /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoCompositeOpFunctions.h:10,
                 from /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoCompositeOpBase.h:11,
                 from /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoOptimizedCompositeOpAlphaDarken32.h:12,
                 from /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/pigment/KoOptimizedCompositeOpFactoryPerArch_AVX.cpp:11:
/usr/x86_64-pc-linux-gnu/include/Imath/halfLimits.h:17:2: warning: #warning "ImathLimits is deprecated; use #include <half.h>" [-Wcpp]
   17 | #warning "ImathLimits is deprecated; use #include <half.h>"
      |  ^~~~~~~
In file included from /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoStreamedMath.h:14,
                 from /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoOptimizedCompositeOpAlphaDarken32.h:14,
                 from /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build/libs/pigment/KoOptimizedCompositeOpFactoryPerArch_AVX.cpp:11:
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h: In instantiation of 'static void KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&, xsimd::batch<T, A>&) [with T = unsigned int; A = xsimd::avx; bool aligned = false]':
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoStreamedMath.h:610:45:   required from 'void PixelWrapper<short unsigned int, _impl>::read(const void*, PixelWrapper<short unsigned int, _impl>::float_v&, PixelWrapper<short unsigned int, _impl>::float_v&, PixelWrapper<short unsigned int, _impl>::float_v&, PixelWrapper<short unsigned int, _impl>::float_v&) [with _impl = xsimd::avx; PixelWrapper<short unsigned int, _impl>::float_v = xsimd::batch<float, xsimd::avx>]'
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoOptimizedCompositeOpAlphaDarken128.h:52:25:   required from 'static void AlphaDarkenCompositor128<channels_type, ParamsWrapperT>::compositeVector(const quint8*, quint8*, const quint8*, float, const ParamsWrapper&) [with bool haveMask = true; bool src_aligned = true; _impl = xsimd::avx; channels_type = short unsigned int; ParamsWrapperT = KoAlphaDarkenParamsWrapperCreamy; quint8 = unsigned char; AlphaDarkenCompositor128<channels_type, ParamsWrapperT>::ParamsWrapper = KoAlphaDarkenParamsWrapperCreamy]'
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoStreamedMath.h:424:75:   required from 'static void KoStreamedMath<_impl>::genericComposite(const KoCompositeOp::ParameterInfo&) [with bool useMask = true; bool useFlow = true; Compositor = AlphaDarkenCompositor128<short unsigned int, KoAlphaDarkenParamsWrapperCreamy>; int pixelSize = 8; _impl = xsimd::avx]'
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoStreamedMath.h:500:58:   required from 'static void KoStreamedMath<_impl>::genericComposite64(const KoCompositeOp::ParameterInfo&) [with bool useMask = true; bool useFlow = true; Compositor = AlphaDarkenCompositor128<short unsigned int, KoAlphaDarkenParamsWrapperCreamy>; _impl = xsimd::avx]'
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoOptimizedCompositeOpAlphaDarken128.h:248:126:   required from 'void KoOptimizedCompositeOpAlphaDarkenU64Impl<_impl, ParamsWrapper>::composite(const KoCompositeOp::ParameterInfo&) const [with _impl = xsimd::avx; ParamsWrapper = KoAlphaDarkenParamsWrapperCreamy]'
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoOptimizedCompositeOpAlphaDarken128.h:245:10:   required from here
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:176:37: error: no matching function for call to 'KoRgbaInterleavers<16>::deinterleave<false>(const void*&, xsimd::batch<unsigned int, xsimd::avx>&, xsimd::batch<unsigned int, xsimd::avx>&, xsimd::avx)'
  176 |         return deinterleave<aligned>(src, a, b, A{});
      |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:131:24: note: candidate: 'template<bool aligned, class T, class A, typename std::enable_if<(std::is_integral<_Size>::value && (sizeof (T) == 4)), int>::type <anonymous>, typename std::enable_if<(xsimd::batch<T, A>::size == 4), int>::type <anonymous> > static void KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&, xsimd::batch<T, A>&, xsimd::kernel::requires_arch<xsimd::generic>)'
  131 |     static inline void deinterleave(const void *src, batch<T, A> &dst1, batch<T, A> &dst2, kernel::requires_arch<generic>)
      |                        ^~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:131:24: note:   template argument deduction/substitution failed:
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:130:120: error: no type named 'type' in 'struct std::enable_if<false, int>'
  130 |     template<bool aligned, typename T, typename A, enable_sized_integral_t<T, 4> = 0, enable_sized_vector_t<T, A, 4> = 0>
      |                                                                                                                        ^
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:146:24: note: candidate: 'template<bool aligned, class T, class A, typename std::enable_if<(sizeof (T) == 4), int>::type <anonymous> > static void KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&, xsimd::batch<T, A>&, xsimd::kernel::requires_arch<xsimd::avx2>)'
  146 |     static inline void deinterleave(const void *src, batch<T, A> &a, batch<T, A> &b, kernel::requires_arch<avx2>)
      |                        ^~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:146:24: note:   template argument deduction/substitution failed:
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:176:37: note:   cannot convert 'xsimd::avx()' (type 'xsimd::avx') to type 'xsimd::kernel::requires_arch<xsimd::avx2>' {aka 'const xsimd::avx2&'}
  176 |         return deinterleave<aligned>(src, a, b, A{});
      |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:174:24: note: candidate: 'template<class T, class A, bool aligned> static void KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&, xsimd::batch<T, A>&)'
  174 |     static inline void deinterleave(const void *src, batch<T, A> &a, batch<T, A> &b)
      |                        ^~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:174:24: note:   template argument deduction/substitution failed:
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:176:37: error: type/value mismatch at argument 1 in template parameter list for 'template<class T, class A, bool aligned> static void KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&, xsimd::batch<T, A>&)'
  176 |         return deinterleave<aligned>(src, a, b, A{});
      |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:176:37: note:   expected a type, got 'false'

Error:
  * In program cave perform install --hooks --managed-output --output-exclusivity with-others =media-gfx/krita-5.1.0:0::kde --destination installed --replacing =media-gfx/krita-5.1.0:0::installed --x-of-y 1 of 1:
  * When installing 'media-gfx/krita-5.1.0:0::kde' replacing { 'media-gfx/krita-5.1.0:0::installed' }:
  * When running an ebuild command on 'media-gfx/krita-5.1.0:0::kde':
  * Install failed for 'media-gfx/krita-5.1.0:0::kde' (paludis::ActionFailedError)

make[2]: Leaving directory '/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build'
make[1]: Leaving directory '/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/build'
make[2]: *** [libs/pigment/CMakeFiles/kritapigment.dir/build.make:908: libs/pigment/CMakeFiles/kritapigment.dir/KoOptimizedCompositeOpFactoryPerArch_AVX.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:9887: libs/pigment/CMakeFiles/kritapigment.dir/all] Error 2
make: *** [Makefile:149: all] Error 2



EXPECTED RESULT
Compile with no error. Note: Disabling XSIMD support by passing -DCMAKE_DISABLE_FIND_PACKAGE_xsimd:BOOL=TRUE allows krita 5.1.0 to compile just fine.

SOFTWARE/OS VERSIONS
Operating System: Exherbo Linux
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.5
Kernel Version: 5.19.0 (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-6500 CPU @ 3.20GHz
Memory: 11.5 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 530

ADDITIONAL INFORMATION
Comment 1 Timo Gurr 2022-08-18 15:02:01 UTC
Created attachment 151407 [details]
krita-5.1.0_build.log
Comment 2 amyspark 2022-08-18 17:04:05 UTC
The check that's failing means that the size of the `unsigned int` type in your system is *not* 32 bits, which renders those functions unusable.

Can you check what your compiler returns for the size of `unsigned int`?

Alternatively, can you replace the definitions in libs\pigment\compositeops\KoStreamedMath.h as follows, and try building Krita again? Replace "int" and "unsigned int" for "int32_t" and "uint32_t" respectively, in`struct PixelWrapper<quint16, ...>` and `struct PixelWrapper<float, ...>`.
Comment 3 tomtomtomreportingin 2022-08-18 19:15:33 UTC
I will at least say that I've also had problems building recent versions of Krita on my Debian sid system. The error I would get at around the 7% mark would be "/usr/bin/ld: cannot find -lxtl: No such file or directory", but it would stop at the same file.

Passing the flag that Timo noted seems to workaround the issue, so it's likely also xsimd related.
Comment 4 Timo Gurr 2022-08-18 19:23:50 UTC
(In reply to amyspark from comment #2)
> Can you check what your compiler returns for the size of `unsigned int`?
Sorry I've no  idea how to do that.

> Alternatively, can you replace the definitions in
> libs\pigment\compositeops\KoStreamedMath.h as follows, and try building
> Krita again? Replace "int" and "unsigned int" for "int32_t" and "uint32_t"
> respectively, in`struct PixelWrapper<quint16, ...>` and `struct
> PixelWrapper<float, ...>`.

I'm attaching the patch I'm using as krita-5.1.0-xsimd.patch, maybe I did something wrong, with it applied I get the following error:

/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:176:37: error: no matching function for call to 'KoRgbaInterleavers<16>::deinterleave<false>(const void*&, xsimd::batch<unsigned int, xsimd::avx>&, xsimd::batch<unsigned int, xsimd::avx>&, xsimd::avx)'
  176 |         return deinterleave<aligned>(src, a, b, A{});
      |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:131:24: note: candidate: 'template<bool aligned, class T, class A, typename std::enable_if<(std::is_integral<_Size>::value && (sizeof (T) == 4)), int>::type <anonymous>, typename std::enable_if<(xsimd::batch<T, A>::size == 4), int>::type <anonymous> > static void KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&, xsimd::batch<T, A>&, xsimd::kernel::requires_arch<xsimd::generic>)'
  131 |     static inline void deinterleave(const void *src, batch<T, A> &dst1, batch<T, A> &dst2, kernel::requires_arch<generic>)
      |                        ^~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:131:24: note:   template argument deduction/substitution failed:
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:130:120: error: no type named 'type' in 'struct std::enable_if<false, int>'
  130 |     template<bool aligned, typename T, typename A, enable_sized_integral_t<T, 4> = 0, enable_sized_vector_t<T, A, 4> = 0>
      |                                                                                                                        ^
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:146:24: note: candidate: 'template<bool aligned, class T, class A, typename std::enable_if<(sizeof (T) == 4), int>::type <anonymous> > static void KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&, xsimd::batch<T, A>&, xsimd::kernel::requires_arch<xsimd::avx2>)'
  146 |     static inline void deinterleave(const void *src, batch<T, A> &a, batch<T, A> &b, kernel::requires_arch<avx2>)
      |                        ^~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:146:24: note:   template argument deduction/substitution failed:
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:176:37: note:   cannot convert 'xsimd::avx()' (type 'xsimd::avx') to type 'xsimd::kernel::requires_arch<xsimd::avx2>' {aka 'const xsimd::avx2&'}
  176 |         return deinterleave<aligned>(src, a, b, A{});
      |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:174:24: note: candidate: 'template<class T, class A, bool aligned> static void KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&, xsimd::batch<T, A>&)'
  174 |     static inline void deinterleave(const void *src, batch<T, A> &a, batch<T, A> &b)
      |                        ^~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:174:24: note:   template argument deduction/substitution failed:
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:176:37: error: type/value mismatch at argument 1 in template parameter list for 'template<class T, class A, bool aligned> static void KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&, xsimd::batch<T, A>&)'
  176 |         return deinterleave<aligned>(src, a, b, A{});
      |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/compositeops/KoRgbaInterleavers.h:176:37: note:   expected a type, got 'false'

In regards to what tomtomtomreportingin@gmail.com just posted I want to note that we currently compile our xsimd package with xtl support disabled by passing -DENABLE_XTL_COMPLEX:BOOL=FALSE since we didn't package https://github.com/xtensor-stack/xtl yet.
Comment 5 Timo Gurr 2022-08-18 19:24:10 UTC
Created attachment 151414 [details]
krita-5.1.0-xsimd.patch
Comment 6 amyspark 2022-08-18 19:48:04 UTC
(In reply to tomtomtomreportingin from comment #3)
> I will at least say that I've also had problems building recent versions of
> Krita on my Debian sid system. The error I would get at around the 7% mark
> would be "/usr/bin/ld: cannot find -lxtl: No such file or directory", but it
> would stop at the same file.
> 
> Passing the flag that Timo noted seems to workaround the issue, so it's
> likely also xsimd related.

We don't use xtensor-stack's xtl since we have no need for complex number maths (yet). So that would be best reported to your distribution.
Comment 7 amyspark 2022-08-18 19:51:15 UTC
(In reply to Timo Gurr from comment #4)
> (In reply to amyspark from comment #2)
> > Can you check what your compiler returns for the size of `unsigned int`?
> Sorry I've no  idea how to do that.
> 
> > Alternatively, can you replace the definitions in
> > libs\pigment\compositeops\KoStreamedMath.h as follows, and try building
> > Krita again? Replace "int" and "unsigned int" for "int32_t" and "uint32_t"
> > respectively, in`struct PixelWrapper<quint16, ...>` and `struct
> > PixelWrapper<float, ...>`.
> 
> I'm attaching the patch I'm using as krita-5.1.0-xsimd.patch, maybe I did
> something wrong, with it applied I get the following error:
> 
> /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/
> compositeops/KoRgbaInterleavers.h:176:37: error: no matching function for
> call to 'KoRgbaInterleavers<16>::deinterleave<false>(const void*&,
> xsimd::batch<unsigned int, xsimd::avx>&, xsimd::batch<unsigned int,
> xsimd::avx>&, xsimd::avx)'
>   176 |         return deinterleave<aligned>(src, a, b, A{});
>       |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
> /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/
> compositeops/KoRgbaInterleavers.h:131:24: note: candidate: 'template<bool
> aligned, class T, class A, typename
> std::enable_if<(std::is_integral<_Size>::value && (sizeof (T) == 4)),
> int>::type <anonymous>, typename std::enable_if<(xsimd::batch<T, A>::size ==
> 4), int>::type <anonymous> > static void
> KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&,
> xsimd::batch<T, A>&, xsimd::kernel::requires_arch<xsimd::generic>)'
>   131 |     static inline void deinterleave(const void *src, batch<T, A>
> &dst1, batch<T, A> &dst2, kernel::requires_arch<generic>)
>       |                        ^~~~~~~~~~~~
> /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/
> compositeops/KoRgbaInterleavers.h:131:24: note:   template argument
> deduction/substitution failed:
> /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/
> compositeops/KoRgbaInterleavers.h:130:120: error: no type named 'type' in
> 'struct std::enable_if<false, int>'
>   130 |     template<bool aligned, typename T, typename A,
> enable_sized_integral_t<T, 4> = 0, enable_sized_vector_t<T, A, 4> = 0>
>       |                                                                     
> ^
> /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/
> compositeops/KoRgbaInterleavers.h:146:24: note: candidate: 'template<bool
> aligned, class T, class A, typename std::enable_if<(sizeof (T) == 4),
> int>::type <anonymous> > static void
> KoRgbaInterleavers<16>::deinterleave(const void*, xsimd::batch<T, A>&,
> xsimd::batch<T, A>&, xsimd::kernel::requires_arch<xsimd::avx2>)'
>   146 |     static inline void deinterleave(const void *src, batch<T, A> &a,
> batch<T, A> &b, kernel::requires_arch<avx2>)
>       |                        ^~~~~~~~~~~~
> /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/
> compositeops/KoRgbaInterleavers.h:146:24: note:   template argument
> deduction/substitution failed:
> /var/tmp/paludis/build/media-gfx-krita-5.1.0/work/krita-5.1.0/libs/pigment/
> compositeops/KoRgbaInterleavers.h:176:37: note:   cannot convert
> 'xsimd::avx()' (type 'xsimd::avx') to type
> 'xsimd::kernel::requires_arch<xsimd::avx2>' {aka 'const xsimd::avx2&'}
>   176 |         return deinterleave<aligned>(src, a, b, A{});
>       |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~

I'm afraid your compiler is definitely reporting the wrong size for 32-bit unsigned integers (not 4 bytes), hence the generic version won't be usable. There's nothing we can do on our end, you'll have to upgrade GCC or build Krita without SIMD acceleration.

For this reason, marking as NOT A BUG.
Comment 8 Timo Gurr 2022-08-18 21:11:31 UTC
(In reply to amyspark from comment #7)
> I'm afraid your compiler is definitely reporting the wrong size for 32-bit
> unsigned integers (not 4 bytes), hence the generic version won't be usable.
> There's nothing we can do on our end, you'll have to upgrade GCC or build
> Krita without SIMD acceleration.
> 
> For this reason, marking as NOT A BUG.

I haven't come across any issues with other packages and since we're a source-based distribution and compile everything such fundamental issues should become directly obvious.

Also our GCC version is pretty recent:

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/x86_64-pc-linux-gnu/libexec/gcc/x86_64-pc-linux-gnu/11.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/paludis/build/sys-devel-gcc-11.3.0/work/gcc-11.3.0/configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --prefix=/usr/x86_64-pc-linux-gnu --datarootdir=/usr/share --localstatedir=/var --sysconfdir=/etc --disable-dependency-tracking --enable-fast-install --enable-serial-configure --disable-bootstrap --disable-decimal-float --disable-install-libiberty --disable-libada --disable-libatomic --disable-libcilkrts --disable-libffi --disable-libgfortran --disable-libgo --disable-libgomp --disable-libitm --disable-libobjc --disable-liboffloadmic --disable-libquadmath --disable-libsanitizer --disable-libssp --disable-libstdcxx --disable-libstdc++-v3 --disable-libvtv --disable-vtable-verify --disable-multilib --disable-nls --disable-shared --enable-lto --enable-plugin --enable-plugins --enable-threads --enable-languages=c,c++,fortran,objc,obj-c++ --with-sysroot= --with-gxx-include-dir=/usr/x86_64-pc-linux-gnu/include/c++/11.3.0 --with-isl --with-lib-path=/usr/x86_64-pc-linux-gnu/lib --with-as=/usr/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/bin/as.binutils --with-ld=/usr/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-ld --with-system-zlib --with-glibc-version=2.11 --enable-linker-build-id --with-multilib-list= --disable-libhsail-rt --disable-libphobos --enable-default-pie --enable-analyzer --without-zstd --program-transform='s,$,-11,' --enable-cet
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.3.0 (GCC)

and I've also just tried it on another system which was just recently upgraded to GCC 12 and successfully recompiled every single package installed and can reproduce the issue there as well.

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/x86_64-pc-linux-gnu/libexec/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/paludis/build/sys-devel-gcc-12.1.0/work/gcc-12.1.0/configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --prefix=/usr/x86_64-pc-linux-gnu --datarootdir=/usr/share --localstatedir=/var --sysconfdir=/etc --disable-dependency-tracking --enable-fast-install --enable-serial-configure --disable-bootstrap --disable-decimal-float --disable-install-libiberty --disable-libada --disable-libatomic --disable-libcilkrts --disable-libffi --disable-libgfortran --disable-libgo --disable-libgomp --disable-libitm --disable-libobjc --disable-liboffloadmic --disable-libquadmath --disable-libsanitizer --disable-libssp --disable-libstdcxx --disable-libstdc++-v3 --disable-libvtv --disable-vtable-verify --disable-multilib --disable-nls --disable-shared --enable-lto --enable-plugin --enable-plugins --enable-threads --enable-languages=c,c++,fortran,objc,obj-c++ --with-sysroot= --with-gxx-include-dir=/usr/x86_64-pc-linux-gnu/include/c++/12.1.0 --without-isl --with-lib-path=/usr/x86_64-pc-linux-gnu/lib --with-as=/usr/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/bin/as.binutils --with-ld=/usr/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-ld --with-system-zlib --with-glibc-version=2.11 --enable-linker-build-id --with-multilib-list= --disable-pgo-build --disable-werror --disable-libphobos --enable-default-pie --enable-analyzer --without-zstd --program-transform='s,$,-12,' --enable-cet
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.1.0 (GCC)

Both systems are on glibc 2.36 and binutils 2.39 if that might be of any relevance.
Comment 9 amyspark 2022-08-19 01:00:09 UTC
(In reply to Timo Gurr from comment #8)
> I haven't come across any issues with other packages and since we're a
> source-based distribution and compile everything such fundamental issues
> should become directly obvious.
> 
> Also our GCC version is pretty recent:

The RGBA interleavers code that's causing the error checks for 256-bit wide vectors (AVX) of 32-bit integers. Your version of GCC is reporting `unsigned int` to not be 32-bit in size. I do not know what your distribution is doing, but the code is not designed for that circumstance.

FTR, I compile the code with Clang 14.0.6, GCC 12.1 (MSYS flavours CLANG64 and UCRT64), and MSVC 17.4 Preview 1. All of them work correctly.
Comment 10 Timo Gurr 2022-08-23 10:46:45 UTC
(In reply to amyspark from comment #9)
> (In reply to Timo Gurr from comment #8)
> > I haven't come across any issues with other packages and since we're a
> > source-based distribution and compile everything such fundamental issues
> > should become directly obvious.
> > 
> > Also our GCC version is pretty recent:
> 
> The RGBA interleavers code that's causing the error checks for 256-bit wide
> vectors (AVX) of 32-bit integers. Your version of GCC is reporting `unsigned
> int` to not be 32-bit in size. I do not know what your distribution is
> doing, but the code is not designed for that circumstance.
> 
> FTR, I compile the code with Clang 14.0.6, GCC 12.1 (MSYS flavours CLANG64
> and UCRT64), and MSVC 17.4 Preview 1. All of them work correctly.

After further investigation and finding the actual problem I'd say this is clearly an issue on your side regarding the CMake magic you've implemented doing the wrong thing since if I compile with -march=x86-64 krita builds just fine with vectorization/xsimd enabled, but it fails when trying to build with -march=native on the very same machine with nothing else changed. That shouldn't be the case and I don't consider this an issue with our compiler. Probably you should be able to reproduce this when trying to compile with -march=native as well, not sure what the CMake magic does in regards to different hardware/processor features though and if that may also play a role here.

For reference, working:
CHOST="x86_64-pc-linux-gnu"
x86_64_pc_linux_gnu_CFLAGS="-march=x86-64 -O2 -pipe"
x86_64_pc_linux_gnu_CXXFLAGS="-march=x86-64 -O2 -pipe"

Failing:
CHOST="x86_64-pc-linux-gnu"
x86_64_pc_linux_gnu_CFLAGS="-march=native -O2 -pipe"
x86_64_pc_linux_gnu_CXXFLAGS="-march=native -O2 -pipe"

/proc/cpuinfo of CPUs tested on:

vendor_id       : GenuineIntel
cpu family      : 6
model           : 94
model name      : Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
stepping        : 3
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities

vendor_id       : GenuineIntel
cpu family      : 6
model           : 85
model name      : Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz
stepping        : 4
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xsaves arat pku ospke md_clear flush_l1d arch_capabilities
Comment 11 amyspark 2022-08-23 14:00:31 UTC
(In reply to Timo Gurr from comment #10)
> (In reply to amyspark from comment #9)
> > (In reply to Timo Gurr from comment #8)
> > > I haven't come across any issues with other packages and since we're a
> > > source-based distribution and compile everything such fundamental issues
> > > should become directly obvious.
> > > 
> > > Also our GCC version is pretty recent:
> > 
> > The RGBA interleavers code that's causing the error checks for 256-bit wide
> > vectors (AVX) of 32-bit integers. Your version of GCC is reporting `unsigned
> > int` to not be 32-bit in size. I do not know what your distribution is
> > doing, but the code is not designed for that circumstance.
> > 
> > FTR, I compile the code with Clang 14.0.6, GCC 12.1 (MSYS flavours CLANG64
> > and UCRT64), and MSVC 17.4 Preview 1. All of them work correctly.
> 
> After further investigation and finding the actual problem I'd say this is
> clearly an issue on your side regarding the CMake magic you've implemented
> doing the wrong thing since if I compile with -march=x86-64 krita builds
> just fine with vectorization/xsimd enabled, but it fails when trying to
> build with -march=native on the very same machine with nothing else changed.
> That shouldn't be the case and I don't consider this an issue with our
> compiler. Probably you should be able to reproduce this when trying to
> compile with -march=native as well, not sure what the CMake magic does in
> regards to different hardware/processor features though and if that may also
> play a role here.

march=native? That's the key to this issue, reopening and assigning to myself.
Comment 12 amyspark 2022-08-23 14:00:46 UTC
Assigning.
Comment 13 Bug Janitor Service 2022-08-23 14:02:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1552
Comment 14 amyspark 2022-08-23 14:03:26 UTC
If you can test build Krita with the MR above, it'd be great.
Comment 15 Timo Gurr 2022-08-23 15:42:54 UTC
(In reply to amyspark from comment #14)
> If you can test build Krita with the MR above, it'd be great.

Appears to work for me with the changes from the MR.
Comment 16 amyspark 2022-08-25 17:41:45 UTC
Git commit 9c555836eef341bd6368d6181776838ae7163da0 by L. E. Segovia.
Committed on 25/08/2022 at 16:30.
Pushed by lsegovia into branch 'master'.

xsimd: fix architecture deduction on amd64 with march=native

Building Krita with march=native breaks a few assumptions existing in
my and Dmitry's code, namely:

- KoOptimizedPixelDataScalerU8ToU16 can't deduce the AVX batch type
  correctly on <= SSE4.1

- KoRgbaInterleavers can't select the correct implementation for AVX,
  because the AVX2 implementation is ifdef'd in instead of the AVX
  version

These assumptions are correct when building Krita with standard compiler
flags, which is why this bug cannot be reproduced in CI or locally out
of the box.

M  +2    -2    libs/pigment/KoOptimizedPixelDataScalerU8ToU16.h
M  +2    -1    libs/pigment/compositeops/KoRgbaInterleavers.h

https://invent.kde.org/graphics/krita/commit/9c555836eef341bd6368d6181776838ae7163da0
Comment 17 amyspark 2022-08-25 17:45:16 UTC
Git commit 9add01e5a5818be5e0a6d4d787adb8645b09d049 by L. E. Segovia.
Committed on 25/08/2022 at 17:45.
Pushed by lsegovia into branch 'krita/5.1'.

xsimd: fix architecture deduction on amd64 with march=native

Building Krita with march=native breaks a few assumptions existing in
my and Dmitry's code, namely:

- KoOptimizedPixelDataScalerU8ToU16 can't deduce the AVX batch type
  correctly on <= SSE4.1

- KoRgbaInterleavers can't select the correct implementation for AVX,
  because the AVX2 implementation is ifdef'd in instead of the AVX
  version

These assumptions are correct when building Krita with standard compiler
flags, which is why this bug cannot be reproduced in CI or locally out
of the box.
(cherry picked from commit 9c555836eef341bd6368d6181776838ae7163da0)

M  +2    -2    libs/pigment/KoOptimizedPixelDataScalerU8ToU16.h
M  +2    -1    libs/pigment/compositeops/KoRgbaInterleavers.h

https://invent.kde.org/graphics/krita/commit/9add01e5a5818be5e0a6d4d787adb8645b09d049