Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 747163 - media-libs/opencv-4.4.0 fails to compile on amd64 with ABI_X86="32" (error: there are no arguments to _mm256_extract_epi64 that depend on a template par)
Summary: media-libs/opencv-4.4.0 fails to compile on amd64 with ABI_X86="32" (error: t...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Amy Liffey
URL:
Whiteboard:
Keywords: PullRequest
: 747307 (view as bug list)
Depends on:
Blocks: 746596
  Show dependency tree
 
Reported: 2020-10-07 19:56 UTC by crabbed halo ablution
Modified: 2020-10-29 17:50 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,142.57 KB, text/plain)
2020-10-07 19:58 UTC, crabbed halo ablution
Details

Note You need to log in before you can comment on or make changes to this bug.
Description crabbed halo ablution 2020-10-07 19:56:50 UTC
ninja -v -j1 -l0
[1/445] cd /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0_build-abi_x86_32.x86 && /usr/bin/cmake -DCMAKE_HELPER_SCRIPT=/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0_build-abi_x86_32.x86/OpenCVGenPkgConfig.info.cmake -P /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/cmake/OpenCVGenPkgconfig.cmake
[2/445] cd /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0_build-abi_x86_32.x86/modules/core && /usr/bin/cmake -DMODULE_NAME=core -DCL_DIR=/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/opencl -DOUTPUT=/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0_build-abi_x86_32.x86/modules/core/opencl_kernels_core.cpp -P /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/cmake/cl2cpp.cmake
[3/445] /usr/bin/x86_64-pc-linux-gnu-g++ -m32 -DCVAPI_EXPORTS -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE="long long" -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include -Imodules/core -isystem . -isystem /usr/include/eigen3  -march=native -mtune=native -ggdb -O2 -pipe   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mfma -mavx -mavx2 -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -fPIC -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o -MF modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o.d -o modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o -c /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/algorithm.cpp
FAILED: modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o 
/usr/bin/x86_64-pc-linux-gnu-g++ -m32 -DCVAPI_EXPORTS -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE="long long" -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include -Imodules/core -isystem . -isystem /usr/include/eigen3  -march=native -mtune=native -ggdb -O2 -pipe   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mfma -mavx -mavx2 -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -fPIC -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o -MF modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o.d -o modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o -c /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/algorithm.cpp
In file included from /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include/opencv2/core/hal/intrin.hpp:247,
                 from /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/precomp.hpp:85,
                 from /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/algorithm.cpp:43:
/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include/opencv2/core/hal/intrin_avx.hpp: In function ‘int64 cv::hal_baseline::_v256_extract_epi64(const __m256i&)’:
/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include/opencv2/core/hal/intrin_avx.hpp:130:12: error: there are no arguments to ‘_mm256_extract_epi64’ that depend on a template parameter, so a declaration of ‘_mm256_extract_epi64’ must be available [-fpermissive]
  130 |     return _mm256_extract_epi64(a, i);
      |            ^~~~~~~~~~~~~~~~~~~~
/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include/opencv2/core/hal/intrin_avx.hpp:130:12: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
ninja: build stopped: subcommand failed.


Reproducible: Always
Comment 1 crabbed halo ablution 2020-10-07 19:58:11 UTC
Created attachment 664252 [details]
build.log
Comment 2 crabbed halo ablution 2020-10-07 20:01:32 UTC
This is presumably a failure to check if the compiler is generating x86_64 (AVX) or x86 (no AVX) code, as described in, e.g. https://github.com/pytorch/pytorch/issues/17901
Comment 3 Ross Charles C. 2020-10-08 01:28:47 UTC
Probably should have added a constraint in the ebuild to force cpu_flag_avx and abi_x86_32 mutual exclusive.
Comment 4 Ross Charles C. 2020-10-08 01:40:59 UTC
Can you also test if you disable avx and enable avx2 or avx512f alone, the compiling is still fine?
Comment 5 crabbed halo ablution 2020-10-08 03:56:25 UTC
Through a process of exclusion, I can report it is the avx2 cpu flag that's causing the compilation error.
CPU_FLAGS_X86="avx f16c fma3 popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3 avx512f"
compiles fine (even though my cpu does not support avx512f)
CPU_FLAGS_X86="avx f16c fma3 popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3 avx512f avx2"
fails to compile with the error above.
Comment 6 Ross Charles C. 2020-10-08 09:04:06 UTC
Ok, after a little digging, now I can attest that the _mm256_extract_epi64 intrinsic (which generates pextrq instruction) exists on x86_64 only, so I suspect that this is an upstream bug. Does it also affect the older v4.1.2 ebuild?
Comment 7 crabbed halo ablution 2020-10-08 09:27:29 UTC
The 4.1.2 ebuild is not affected with CPU_FLAGS_X86="avx avx2 fma3 popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3". Builds and installs fine.
Comment 8 Ross Charles C. 2020-10-08 09:43:15 UTC
I see. The affected code was added by https://github.com/opencv/opencv/commit/75315fb297a010153d3acab8111ebb87d909cdcf.
Comment 9 Ross Charles C. 2020-10-08 12:18:27 UTC
One last piece to the puzzle: have you tried compiling opencv with a less futuristic version of gcc (gcc-8 or gcc-9)? I suspect that the upstream overlooked their commit because the gcc versions they use were less stringent on undefined symbols on header files. I couldn't find it on changelogs but maybe at some point gcc has gone through a behavior change and became less tolerant on undefined symbols by default even if they are not actually used by the program.
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-10-08 12:35:03 UTC
*** Bug 747307 has been marked as a duplicate of this bug. ***
Comment 11 crabbed halo ablution 2020-10-08 13:09:41 UTC
saga /var/db/repos/gentoo/media-libs/opencv # gcc --version
gcc (Gentoo 8.4.0-r1 p2) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Substantially the same outcome:

 * abi_x86_32.x86: running multilib-minimal_abi_src_compile
 * Working in BUILD_DIR: "/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0_build-abi_x86_32.x86"
ninja -v -j1 -l0
[1/445] cd /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0_build-abi_x86_32.x86 && /usr/bin/cmake -DCMAKE_HELPER_SCRIPT=/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0_build-abi_x86_32.x86/OpenCVGenPkgConfig.info.cmake -P /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/cmake/OpenCVGenPkgconfig.cmake
[2/445] cd /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0_build-abi_x86_32.x86/modules/core && /usr/bin/cmake -DMODULE_NAME=core -DCL_DIR=/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/opencl -DOUTPUT=/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0_build-abi_x86_32.x86/modules/core/opencl_kernels_core.cpp -P /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/cmake/cl2cpp.cmake
[3/445] /usr/bin/x86_64-pc-linux-gnu-g++ -m32 -DCVAPI_EXPORTS -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE="long long" -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include -Imodules/core -isystem . -isystem /usr/include/eigen3  -march=native -mtune=native -ggdb -O2 -pipe   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mfma -mavx -mavx2 -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -fPIC -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o -MF modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o.d -o modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o -c /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/algorithm.cpp
FAILED: modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o 
/usr/bin/x86_64-pc-linux-gnu-g++ -m32 -DCVAPI_EXPORTS -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE="long long" -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include -Imodules/core -isystem . -isystem /usr/include/eigen3  -march=native -mtune=native -ggdb -O2 -pipe   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mfma -mavx -mavx2 -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -fPIC -std=c++11 -MD -MT modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o -MF modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o.d -o modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o -c /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/algorithm.cpp
In file included from /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include/opencv2/core/hal/intrin.hpp:247,
                 from /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/precomp.hpp:85,
                 from /var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/src/algorithm.cpp:43:
/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include/opencv2/core/hal/intrin_avx.hpp: In function ‘int64 cv::hal_baseline::_v256_extract_epi64(const __m256i&)’:
/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include/opencv2/core/hal/intrin_avx.hpp:130:12: error: there are no arguments to ‘_mm256_extract_epi64’ that depend on a template parameter, so a declaration of ‘_mm256_extract_epi64’ must be available [-fpermissive]
     return _mm256_extract_epi64(a, i);
            ^~~~~~~~~~~~~~~~~~~~
/var/tmp/portage/media-libs/opencv-4.4.0/work/opencv-4.4.0/modules/core/include/opencv2/core/hal/intrin_avx.hpp:130:12: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
ninja: build stopped: subcommand failed.
Comment 12 Ross Charles C. 2020-10-08 13:45:42 UTC
Alright then. For starters we need to file a bug report to the upstream developers.
Comment 13 Silvio 2020-10-09 06:45:22 UTC
(In reply to Ross Charles C. from comment #9)
> One last piece to the puzzle: have you tried compiling opencv with a less
> futuristic version of gcc (gcc-8 or gcc-9)? I suspect that the upstream
> overlooked their commit because the gcc versions they use were less
> stringent on undefined symbols on header files. I couldn't find it on
> changelogs but maybe at some point gcc has gone through a behavior change
> and became less tolerant on undefined symbols by default even if they are
> not actually used by the program.

I tried to downgrade to gcc:

x86_64-pc-linux-gnu-9.3.0

same problem.
Comment 14 Silvio 2020-10-09 06:50:50 UTC
I confirm 

USE=-cpu_flags_x86_avx2 emerge -1 opencv

compiles well.
Comment 15 Ross Charles C. 2020-10-09 07:09:52 UTC
Can someone report this issue to upstream? (re-create the error but use the latest source from their git tree and outside gentoo's build system of course) I'm almost certain this error does not come from the ebuild script.
Comment 16 Silvio 2020-10-09 07:45:56 UTC
There is an old similar issue, more than one year old:

https://github.com/opencv/opencv/issues/14239
Comment 17 Ross Charles C. 2020-10-09 07:57:21 UTC
(In reply to Silvio from comment #16)
> There is an old similar issue, more than one year old:
> 
> https://github.com/opencv/opencv/issues/14239

That's a totally different issue. Commit 75315fb was only introduced on last November.
Comment 18 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-10-10 07:32:42 UTC
(In reply to Ross Charles C. from comment #17)
> (In reply to Silvio from comment #16)
> > There is an old similar issue, more than one year old:
> > 
> > https://github.com/opencv/opencv/issues/14239
> 
> That's a totally different issue. Commit 75315fb was only introduced on last
> November.

So, to be clear, we still need someone hitting this to report it upstream please.
Comment 19 Larry the Git Cow gentoo-dev 2020-10-16 21:47:58 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5c21b91ad2464439514aae406a0c0d5f310aca1d

commit 5c21b91ad2464439514aae406a0c0d5f310aca1d
Author:     Ross Charles Campbell <rossbridger.cc@gmail.com>
AuthorDate: 2020-10-14 02:17:02 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2020-10-16 21:47:50 +0000

    media-libs/opencv: version bump to 4.5.0
    
    Bug: https://bugs.gentoo.org/701790
    Bug: https://bugs.gentoo.org/700176
    Bug: https://bugs.gentoo.org/717812
    Bug: https://bugs.gentoo.org/703658
    Bug: https://bugs.gentoo.org/689838
    Closes: https://bugs.gentoo.org/666716
    Closes: https://bugs.gentoo.org/747163
    Closes: https://bugs.gentoo.org/729190
    Closes: https://bugs.gentoo.org/699730
    Closes: https://bugs.gentoo.org/672840
    Package-Manager: Portage-3.0.8, Repoman-3.0.1
    
    Signed-off-by: Ross Charles Campbell <rossbridger.cc@gmail.com>
    Closes: https://github.com/gentoo/gentoo/pull/17899
    Signed-off-by: Sam James <sam@gentoo.org>

 media-libs/opencv/Manifest            |   2 +
 media-libs/opencv/opencv-4.5.0.ebuild | 555 ++++++++++++++++++++++++++++++++++
 2 files changed, 557 insertions(+)