Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not build on GCC10 #269

Open
wookey opened this issue May 12, 2021 · 3 comments
Open

Does not build on GCC10 #269

wookey opened this issue May 12, 2021 · 3 comments

Comments

@wookey
Copy link

wookey commented May 12, 2021

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
Copy link

thanks very much!

@WangQin-wq
Copy link

非常感谢,已解决问题

@oldman1969
Copy link

oldman1969 commented Sep 1, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants