scapix icon indicating copy to clipboard operation
scapix copied to clipboard

Cannot use OpenCV with Scapix `1.0.28` or newer when building with `clang 12` or older

Open TimPushkin opened this issue 2 years ago • 2 comments

I have a project that uses OpenCV and Scapix 1.0.27 (cmodule 1.0.32) here -- it builds and works flawlessly as you can see in CI.

If I update Scapix to 1.0.28 or newer (in fact, I update cmodule to 1.0.33 or newer) as you can see in this branch where it's the only change, language interface generation fails with errors like this (I'm not sure if you can see it in the CI, so just copying from there)

[ 14%] Building CXX object _deps/scapix-1.0.28-build/CMakeFiles/scapix.dir/source/scapix/link/java/detail/exception.cpp.o
[ 28%] Linking CXX static library libscapix.a
[ 28%] Built target scapix
[ 42%] Running Scapix Bridge for /home/runner/work/SgbmDepthAndroid/SgbmDepthAndroid/sgbmdepth/src/main/cpp/include/DepthEstimator.h
In file included from /home/runner/work/SgbmDepthAndroid/SgbmDepthAndroid/sgbmdepth/src/main/cpp/include/DepthEstimator.h:7:
In file included from /home/runner/work/SgbmDepthAndroid/SgbmDepthAndroid/sgbmdepth/src/main/cpp/build/opencv-download/opencv-4.5.5/modules/core/include/opencv2/core.hpp:52:
In file included from /home/runner/work/SgbmDepthAndroid/SgbmDepthAndroid/sgbmdepth/src/main/cpp/build/opencv-download/opencv-4.5.5/modules/core/include/opencv2/core/cvdef.h:349:
In file included from /home/runner/work/SgbmDepthAndroid/SgbmDepthAndroid/sgbmdepth/src/main/cpp/build/opencv-download/opencv-4.5.5/modules/core/include/opencv2/core/cv_cpu_dispatch.h:210:
/usr/lib/llvm-[11](https://github.com/TimPushkin/SgbmDepthAndroid/runs/7496540399?check_suite_focus=true#step:7:12)/lib/clang/11.0.0/include/emmintrin.h:2374:19: error: use of undeclared identifier '__builtin_ia32_pmaxsw[12](https://github.com/TimPushkin/SgbmDepthAndroid/runs/7496540399?check_suite_focus=true#step:7:13)8'
  return (__m128i)__builtin_ia32_pmaxsw128((__v8hi)__a, (__v8hi)__b);
                  ^
/usr/lib/llvm-11/lib/clang/11.0.0/include/emmintrin.h:2394:19: error: use of undeclared identifier '__builtin_ia32_pmaxub128'
  return (__m128i)__builtin_ia32_pmaxub128((__v16qi)__a, (__v16qi)__b);
                  ^
/usr/lib/llvm-11/lib/clang/11.0.0/include/emmintrin.h:24[14](https://github.com/TimPushkin/SgbmDepthAndroid/runs/7496540399?check_suite_focus=true#step:7:15):19: error: use of undeclared identifier '__builtin_ia32_pminsw128'
  return (__m128i)__builtin_ia32_pminsw128((__v8hi)__a, (__v8hi)__b);
                  ^
/usr/lib/llvm-11/lib/clang/11.0.0/include/emmintrin.h:2434:19: error: use of undeclared identifier '__builtin_ia32_pminub128'
  return (__m128i)__builtin_ia32_pminub128((__v[16](https://github.com/TimPushkin/SgbmDepthAndroid/runs/7496540399?check_suite_focus=true#step:7:17)qi)__a, (__v16qi)__b);
                  ^
4 errors generated.
Error while processing /home/runner/work/SgbmDepthAndroid/SgbmDepthAndroid/sgbmdepth/src/main/cpp/include/DepthEstimator.h.
make[2]: *** [src/CMakeFiles/sgbmdepth.dir/build.make:75: ../generated/bridge/java/DepthEstimator.cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:[17](https://github.com/TimPushkin/SgbmDepthAndroid/runs/7496540399?check_suite_focus=true#step:7:18)9: src/CMakeFiles/sgbmdepth.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Error: Process completed with exit code 2.

Here you can see how it's built in CI, but I'm getting the same errors locally. Everything builds fine if I disable Scapix. What may be causing the issue?

TimPushkin avatar Jul 25 '22 09:07 TimPushkin

I think, I figured this out. CI uses clang 11.0.0 (currently the default for ubuntu-latest), but if I set it to use clang 14.0.0 (currently the default for ubuntu-22.04), on the contrary, it builds fine with newer Scapix (I tested it with cmodule 1.0.35) and has similar problems with building Scapix 1.0.27 (this I observed locally and didn't test in CI). Seems like clang 12 is also incompatible with newer Scapix.

Maybe it would be nice to specify compatible clang versions for Scapix releases?

TimPushkin avatar Jul 25 '22 16:07 TimPushkin

Thank you for detailed report.

I didn't catch this before, because it only happens with code using intrinsic ("emmintrin.h"), like OpenCV does.

I think I know what is the problem and how to fix it.

This may take some time, but next version of Scapix should fix this for any version of clang (and gcc) compiler.

Boris-Rasin avatar Jul 27 '22 15:07 Boris-Rasin

Fix released in cmodule v1.0.36 https://www.scapix.com/language_bridge/changelog/

Boris-Rasin avatar Aug 31 '22 01:08 Boris-Rasin