Bug 1146096 - LTO: opencv build fails on ppc64le
LTO: opencv build fails on ppc64le
Status: NEW
Classification: openSUSE
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Other
Current
PowerPC-64 All
: P5 - None : Normal (vote)
: ---
Assigned To: Martin Liška
E-mail List
:
Depends on:
Blocks: 1133084
  Show dependency treegraph
 
Reported: 2019-08-19 08:30 UTC by Jonathan Brielmaier
Modified: 2022-01-12 14:45 UTC (History)
4 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
opencv_standard_ppc64le_201908191158.log (1.24 MB, text/x-log)
2019-08-19 12:13 UTC, Michel Normand
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Brielmaier 2019-08-19 08:30:20 UTC
Building opencv on ppc64le leads to a build failure:

[  428s] [ 33%] Linking CXX shared library ../../lib/libopencv_core.so
[  428s] cd /home/abuild/rpmbuild/BUILD/opencv-4.1.1/build/modules/core && /usr/bin/cmake -E cmake_link_script CMakeFiles/opencv_core.dir/link.txt --verbose=1
[  428s] /usr/bin/c++ -fPIC -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=8 -g -DNDEBUG   -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 -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fno-omit-frame-pointer -ffunction-sections -fdata-sections  -mcpu=power8 -fvisibility=hidden -fvisibility-inlines-hidden -O2 -g -DNDEBUG -flto=8 -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now  -Wl,--gc-sections -shared -Wl,-soname,libopencv_core.so.4.1 -o ../../lib/libopencv_core.so.4.1.1 CMakeFiles/opencv_core.dir/src/algorithm.cpp.o CMakeFiles/opencv_core.dir/src/alloc.cpp.o CMakeFiles/opencv_core.dir/src/arithm.cpp.o CMakeFiles/opencv_core.dir/src/arithm.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/array.cpp.o CMakeFiles/opencv_core.dir/src/async.cpp.o CMakeFiles/opencv_core.dir/src/batch_distance.cpp.o CMakeFiles/opencv_core.dir/src/bindings_utils.cpp.o CMakeFiles/opencv_core.dir/src/channels.cpp.o CMakeFiles/opencv_core.dir/src/check.cpp.o CMakeFiles/opencv_core.dir/src/command_line_parser.cpp.o CMakeFiles/opencv_core.dir/src/conjugate_gradient.cpp.o CMakeFiles/opencv_core.dir/src/convert.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/convert_c.cpp.o CMakeFiles/opencv_core.dir/src/convert_scale.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/copy.cpp.o CMakeFiles/opencv_core.dir/src/count_non_zero.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/cuda_gpu_mat.cpp.o CMakeFiles/opencv_core.dir/src/cuda_host_mem.cpp.o CMakeFiles/opencv_core.dir/src/cuda_info.cpp.o CMakeFiles/opencv_core.dir/src/cuda_stream.cpp.o CMakeFiles/opencv_core.dir/src/datastructs.cpp.o CMakeFiles/opencv_core.dir/src/directx.cpp.o CMakeFiles/opencv_core.dir/src/downhill_simplex.cpp.o CMakeFiles/opencv_core.dir/src/dxt.cpp.o CMakeFiles/opencv_core.dir/src/gl_core_3_1.cpp.o CMakeFiles/opencv_core.dir/src/glob.cpp.o CMakeFiles/opencv_core.dir/src/hal_internal.cpp.o CMakeFiles/opencv_core.dir/src/kmeans.cpp.o CMakeFiles/opencv_core.dir/src/lapack.cpp.o CMakeFiles/opencv_core.dir/src/lda.cpp.o CMakeFiles/opencv_core.dir/src/logger.cpp.o CMakeFiles/opencv_core.dir/src/lpsolver.cpp.o CMakeFiles/opencv_core.dir/src/lut.cpp.o CMakeFiles/opencv_core.dir/src/mathfuncs.cpp.o CMakeFiles/opencv_core.dir/src/mathfuncs_core.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/matmul.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/matrix.cpp.o CMakeFiles/opencv_core.dir/src/matrix_c.cpp.o CMakeFiles/opencv_core.dir/src/matrix_decomp.cpp.o CMakeFiles/opencv_core.dir/src/matrix_expressions.cpp.o CMakeFiles/opencv_core.dir/src/matrix_iterator.cpp.o CMakeFiles/opencv_core.dir/src/matrix_operations.cpp.o CMakeFiles/opencv_core.dir/src/matrix_sparse.cpp.o CMakeFiles/opencv_core.dir/src/matrix_wrap.cpp.o CMakeFiles/opencv_core.dir/src/mean.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/merge.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/minmax.cpp.o CMakeFiles/opencv_core.dir/src/norm.cpp.o CMakeFiles/opencv_core.dir/src/ocl.cpp.o CMakeFiles/opencv_core.dir/src/opencl/runtime/opencl_clamdblas.cpp.o CMakeFiles/opencv_core.dir/src/opencl/runtime/opencl_clamdfft.cpp.o CMakeFiles/opencv_core.dir/src/opencl/runtime/opencl_core.cpp.o CMakeFiles/opencv_core.dir/src/opengl.cpp.o CMakeFiles/opencv_core.dir/src/out.cpp.o CMakeFiles/opencv_core.dir/src/ovx.cpp.o CMakeFiles/opencv_core.dir/src/parallel.cpp.o CMakeFiles/opencv_core.dir/src/parallel_impl.cpp.o CMakeFiles/opencv_core.dir/src/pca.cpp.o CMakeFiles/opencv_core.dir/src/persistence.cpp.o CMakeFiles/opencv_core.dir/src/persistence_json.cpp.o CMakeFiles/opencv_core.dir/src/persistence_types.cpp.o CMakeFiles/opencv_core.dir/src/persistence_xml.cpp.o CMakeFiles/opencv_core.dir/src/persistence_yml.cpp.o CMakeFiles/opencv_core.dir/src/rand.cpp.o CMakeFiles/opencv_core.dir/src/softfloat.cpp.o CMakeFiles/opencv_core.dir/src/split.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/stat.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/stat_c.cpp.o CMakeFiles/opencv_core.dir/src/stl.cpp.o CMakeFiles/opencv_core.dir/src/sum.dispatch.cpp.o CMakeFiles/opencv_core.dir/src/system.cpp.o CMakeFiles/opencv_core.dir/src/tables.cpp.o CMakeFiles/opencv_core.dir/src/trace.cpp.o CMakeFiles/opencv_core.dir/src/types.cpp.o CMakeFiles/opencv_core.dir/src/umatrix.cpp.o CMakeFiles/opencv_core.dir/src/utils/datafile.cpp.o CMakeFiles/opencv_core.dir/src/utils/filesystem.cpp.o CMakeFiles/opencv_core.dir/src/utils/logtagconfigparser.cpp.o CMakeFiles/opencv_core.dir/src/utils/logtagmanager.cpp.o CMakeFiles/opencv_core.dir/src/utils/samples.cpp.o CMakeFiles/opencv_core.dir/src/va_intel.cpp.o CMakeFiles/opencv_core.dir/opencl_kernels_core.cpp.o CMakeFiles/opencv_core.dir/arithm.vsx3.cpp.o CMakeFiles/opencv_core.dir/convert.vsx3.cpp.o -ldl -lm -lpthread -lrt /usr/lib64/libGL.so /usr/lib64/libGLU.so /usr/lib64/libz.so /usr/lib64/libopenblas.so ../../3rdparty/lib64/libittnotify.a /usr/lib64/cmake/TBB/../../libtbb.so.2 -ldl -Wl,-rpath-link,"\$ORIGIN" 
[  430s] lto1: error: builtin function '__builtin_altivec_vadub' requires the '-mcpu=power9' option
[  430s] lto1: fatal error: target specific builtin not available
[  430s] compilation terminated.
[  430s] lto-wrapper: fatal error: /usr/bin/c++ returned 1 exit status
[  430s] compilation terminated.
[  430s] /usr/lib64/gcc/powerpc64le-suse-linux/9/../../../../powerpc64le-suse-linux/bin/ld: error: lto-wrapper failed
[  430s] collect2: error: ld returned 1 exit status
[  430s] make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/build.make:1380: lib/libopencv_core.so.4.1.1] Error 1
[  430s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/opencv-4.1.1/build'
[  430s] make[1]: *** [CMakeFiles/Makefile2:1422: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
[  430s] make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/opencv-4.1.1/build'
[  430s] make: *** [Makefile:166: all] Error 2

After setting %define _lto_cflags %{nil} on ppc64le the build error was gone.
Comment 1 Michel Normand 2019-08-19 12:13:51 UTC
Created attachment 814536 [details]
opencv_standard_ppc64le_201908191158.log

opencv_standard_ppc64le_201908191158.log show that VSX and VSX3 are enabled while building on a power8 machine.

"CPU_VSX3_FLAGS_ON" was added by upstream commit https://github.com/opencv/opencv/commit/474a0dac49d1fe5ab8bafbeae2329194101676f9

Question: is it normal to enable VSX3 when building on a Power8 machine ?
Comment 2 Jonathan Brielmaier 2019-08-19 12:29:23 UTC
Adding Stefan Brüns to CC. He is the maintainer of opencv.
Comment 3 Stefan Brüns 2019-08-19 12:40:28 UTC
openCV uses runtime dispatch for VSX3, only VSX is part of the baseline.

Without LTO, CPU dependend code generation happens when arithm.vsx3.cpp.o is created (which is done with "-mcpu=power9"), and the "-mcpu=power8" is likely ignored when "only" linking.
Comment 4 Jonathan Brielmaier 2019-08-19 12:47:39 UTC
So maybe we should create an upstream bug. Should I do that? Or is one of you volunteering here...
Comment 5 Stefan Brüns 2019-08-19 12:52:31 UTC
Where is the "-mcpu=power8" flag coming from? Is it part of the default compiler flags on PPC64LE?
Comment 6 Jonathan Brielmaier 2019-08-19 12:58:06 UTC
(In reply to Stefan Brüns from comment #5)
> Where is the "-mcpu=power8" flag coming from? Is it part of the default
> compiler flags on PPC64LE?

I would say from here:
https://github.com/opencv/opencv/blob/ea667d82b30a19b10a6c00edf8acc6e9dd85c429/cmake/OpenCVCompilerOptimizations.cmake#L355

As rpm --eval '%optflags' in Fatory:PowerPC chroot gives:
-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=8 -g

And in the spec file are no signs of addtional compiler flags.
Comment 7 Michel Normand 2019-08-21 11:12:42 UTC
There is a pending lto disable sr, waiting for acceptance at https://build.opensuse.org/request/show/724857
Comment 8 Stefan Brüns 2019-08-21 16:51:14 UTC
Apparently, GCC *really* wants "-mcpu=power9" when using power9 builtins, replacing "-mcpu=power8" with "-maltivec -mvsx" gives the same error.

IMHO this is a GCC bug, the CPU flags duing LTO linking should be inferred from the flags of the linked object files.
Comment 9 Stefan Brüns 2019-08-25 13:18:45 UTC
@Martin: should we file a GCC BR, or will you take care of this?
Comment 10 Martin Liška 2019-08-26 06:28:55 UTC
(In reply to Stefan Brüns from comment #9)
> @Martin: should we file a GCC BR, or will you take care of this?

Please report a GCC upstream issue with a reduced test-case.
Thanks.
Comment 11 Michel Normand 2019-09-23 09:57:48 UTC
(In reply to Michel Normand from comment #7)
> There is a pending lto disable sr, waiting for acceptance at
> https://build.opensuse.org/request/show/724857

and another bypass sr for opencv3 https://build.opensuse.org/request/show/731294 still not yet in TW as pending staging J for https://build.opensuse.org/request/show/731318
Comment 12 Martin Liška 2021-03-02 14:31:12 UTC
(In reply to Stefan Brüns from comment #9)
> @Martin: should we file a GCC BR, or will you take care of this?

Can you please create the GCC BR?