Relocation truncated to fit during build of perf tests (opencv_perf_cored.exe)

My environment:
OS: windows 10 64bit
CMake: 3.21.1
MinGW: w64 9.0

I built the project with Clion, and when “[1300/1642] Linking CXX executable bin\opencv_perf_cored.exe”, the build stopped. Here the error message.

modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl27OCL_LUTFixture_LUT_LUT_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl27OCL_ExpFixture_Exp_Exp_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl27OCL_LogFixture_Log_Log_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl27OCL_AddFixture_Add_Add_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl42OCL_SubtractFixture_Subtract_Subtract_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl37OCL_MulFixture_Multiply_Multiply_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl33OCL_DivFixture_Divide_Divide_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl39OCL_AbsDiffFixture_Absdiff_Absdiff_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl51OCL_CartToPolarFixture_CartToPolar_CartToPolar_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl51OCL_PolarToCartFixture_PolarToCart_PolarToCart_Test8TestBodyEv+0x28): relocation truncated to fit: IMAGE_REL_AMD64_REL32 against `.data$.LDFCM0'
modules/core/CMakeFiles/opencv_perf_core.dir/perf/opencl/perf_arithm.cpp.obj:perf_arithm.cp:(.xdata$_ZN11opencv_test3ocl45OCL_MagnitudeFixture_Magnitude_Magnitude_Test8TestBodyEv+0x28): additional relocation overflows omitted from the output

Then I add flags -mcmodel=medium in bulid.ninja, but it did`t work.

relocation truncated to fit

investigate this error message. it’ll lead to an explanation.

you can skip building the perf tests:

cmake -DBUILD_PERF_TESTS=OFF

Thank you, I will try it.

btw, where exatly did you add that ?
(shouldn’t this go into CMAKE_CXX_DEBUG_FLAGS ?)