https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119625
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I think --- gcc/lto-opts.cc.jj 2025-01-02 11:23:09.939608681 +0100 +++ gcc/lto-opts.cc 2025-04-04 15:02:17.881941293 +0200 @@ -96,17 +96,17 @@ lto_write_options (void) if (!OPTION_SET_P (flag_cf_protection)) { - append_to_collect_gcc_options ( - &temporary_obstack, &first_p, - global_options.x_flag_cf_protection == CF_NONE - ? "-fcf-protection=none" - : global_options.x_flag_cf_protection == CF_FULL - ? "-fcf-protection=full" - : global_options.x_flag_cf_protection == CF_BRANCH - ? "-fcf-protection=branch" - : global_options.x_flag_cf_protection == CF_RETURN - ? "-fcf-protection=return" - : ""); + const char *cf_protection = NULL; + switch (global_options.x_flag_cf_protection) + { + case CF_NONE: cf_protection = "-fcf-protection=none"; break; + case CF_FULL: cf_protection = "-fcf-protection=full"; break; + case CF_BRANCH: cf_protection = "-fcf-protection=branch"; break; + case CF_RETURN: cf_protection = "-fcf-protection=return"; break; + } + if (cf_protection) + append_to_collect_gcc_options (&temporary_obstack, &first_p, + cf_protection); } /* If debug info is enabled append -g. */ would fix this but whether it fixes also the propagation of "" into the @ file, I have no idea. With -fhardened flag_cf_protection is CF_FULL | CF_SET, CF_FULL set by -fhardened handling and CF_SET by the i386 backend: opts->x_flag_cf_protection = (cf_protection_level) (opts->x_flag_cf_protection | CF_SET); Now, whether lto-opts.cc should also switch (global_options.x_flag_cf_protection & ~CF_SET), I have no idea. Note, append_to_collect_gcc_options (&temporary_obstack, &first_p, global_options.x_flag_pic == 2 ? "-fPIC" : global_options.x_flag_pic == 1 ? "-fpic" : global_options.x_flag_pie == 2 ? "-fPIE" : global_options.x_flag_pie == 1 ? "-fpie" : "-fno-pie"); is also weird. Because I get -fPIC even when I haven't specified that, I've used -fhardened which implies in this case -fPIE. But for -fPIE, both flag_pic and flag_pie are equal to 2. So IMHO we should test for flag_pie first before flag_pic.