[MDEV-30573] Server doesn't build with GCOV by GCC 11+ Created: 2023-02-05  Updated: 2023-02-16  Resolved: 2023-02-06

Status: Closed
Project: MariaDB Server
Component/s: Compiling, Debug
Affects Version/s: 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.11.3, 11.0.1, 10.6.13, 10.8.8, 10.9.6, 10.10.4

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: None


 Description   

10.6 9f16d1535

/usr/bin/ld: libdbug.a(dbug.c.o): in function `_db_suicide_':
/data/src/10.6-bug/dbug/dbug.c:2215: undefined reference to `__gcov_flush'
/usr/bin/ld: libdbug.a(dbug.c.o): in function `_db_my_assert':
/data/src/10.6-bug/dbug/dbug.c:2265: undefined reference to `__gcov_flush'
collect2: error: ld returned 1 exit status
make[2]: *** [dbug/CMakeFiles/tests.dir/build.make:104: dbug/tests] Error 1
make[1]: *** [CMakeFiles/Makefile2:8982: dbug/CMakeFiles/tests.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

The recipe from stackoverflow helps, but I don't know (didn't check) whether it will still build with older compilers.

Recipe diff

diff --git a/dbug/dbug.c b/dbug/dbug.c
index a6d893e3f49..45809c521d6 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -86,7 +86,7 @@
 #include <m_string.h>
 #include <errno.h>
 #ifdef HAVE_gcov
-extern void __gcov_flush();
+extern void __gcov_dump();
 #endif
 
 #ifndef DBUG_OFF
@@ -2212,7 +2212,7 @@ void _db_suicide_()
   fprintf(stderr, "SIGKILL myself\n");
   fflush(stderr);
 #ifdef HAVE_gcov
-  __gcov_flush();
+  __gcov_dump();
 #endif
 
   retval= kill(getpid(), SIGKILL);
@@ -2262,7 +2262,7 @@ my_bool _db_my_assert(const char *file, int line, const char *msg)
     fprintf(stderr, "%s:%d: assert: %s\n", file, line, msg);
     fflush(stderr);
 #ifdef HAVE_gcov
-    __gcov_flush();
+    __gcov_dump();
 #endif
   }
   return a;
diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c
index 844d8a0b28f..42a8c5f192e 100644
--- a/mysys/stacktrace.c
+++ b/mysys/stacktrace.c
@@ -410,7 +410,7 @@ void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack,
 void my_write_core(int sig)
 {
 #ifdef HAVE_gcov
-  extern void __gcov_flush(void);
+  extern void __gcov_dump(void);
 #endif
   signal(sig, SIG_DFL);
 #ifdef HAVE_gcov
@@ -419,7 +419,7 @@ void my_write_core(int sig)
     information from this process, causing gcov output to be incomplete.
     So we force the writing of coverage information here before terminating.
   */
-  __gcov_flush();
+  __gcov_dump();
 #endif
   pthread_kill(pthread_self(), sig);
 #if defined(P_MYID) && !defined(SCO)



 Comments   
Comment by Daniel Black [ 2023-02-06 ]

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93623

Removed gcc-11.0

> Why did you remove __gcov_flush ?

It is not a supported _gcov* library call:

https://gcc.gnu.org/onlinedocs/gcc/Gcov-and-Optimization.html

Caused by 3b8d4180d5f7f8c0d72be734f13a8de05ef537cb.

__gcov_dump should be covered by gcov.h include rather than our own define.

Comment by Oleksandr Byelkin [ 2023-02-06 ]

OK to push

Generated at Thu Feb 08 10:17:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.