Skip to content

Conversation

ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Apr 23, 2021

This PR rolls up a build of the latest OpenCV release, tested under mingw64 and mingw32.

The changes to packaging are fairly minor, though the PR is bigger than it strictly has to be because I took the possibly-controversial step of re-rolling all of the existing patches that didn't apply cleanly. The first patch didn't apply at all and required an update, and some of the others were applying but with hundreds of lines of offset, so I decided to refresh them all. If that's a problem, let me know and I'll be happy to drop those changes from the PR.

In addition to re-rolling many existing patches, and deleting the no-longer-used patch 0005 from the repo, changes required to successfully build were:

  • Added new patch 0105 to fix the build of new contrib module wechat_qrcode. It was using iconv assuming it was part of the base system -- a correct assumption, on POSIX. On Windows it requires linking with libiconv, which is available in MSYS2. I added code to its CMakeLists.txt to discover Iconv using the CMake-standard find module, and added it as a new dependency in the PKGBUILD.

    I should note that someone already submitted an upstream patch at wechat_qr: disable iconv dependancy for mingw opencv/opencv_contrib#2916 to go in the opposite direction, and disable wechat_qrcode's iconv use under MinGW. I have a question in at that PR as to why disabling it was chosen over linking in libiconv, but regardless I didn't discover that divergence until I was preparing to submit my change upstream as a PR.

  • I had to disable PKG_CONFIG_WITHOUT_PREFIX on the CMake command line, because the new OpenCVUtils.cmake functions for linking in dependencies create targets that break on paths rooted at /mingw64/.

    Issue manifested as a CMake configuration failure, claiming that Tesseract had a "nonexistent path" /mingw64/include/leptonica/ in its INTERFACE_INCLUDE_DIRECTORIES. Removing the setting changed its pkg-config output to include C:/msys64/... and placated CMake.

With these changes, and some downstream re-tooling to support the migration of the previous object tracking API to a cv::legacy:: namespace that occurred between 4.5.0 and 4.5.1 (but was broken into incompatibility by missing headers in 4.5.1, the main reason we're looking to move to 4.5.2), our OpenCV-enabled application builds successfully against these packages and passes all of its existing unit tests.

The console output of C:/msys64/mingw64/bin/opencv_version_win32.exe is also informative as to the state of the build, as it serves as a configuration summary for the package. Its output is included below.

Console output of opencv_version_win32.exe on MinGW64

General configuration for OpenCV 4.5.2 =====================================
  Version control:               4b90a245d-dirty

  Extra modules:
    Location (extra):            C:/msys64/home/DP/devel/MINGW-packages/mingw-w64-opencv/src/opencv_contrib-4.5.2/modules
    Version control (extra):     265cdac81

  Platform:
    Timestamp:                   2021-04-22T20:27:57Z
    Host:                        Windows 10.0.19042 AMD64
    CMake:                       3.19.3
    CMake generator:             MSYS Makefiles
    CMake build tool:            C:/msys64/usr/bin/make.exe
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (15 files):         + SSSE3 SSE4_1
      SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (0 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (4 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (29 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (4 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

  C/C++:
    Built as dynamic libs?:      YES
    C++ standard:                11
    C++ Compiler:                C:/msys64/mingw64/bin/g++.exe  (ver 10.2.0)
    C++ flags (Release):         -march=x86-64 -mtune=generic -O2 -pipe -D_POSIX_SOURCE -Wno-attributes   -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -march=x86-64 -mtune=generic -O2 -pipe -D_POSIX_SOURCE -Wno-attributes   -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -DDEBUG -D_DEBUG
    C Compiler:                  C:/msys64/mingw64/bin/gcc.exe
    C flags (Release):           -march=x86-64 -mtune=generic -O2 -pipe -D_POSIX_SOURCE -Wno-attributes   -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -march=x86-64 -mtune=generic -O2 -pipe -D_POSIX_SOURCE -Wno-attributes   -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -DDEBUG -D_DEBUG
    Linker flags (Release):      -pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high  -Wl,--gc-sections
    Linker flags (Debug):        -pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high  -Wl,--gc-sections
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          opengl32 glu32
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 alphamat aruco bgsegm calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow ovis phase_unwrapping photo plot python3 quality rapid reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    bioinspired world
    Disabled by dependency:      -
    Unavailable:                 cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv java julia matlab python2 ts viz
    Applications:                apps
    Documentation:               NO
    Non-free algorithms:         NO

  Windows RT support:            NO

  GUI:
    Win32 UI:                    YES
    OpenGL support:              YES (opengl32 glu32)

  Media I/O:
    ZLib:                        C:/msys64/mingw64/lib/libz.dll.a (ver 1.2.11)
    JPEG:                        C:/msys64/mingw64/lib/libjpeg.dll.a (ver 80)
    WEBP:                        C:/msys64/mingw64/lib/libwebp.dll.a (ver encoder: 0x020f)
    PNG:                         C:/msys64/mingw64/lib/libpng.dll.a (ver 1.6.37)
    TIFF:                        C:/msys64/mingw64/lib/libtiff.dll.a (ver 42 / 4.2.0)
    JPEG 2000:                   OpenJPEG (ver 2.3.1)
    OpenEXR:                     C:/msys64/mingw64/lib/libImath.dll.a C:/msys64/mingw64/lib/libIlmImf.dll.a C:/msys64/mingw64/lib/libIex.dll.a C:/msys64/mingw64/lib/libHalf.dll.a C:/msys64/mingw64/lib/libIlmThread.dll.a (ver 2_5)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (58.91.100)
      avformat:                  YES (58.45.100)
      avutil:                    YES (56.51.100)
      swscale:                   YES (5.7.100)
      avresample:                YES (4.0.0)
    DirectShow:                  YES

  Parallel framework:            TBB (ver 2020.2 interface 11102)

  Trace:                         YES (built-in)

  Other third-party libraries:
    Lapack:                      YES (C:/msys64/mingw64/lib/libopenblas.dll.a)
    Eigen:                       YES (ver 3.3.9)
    Custom HAL:                  NO
    Protobuf:                    C:/msys64/mingw64/lib/libprotobuf.dll.a (3.12.4)

  OpenCL:                        YES (no extra features)
    Include path:                C:/msys64/home/DP/devel/MINGW-packages/mingw-w64-opencv/src/opencv-4.5.2/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python 3:
    Interpreter:                 C:/msys64/mingw64/bin/python (ver 3.8.8)
    Libraries:                   C:/msys64/mingw64/lib/libpython3.8.dll.a (ver 3.8.8)
    numpy:                       C:/msys64/mingw64/lib/python3.8/site-packages/numpy/core/include (ver 1.20.1)
    install path:                /mingw64/lib/python3.8/site-packages

  Python (for build):            C:/msys64/mingw64/bin/python

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    /mingw64
-----------------------------------------------------------------


OpenCL Platforms:
    Intel(R) OpenCL
        iGPU: Intel(R) HD Graphics 4600 (OpenCL 1.2 )
        CPU: Intel(R) Core(TM) i5-4590S CPU @ 3.00GHz (OpenCL 1.2 (Build 10094))
Current OpenCL device:
    Type = iGPU
    Name = Intel(R) HD Graphics 4600
    Version = OpenCL 1.2
    Driver version = 20.19.15.5063
    Address bits = 64
    Compute units = 20
    Max work group size = 512
    Local memory size = 64 KB
    Max memory allocation size = 407 MB 409 KB 614 B
    Double support = No
    Host unified memory = Yes
    Device extensions:
        cl_intel_accelerator
        cl_intel_advanced_motion_estimation
        cl_intel_ctz
        cl_intel_d3d11_nv12_media_sharing
        cl_intel_dx9_media_sharing
        cl_intel_motion_estimation
        cl_intel_simultaneous_sharing
        cl_intel_subgroups
        cl_khr_3d_image_writes
        cl_khr_byte_addressable_store
        cl_khr_d3d10_sharing
        cl_khr_d3d11_sharing
        cl_khr_depth_images
        cl_khr_dx9_media_sharing
        cl_khr_gl_depth_images
        cl_khr_gl_event
        cl_khr_gl_msaa_sharing
        cl_khr_global_int32_base_atomics
        cl_khr_global_int32_extended_atomics
        cl_khr_gl_sharing
        cl_khr_icd
        cl_khr_image2d_from_buffer
        cl_khr_local_int32_base_atomics
        cl_khr_local_int32_extended_atomics
        cl_khr_spir
    Has AMD Blas = No
    Has AMD Fft = No
    Preferred vector width char = 1
    Preferred vector width short = 1
    Preferred vector width int = 1
    Preferred vector width long = 1
    Preferred vector width float = 1
    Preferred vector width double = 0
OpenCV's HW features list:
    ID=  1 (MMX) -> ON
    ID=  2 (SSE) -> ON
    ID=  3 (SSE2) -> ON
    ID=  4 (SSE3) -> ON
    ID=  5 (SSSE3) -> ON
    ID=  6 (SSE4.1) -> ON
    ID=  7 (SSE4.2) -> ON
    ID=  8 (POPCNT) -> ON
    ID=  9 (FP16) -> ON
    ID= 10 (AVX) -> ON
    ID= 11 (AVX2) -> ON
    ID= 12 (FMA3) -> ON
Total available: 12
Parallel framework: tbb (nthreads=4)

@Biswa96
Copy link
Member

Biswa96 commented Apr 23, 2021

Any chance to upstream the patches in proper way?

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Apr 23, 2021

Any chance to upstream the patches in proper way?

@Biswa The new patch I added, 0105, I had planned to do exactly that. Then I discovered that (merged) PR. So I guess it depends on the answer to my question there. If linking in libiconv is the way to go, then absolutely I'll submit the change upstream. If there's some reason it's a bad idea to do that, and disabling is the right move, then I'd say we should replace my patch with the one from that PR (especially since it's already upstreamed).

But there was no real explanation given for why iconv was disabled instead of linked with the library, when that patch was submitted. So I'm waiting to hear.

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Apr 23, 2021

(The other, preexisting patches, I'm not at all familiar with their history. I couldn't comment on whether anyone has tried to submit them upstream, or what the outcome was of those attempts. If nobody has, I'd be game to take a stab at it, though none of it is actually my code -- despite git-format-patch plastering my name all over the re-rolled versions, I'm now realizing and possibly regretting. 😉 )

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Apr 23, 2021

@Biswa96 (Whoops, sorry about mangling your ID last time)

The submitter of opencv/opencv_contrib#2916 admitted that disabling iconv was a punt, and agrees that linking with the library is the better way to go. So I'll be submitting my 0105 patch as a new PR to opencv_contrib shortly, and it can stand as-is in the packaging for the time being.

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Apr 23, 2021

Patch 0105 submitted upstream: opencv/opencv_contrib#2931

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Apr 24, 2021

At the upstream PR, we settled on one additional change affecting builders who don't have iconv available. That doesn't include us (since libiconv is listed as a prereq in the PKGBUILD and will always be available), but just for consistency with upstream I've incorporated it into my patch 0105 here, as well.

ferdnyc and others added 3 commits May 19, 2021 20:44
- Add patch 0105 to fix wechat_qrcode build
- Add libiconv as a dependency
- Disable PKG_CONFIG_WITHOUT_PREFIX
  The new OpenCVUtils.cmake functions create targets for
  dependencies that break on paths rooted at /mingw64/.
- Re-roll all fuzzy patches
- Remove dropped patch 0005
@lazka lazka merged commit 2781543 into msys2:master May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants