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
Created attachment 664252 [details] build.log
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
Probably should have added a constraint in the ebuild to force cpu_flag_avx and abi_x86_32 mutual exclusive.
Can you also test if you disable avx and enable avx2 or avx512f alone, the compiling is still fine?
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.
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?
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.
I see. The affected code was added by https://github.com/opencv/opencv/commit/75315fb297a010153d3acab8111ebb87d909cdcf.
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.
*** Bug 747307 has been marked as a duplicate of this bug. ***
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.
Alright then. For starters we need to file a bug report to the upstream developers.
(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.
I confirm USE=-cpu_flags_x86_avx2 emerge -1 opencv compiles well.
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.
There is an old similar issue, more than one year old: https://github.com/opencv/opencv/issues/14239
(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.
(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.
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(+)