ARM-software / armnn

Arm NN ML Software. The code here is a read-only mirror of https://review.mlplatform.org/admin/repos/ml/armnn
https://developer.arm.com/products/processors/machine-learning/arm-nn
MIT License
1.14k stars 307 forks source link

Armnn 22.02 fails to build with GCC12 #643

Closed ggardet closed 2 years ago

ggardet commented 2 years ago

Armnn 22.02 fails to build with GCC12 on openSUSE Tumbleweed:

[   75s] [  5%] Building CXX object src/backends/reference/CMakeFiles/armnnRefBackend.dir/RefWorkloadFactory.cpp.o
[   75s] cd /home/abuild/rpmbuild/BUILD/armnn-22.02/build/src/backends/reference && /usr/bin/c++ -DARMCOMPUTENEON_ENABLED -DARMNNREF_ENABLED -DARMNN_SERIALIZER -DARMNN_SERIALIZER_SCHEMA_PATH=\"/home/abuild/rpmbuild/BUILD/armnn-22.02/src/armnnSerializer/ArmnnSchema.fbs\" -DARMNN_TF_LITE_PARSER -DDYNAMIC_BACKEND_BUILD_DIR=\"/home/abuild/rpmbuild/BUILD/armnn-22.02/build\" -I/home/abuild/rpmbuild/BUILD/armnn-22.02/include -I/home/abuild/rpmbuild/BUILD/armnn-22.02/profiling -I/home/abuild/rpmbuild/BUILD/armnn-22.02/src/armnn -I/home/abuild/rpmbuild/BUILD/armnn-22.02/src/armnnUtils -I/home/abuild/rpmbuild/BUILD/armnn-22.02/src/backends -I/home/abuild/rpmbuild/BUILD/armnn-22.02/src/profiling -I/home/abuild/rpmbuild/BUILD/armnn-22.02/profiling/common/include -isystem /home/abuild/rpmbuild/BUILD/armnn-22.02/third-party -isystem /usr/include/half -mbranch-protection=standard -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g -pthread -std=c++14 -Wall -Wextra -Werror -Wold-style-cast -Wno-missing-braces -Wconversion -Wsign-conversion  -Wno-psabi -O2 -g  -fPIC -MD -MT src/backends/reference/CMakeFiles/armnnRefBackend.dir/RefWorkloadFactory.cpp.o -MF CMakeFiles/armnnRefBackend.dir/RefWorkloadFactory.cpp.o.d -o CMakeFiles/armnnRefBackend.dir/RefWorkloadFactory.cpp.o -c /home/abuild/rpmbuild/BUILD/armnn-22.02/src/backends/reference/RefWorkloadFactory.cpp
[   75s] In file included from /home/abuild/rpmbuild/BUILD/armnn-22.02/src/backends/reference/workloads/RefElementwiseWorkload.hpp:13,
[   75s]                  from /home/abuild/rpmbuild/BUILD/armnn-22.02/src/backends/reference/workloads/RefWorkloads.hpp:39,
[   75s]                  from /home/abuild/rpmbuild/BUILD/armnn-22.02/src/backends/reference/RefWorkloadFactory.cpp:12:
[   75s] /home/abuild/rpmbuild/BUILD/armnn-22.02/src/backends/reference/workloads/Maximum.hpp:13:30: error: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Werror=deprecated-declarations]
[   75s]    13 | struct maximum : public std::binary_function<T, T, T>
[   75s]       |                              ^~~~~~~~~~~~~~~
[   75s] In file included from /usr/include/c++/12/functional:49,
[   75s]                  from /home/abuild/rpmbuild/BUILD/armnn-22.02/include/armnn/Types.hpp:8,
[   75s]                  from /home/abuild/rpmbuild/BUILD/armnn-22.02/include/armnn/MemorySources.hpp:8,
[   75s]                  from /home/abuild/rpmbuild/BUILD/armnn-22.02/include/armnn/backends/ITensorHandle.hpp:7,
[   75s]                  from /home/abuild/rpmbuild/BUILD/armnn-22.02/include/armnn/backends/ITensorHandleFactory.hpp:8,
[   75s]                  from /home/abuild/rpmbuild/BUILD/armnn-22.02/src/armnn/Layer.hpp:9,
[   75s]                  from /home/abuild/rpmbuild/BUILD/armnn-22.02/src/backends/reference/RefWorkloadFactory.cpp:5:
[   75s] /usr/include/c++/12/bits/stl_function.h:131:12: note: declared here
[   75s]   131 |     struct binary_function
[   75s]       |            ^~~~~~~~~~~~~~~
[   75s] In file included from /home/abuild/rpmbuild/BUILD/armnn-22.02/src/backends/reference/workloads/RefElementwiseWorkload.hpp:14:
[   75s] /home/abuild/rpmbuild/BUILD/armnn-22.02/src/backends/reference/workloads/Minimum.hpp:12:30: error: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Werror=deprecated-declarations]
[   75s]    12 | struct minimum : public std::binary_function<T, T, T>
[   75s]       |                              ^~~~~~~~~~~~~~~
[   75s] /usr/include/c++/12/bits/stl_function.h:131:12: note: declared here
[   75s]   131 |     struct binary_function
[   75s]       |            ^~~~~~~~~~~~~~~
[   75s] cc1plus: all warnings being treated as errors
[   75s] make[2]: *** [src/backends/reference/CMakeFiles/armnnRefBackend.dir/build.make:149: src/backends/reference/CMakeFiles/armnnRefBackend.dir/RefWorkloadFactory.cpp.o] Error 1
[   75s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/armnn-22.02/build'
[   75s] make[1]: *** [CMakeFiles/Makefile2:2204: src/backends/reference/CMakeFiles/armnnRefBackend.dir/all] Error 2
[   75s] make[1]: *** Waiting for unfinished jobs....
MatthewARM commented 2 years ago

This is a legitimate issue. std::binary_function and std::unary_function were deprecated in C++11 and removed in C++17.

Since we're using C++14 the warning is correct. Tactical fix for your build could be to compile with "-Wno-deprecated-declarations".

Short-term fix in the code should be to declare result_type and first_argument_type typedefs in Minimum and Maximum (rather than using std::binary_function) and in Abs, Rsqrt, Sin, Sqrt, Exp, Log (instead of std::unary_function). That's how the standard library has solved the same issue. This will fix the code for C++14 (and is future-compatible to C++17).

If we ever move forward to compatibility with C++20 the way types are determined in the reference workloads will need to be re-written, and result_type and first_argument_type will get removed from the standard functors.

MatthewARM commented 2 years ago

Patch up for review https://review.mlplatform.org/c/ml/armnn/+/7574

MatthewARM commented 2 years ago

I don't have g++-12 easily available at the moment, so there could be other problems to fix.

MatthewARM commented 2 years ago

@ggardet I hope this patch at least improves things.

ggardet commented 2 years ago

@MatthewARM Yes, it improved things, but now, I have another (unrelated) error. See: https://github.com/ARM-software/armnn/issues/644

catcor01 commented 2 years ago

I am going to close this issue as it has been resolved. If you are still experiencing problems, please do not hesitate to reopen this ticket or create a new issue.

Kind Regards, Cathal.