projectNe10 / Ne10

An open optimized software library project for the ARM® Architecture
Other
1.46k stars 408 forks source link

Does not build on GCC10 #269

Open wookey opened 3 years ago

wookey commented 3 years ago

The default for what happens when you have multiple definitions of a function has changed between GCC9 and GCC10 so NE10 fails to build on GCC10 with:

/usr/bin/c++ -g -O2 -ffile-prefix-map=/home/wookey/packages/ne10/ne10-1.2.1=. -fstack-protector-strong -Wformat -Werror=format-\
security -Wdate-time -D_FORTIFY_SOURCE=2 -fno-strict-aliasing -O2 -DNDEBUG -Wl,-z,relro -rdynamic CMakeFiles/NE10_imgproc_unit_\
test_static.dir/__/modules/imgproc/test/test_main.c.o CMakeFiles/NE10_imgproc_unit_test_static.dir/__/modules/imgproc/test/test\
_suite_resize.c.o CMakeFiles/NE10_imgproc_unit_test_static.dir/__/modules/imgproc/test/test_suite_rotate.c.o CMakeFiles/NE10_im\
gproc_unit_test_static.dir/__/modules/imgproc/test/test_suite_boxfilter.c.o CMakeFiles/NE10_imgproc_unit_test_static.dir/src/se\
atest.c.o CMakeFiles/NE10_imgproc_unit_test_static.dir/src/unit_test_common.c.o CMakeFiles/NE10_imgproc_unit_test_static.dir/sr\
c/NE10_random.c.o -o NE10_imgproc_unit_test_smoke  ../modules/libNE10.a -lm -lrt -lstdc++
/usr/bin/ld: CMakeFiles/NE10_imgproc_unit_test_static.dir/__/modules/imgproc/test/test_suite_resize.c.o:./obj-aarch64-linux-gnu\
/test/./test/include/seatest.h:23: multiple definition of `seatest_simple_test_result'; CMakeFiles/NE10_imgproc_unit_test_stati\
c.dir/__/modules/imgproc/test/test_main.c.o:./obj-aarch64-linux-gnu/test/./test/include/seatest.h:23: first defined here
/usr/bin/ld: CMakeFiles/NE10_imgproc_unit_test_static.dir/__/modules/imgproc/test/test_suite_rotate.c.o:./obj-aarch64-linux-gnu\
/test/./test/include/seatest.h:23: multiple definition of `seatest_simple_test_result'; CMakeFiles/NE10_imgproc_unit_test_stati\
c.dir/__/modules/imgproc/test/test_main.c.o:./obj-aarch64-linux-gnu/test/./test/include/seatest.h:23: first defined here
/usr/bin/ld: CMakeFiles/NE10_imgproc_unit_test_static.dir/__/modules/imgproc/test/test_suite_boxfilter.c.o:./obj-aarch64-linux-\
gnu/test/./test/include/seatest.h:23: multiple definition of `seatest_simple_test_result'; CMakeFiles/NE10_imgproc_unit_test_st\
atic.dir/__/modules/imgproc/test/test_main.c.o:./obj-aarch64-linux-gnu/test/./test/include/seatest.h:23: first defined here
/usr/bin/ld: CMakeFiles/NE10_imgproc_unit_test_static.dir/src/seatest.c.o:./obj-aarch64-linux-gnu/test/./test/include/seatest.h\
:23: multiple definition of `seatest_simple_test_result'; CMakeFiles/NE10_imgproc_unit_test_static.dir/__/modules/imgproc/test/\
test_main.c.o:./obj-aarch64-linux-gnu/test/./test/include/seatest.h:23: first defined here

This debian bug covers the issue: https://bugs.debian.org/987643

The function is indeed defined twice (not just typedefed inthe header and then defined elsewhere): seatest.h: void (*seatest_simple_test_result)(int passed, char* reason, const char* function, unsigned int line);

seatest.c: void (*seatest_simple_test_result)(int passed, char* reason, const char* function, unsigned int line) = seatest_simple_test_result_log;

The simplest way to do it is build with -fcommon so multiple definitions are not an error. This was the default in gcc9, but gcc10 has -fno-common as the default.

I used this patch:

Index: ne10-1.2.1/CMakeLists.txt                                                                                                         
===================================================================
--- ne10-1.2.1.orig/CMakeLists.txt                                                                                                       
+++ ne10-1.2.1/CMakeLists.txt                                                                                                            
@@ -93,10 +93,10 @@ option(NE10_ENABLE_IMGPROC "Build image
 set(NE10_VERSION 10)                                                                                                                   

 if(BUILD_DEBUG)                                                                                                                        
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -O0 -DDEBUG -g -Wall -Wno-unused-but-set-variable")                        
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon -fno-strict-aliasing -O0 -DDEBUG -g -Wall -Wno-unused-but-set-variable")               
     message("-- Building type: DEBUG")                                                                                                 
 else(BUILD_DEBUG)                                                                                                                      
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -O2 -DNDEBUG")                                                             
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon -fno-strict-aliasing -O2 -DNDEBUG")                                                    
     message("-- Building type: RELEASE")                                                                                               
 endif(BUILD_DEBUG)        
oldman1969 commented 1 year ago

thanks very much!

WangQin-wq commented 1 year ago

非常感谢,已解决问题

oldman1969 commented 1 year ago

【自动回复】感谢您的来信,我将尽快对您的邮件进行回复。 祝好! 来自:任政锋 [Auto reply]Thanks for your letter, I will reply to you as soon as possible. From:Zhengfeng Ren