https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108328
Bug ID: 108328 Summary: gcc --help -v doesn't work correctly in some circumstances in gcc>=10 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver Assignee: unassigned at gcc dot gnu.org Reporter: sagimor6 at gmail dot com Target Milestone: --- Created attachment 54210 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54210&action=edit patch to fix the bug works: gcc --help -v 2>/dev/null | grep ffunction-sections (prints the ffunction-section description) doesn't work: gcc -Wl,--some-flag --help -v 2>/dev/null | grep ffunction-sections (nothing is printed) I am sure that this behavior is incorrect. also (but maybe less important): gcc a.c a.c a.c a.c --help -v 2>/dev/null | grep ffunction-sections this prints the help 4 times (as many times as there are input files). I am also sure that this behavior is incorrect. Some programs depend on --help -v to work, for example python. python checks if fwrapv is supported with the mechanism. buildroot uses something called toolchain-wrapper to add default flags to gcc when you call it, if you would check the bootlin compilers in aarch64 they add -Wl,-z,relro by default. So, if you were to compile python with a bootlin compiler with gcc>=10 it will not compile with all the correct flags (no fwrapv). This is just one example (this is where I noticed the bug). The bug was introduced in the following commit: https://github.com/gcc-mirror/gcc/commit/2dcfc8722b6146e479039a2f8994050c772b25e6 (commit 2dcfc8722b6146e479039a2f8994050c772b25e6) So the bug only exists in gcc>=10, and doesn't in gcc<=9. I created a patch to revert a small part of this commit (will send to the gcc patches mailing list as well). I tested the patch. One of the reasons I am sure this is a bug is because of the comment above the if statement: "Ensure we only invoke each subprocess once.", so the help should be printed once and only once.