Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 907284

Summary: media-libs/opencv-4.7.0 fails to build (but media-libs/opencv-4.6.0-r4 builds fine) - GCC inlining failed
Product: Gentoo Linux Reporter: Markus Ewald <cygon>
Component: Current packagesAssignee: Paul Zander <negril.nx+gentoo>
Status: RESOLVED OBSOLETE    
Severity: normal CC: cygon, proxy-maint
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Output of emerge --info, emerge --pv and the build log

Description Markus Ewald 2023-05-28 07:38:07 UTC
Created attachment 862709 [details]
Output of emerge --info, emerge --pv and the build log

I can't compile the official OpenCV 4.7.0 ebuild on my system whereas OpenCV 4.6.0 works fine.

The error message coming out of GCC 12.3.1 is "/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/fmaintrin.h:63:1: error: inlining failed in call to ‘always_inline’ ‘__m256 _mm256_fmadd_ps(__m256, __m256, __m256)’: target specific option mismatch"

LTO is disabled.

Perhaps of relevance: I have added all supported CPU instruction set extensions to my USE and CPU_FLAGS because I wish to speed up OpenCV, PyTorch and NCNN as much as possible on this system:

-------------------

# Architecture-specific optimizations for certain packages
USE="mmx sse sse2 ssse3 sse4_1 sse4_2 avx avx2 f16c popcnt fma"

CPU_FLAGS_X86="mmx sse sse2 ssse3 sse4_1 sse4_2 avx avx2 f16c popcnt fma"

# Not listed by /proc/cpuinfo - but supported according to
# https://en.wikipedia.org/wiki/Broadwell_(microarchitecture,
# https://en.wikichip.org/wiki/intel/xeon_e5/e5-2697a_v4)
USE="${USE} mmxext sse3"

CPU_FLAGS_X86="${CPU_FLAGS_X86} sse3"

-------------------

The message 'target specific option mismatch' usually appears when LTO'ing two intermediate files that have been compiled with mismatching GCC options. While LTO is off, the GCC options between other files and the problem file (`modules/dnn/src/layers/fast_convolution/fast_convolution.avx2.cpp`) does differ:

-------------------

# Other files being compiled
/usr/bin/x86_64-pc-linux-gnu-g++ -m32 -mfpmath=sse -DCVAPI_EXPORTS -DENABLE_PLUGINS -DHAVE_PROTOBUF=1 -DOPENCV_DNN_EXTERNAL_PROTOBUF=1 -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.7.0/work/opencv-4.7.0/modules/dnn/include -I/var/tmp/portage/media-libs/opencv-4.7.0/work/opencv-4.7.0_build-abi_x86_32.x86/modules/dnn -I/var/tmp/portage/media-libs/opencv-4.7.0/work/opencv-4.7.0/modules/core/include -I/var/tmp/portage/media-libs/opencv-4.7.0/work/opencv-4.7.0/modules/imgproc/include -isystem /var/tmp/portage/media-libs/opencv-4.7.0/work/opencv-4.7.0_build-abi_x86_32.x86 -isystem /usr/include/eigen3  -O2 -pipe   -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wundef -Winit-self -Wpointer-arith -Wsign-promo -Wuninitialized -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 -mavx -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-sign-compare -Wno-invalid-offsetof -std=c++11 -fPIC -MD

# fast_convolution.avx2.cpp being compiled
/usr/bin/x86_64-pc-linux-gnu-g++ -DCVAPI_EXPORTS -DENABLE_PLUGINS -DHAVE_PROTOBUF=1 -DOPENCV_DNN_EXTERNAL_PROTOBUF=1 -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DCV_CPU_DISPATCH_MODE=AVX2 -I/var/tmp/portage/media-libs/opencv-4.7.0/work/opencv-4.7.0/modules/dnn/include -I/var/tmp/portage/media-libs/opencv-4.7.0/work/opencv-4.7.0_build-abi_x86_64.amd64/modules/dnn -I/var/tmp/portage/media-libs/opencv-4.7.0/work/opencv-4.7.0/modules/core/include -I/var/tmp/portage/media-libs/opencv-4.7.0/work/opencv-4.7.0/modules/imgproc/include -isystem /var/tmp/portage/media-libs/opencv-4.7.0/work/opencv-4.7.0_build-abi_x86_64.amd64 -isystem /usr/include/eigen3  -O2 -pipe   -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wundef -Winit-self -Wpointer-arith -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mavx -mavx2 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-sign-compare -Wno-invalid-offsetof -std=c++11 -fPIC -MD

-------------------

The `-mfpmath=sse` option is, for some reason, not used on `fast_convolution.avx2.cpp`.

-------------------

Attached:
Comment 1 Paul Zander 2024-04-21 17:54:25 UTC
Is this still relevant for 4.8.1-r1 or 4.9.0?
Comment 2 Markus Ewald 2024-04-22 12:19:19 UTC
I just checked, my system now has opencv 4.8.1-r1 installed, so the compilation error no longer occurs.