[PR #4373] [MERGED] gcov: fix build failure with gcc 11.1.0 #5136

Closed
opened 2026-05-05 10:32:55 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netblue30/firejail/pull/4373
Author: @kmk3
Created: 6/25/2021
Status: Merged
Merged: 6/27/2021
Merged by: @netblue30

Base: masterHead: gcov-fix-build-gcc11


📝 Commits (1)

  • b408b20 gcov: fix build failure with gcc 11.1.0

📊 Changes

15 files changed (+54 additions, -14 deletions)

View changed files

📝 src/firejail/appimage.c (+1 -1)
📝 src/firejail/chroot.c (+1 -1)
📝 src/firejail/fs.c (+1 -1)
📝 src/firejail/fs_mkdir.c (+1 -1)
📝 src/firejail/ls.c (+1 -1)
📝 src/firejail/main.c (+1 -1)
📝 src/firejail/profile.c (+1 -1)
📝 src/firejail/rlimit.c (+1 -1)
📝 src/firejail/sandbox.c (+1 -1)
📝 src/firejail/util.c (+1 -1)
📝 src/firemon/interface.c (+1 -1)
📝 src/firemon/netstats.c (+1 -1)
📝 src/firemon/procevent.c (+1 -1)
📝 src/firemon/top.c (+1 -1)
src/include/gcov_wrapper.h (+40 -0)

📄 Description

The build currently fails if gcov support is enabled:

$ pacman -Q gcc
gcc 11.1.0-1
$ ./configure --prefix=/usr --enable-apparmor --enable-gcov >/dev/null
$ make >/dev/null
[...]
netstats.c: In function ‘netstats’:
netstats.c:250:25: warning: implicit declaration of function ‘__gcov_flush’; did you mean ‘__gcov_dump’? [-Wimplicit-function-declaration]
  250 |                         __gcov_flush();
      |                         ^~~~~~~~~~~~
      |                         __gcov_dump
[...]
/usr/bin/ld: netstats.o: in function `netstats':
/tmp/firejail-git/src/firejail-git/src/firemon/netstats.c:250: undefined reference to `__gcov_flush'
[...]
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:10: firemon] Error 1
make: *** [Makefile:42: src/firemon/firemon] Error 2
[...]

This happens because __gcov_flush was removed on gcc 11.1.0[1] [2] [3].
See the following gcc commits:

  • d39f7dc8d5 ("Do locking for __gcov_dump and __gcov_reset as well.")
  • c0532db47d ("Use __gcov_dump and __gcov_reset in execv and fork context.")
  • 811b7636cb ("Remove __gcov_flush.")

Its implementation did the following[4]:

  __gcov_lock ();
  __gcov_dump_int ();
  __gcov_reset_int ();
  __gcov_unlock ();

As hinted in the commit messages above, the function is no longer needed
because locking is now done inside each of __gcov_dump and __gcov_reset.

So add an implementation of __gcov_flush (on a new gcov_wrapper.h file)
for gcc >= 11.1.0, which just calls __gcov_dump and then __gcov_reset.

Commands used to search and replace:

$ git grep -Flz '#include <gcov.h>' -- '*.c' |
  xargs -0 -I '{}' sh -c \
  "printf '%s\n' \"\`sed 's|<gcov\\.h>|\"../include/gcov_wrapper.h\"|' '{}'\`\" >'{}'"

Note: This is the continuation of commit 31557e9c7 ("gcov: add missing
gcov.h includes") / PR #4360.

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d39f7dc8d558ca31a661b02d08ff090ce65e6652
[2] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c0532db47d092430f8e8f497b2dc53343527bb13
[3] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=811b7636cb8c10f1a550a76242b5666c7ae36da2
[4] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/libgcov-interface.c;h=855e8612018d1c9caf90396a3271337aaefdb9b3#l86


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netblue30/firejail/pull/4373 **Author:** [@kmk3](https://github.com/kmk3) **Created:** 6/25/2021 **Status:** ✅ Merged **Merged:** 6/27/2021 **Merged by:** [@netblue30](https://github.com/netblue30) **Base:** `master` ← **Head:** `gcov-fix-build-gcc11` --- ### 📝 Commits (1) - [`b408b20`](https://github.com/netblue30/firejail/commit/b408b20c70816ed16ed6343e36af3f9d26976752) gcov: fix build failure with gcc 11.1.0 ### 📊 Changes **15 files changed** (+54 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src/firejail/appimage.c` (+1 -1) 📝 `src/firejail/chroot.c` (+1 -1) 📝 `src/firejail/fs.c` (+1 -1) 📝 `src/firejail/fs_mkdir.c` (+1 -1) 📝 `src/firejail/ls.c` (+1 -1) 📝 `src/firejail/main.c` (+1 -1) 📝 `src/firejail/profile.c` (+1 -1) 📝 `src/firejail/rlimit.c` (+1 -1) 📝 `src/firejail/sandbox.c` (+1 -1) 📝 `src/firejail/util.c` (+1 -1) 📝 `src/firemon/interface.c` (+1 -1) 📝 `src/firemon/netstats.c` (+1 -1) 📝 `src/firemon/procevent.c` (+1 -1) 📝 `src/firemon/top.c` (+1 -1) ➕ `src/include/gcov_wrapper.h` (+40 -0) </details> ### 📄 Description The build currently fails if gcov support is enabled: $ pacman -Q gcc gcc 11.1.0-1 $ ./configure --prefix=/usr --enable-apparmor --enable-gcov >/dev/null $ make >/dev/null [...] netstats.c: In function ‘netstats’: netstats.c:250:25: warning: implicit declaration of function ‘__gcov_flush’; did you mean ‘__gcov_dump’? [-Wimplicit-function-declaration] 250 | __gcov_flush(); | ^~~~~~~~~~~~ | __gcov_dump [...] /usr/bin/ld: netstats.o: in function `netstats': /tmp/firejail-git/src/firejail-git/src/firemon/netstats.c:250: undefined reference to `__gcov_flush' [...] collect2: error: ld returned 1 exit status make[1]: *** [Makefile:10: firemon] Error 1 make: *** [Makefile:42: src/firemon/firemon] Error 2 [...] This happens because __gcov_flush was removed on gcc 11.1.0[1] [2] [3]. See the following gcc commits: * d39f7dc8d5 ("Do locking for __gcov_dump and __gcov_reset as well.") * c0532db47d ("Use __gcov_dump and __gcov_reset in execv and fork context.") * 811b7636cb ("Remove __gcov_flush.") Its implementation did the following[4]: __gcov_lock (); __gcov_dump_int (); __gcov_reset_int (); __gcov_unlock (); As hinted in the commit messages above, the function is no longer needed because locking is now done inside each of __gcov_dump and __gcov_reset. So add an implementation of __gcov_flush (on a new gcov_wrapper.h file) for gcc >= 11.1.0, which just calls __gcov_dump and then __gcov_reset. Commands used to search and replace: $ git grep -Flz '#include <gcov.h>' -- '*.c' | xargs -0 -I '{}' sh -c \ "printf '%s\n' \"\`sed 's|<gcov\\.h>|\"../include/gcov_wrapper.h\"|' '{}'\`\" >'{}'" Note: This is the continuation of commit 31557e9c7 ("gcov: add missing gcov.h includes") / PR #4360. [1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d39f7dc8d558ca31a661b02d08ff090ce65e6652 [2] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c0532db47d092430f8e8f497b2dc53343527bb13 [3] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=811b7636cb8c10f1a550a76242b5666c7ae36da2 [4] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/libgcov-interface.c;h=855e8612018d1c9caf90396a3271337aaefdb9b3#l86 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 10:32:55 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#5136
No description provided.