https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117739
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:88ca0670c79f123cc84928f78cd3d5eb46b91338 commit r14-11307-g88ca0670c79f123cc84928f78cd3d5eb46b91338 Author: Marek Polacek <pola...@redhat.com> Date: Tue Nov 26 14:37:21 2024 -0500 driver: -fhardened and -z lazy/-z norelro [PR117739] As the manual states, using "-fhardened -fstack-protector" will produce a warning because -fhardened wants to enable -fstack-protector-strong, but it can't since it's been overriden by the weaker -fstack-protector. -fhardened also attempts to enable -Wl,-z,relro,-z,now. By the same logic as above, "-fhardened -z norelro" or "-fhardened -z lazy" should produce the same warning. But we don't detect this combination, so this patch fixes it. I also renamed a variable to better reflect its purpose. Also don't check warn_hardened in process_command, since it's always true there. Also tweak wording in the manual as Jon Wakely suggested on IRC. PR driver/117739 gcc/ChangeLog: * doc/invoke.texi: Tweak wording for -Whardened. * gcc.cc (driver_handle_option): If -z lazy or -z norelro was specified, don't enable linker hardening. (process_command): Don't check warn_hardened. gcc/testsuite/ChangeLog: * c-c++-common/fhardened-16.c: New test. * c-c++-common/fhardened-17.c: New test. * c-c++-common/fhardened-18.c: New test. * c-c++-common/fhardened-19.c: New test. * c-c++-common/fhardened-20.c: New test. * c-c++-common/fhardened-21.c: New test. Reviewed-by: Jakub Jelinek <ja...@redhat.com> (cherry picked from commit a134dcd8a010744a0097d190f73a4efc2e381531)