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

--- Comment #1 from Greg Land <landjgregory at gmail dot com> ---
Traced bug to use of add_infile in -fhardened logic.

gcc/gcc.cc:5038
```
  if (flag_hardened)
    {
      if (!avoid_linker_hardening_p && !static_p)
        {
#if defined HAVE_LD_PIE && defined LD_PIE_SPEC
          save_switch (LD_PIE_SPEC, 0, NULL, /*validated=*/true,
/*known=*/false);
#endif
          /* These are passed straight down to collect2 so we have to break
             it up like this.  */

          if (HAVE_LD_NOW_SUPPORT)
            {
              add_infile ("-z", "*");
              add_infile ("now", "*");
            }
          if (HAVE_LD_RELRO_SUPPORT)
            {
              add_infile ("-z", "*");
              add_infile ("relro", "*");
            }
        }
      /* We can't use OPT_Whardened yet.  Sigh.  */
      else
        warning_at (UNKNOWN_LOCATION, 0,
                    "linker hardening options not enabled by %<-fhardened%> "
                    "because other link options were specified on the command "
                    "line");
    }
```

This stops --help=warnings by preventing the creation of dummy-help because
n_infiles is now greater than 0.

gcc/gcc.cc:5577
```
  if (n_infiles == 0
      && (print_subprocess_help || print_help_list || print_version))
    {
      /* Create a dummy input file, so that we can pass
         the help option on to the various sub-processes.  */
      add_infile ("help-dummy", "c");
    }
```

Since the help-dummy never gets added cc never gets executed and the help text
is never displayed.

Reply via email to