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

            Bug ID: 100830
           Summary: Multilib directory picking logic handles default
                    arguments oddly
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mhjacobson at me dot com
  Target Milestone: ---

`set_multilib_dir()` is responsible for selecting a multilib directory given
(a) `multilib_select` and (b) the state of the switches.

But (at least, IMO), it handles the following case very unintuitively:

Suppose `multilib_select` is (newlines added for clarity):

    . !mmcu=avr4 !mmcu=avr5;
    avr4 mmcu=avr4 !mmcu=avr5;
    avr5 !mmcu=avr4 mmcu=avr5;

i.e., choose "avr4" if `-mmcu=avr4`; "avr5" if `-mmcu=avr5`, and "." if
neither.

Suppose also that the default value of `mmcu`, specified in
`multilib_defaults`, is `avr5`.

Then the logic described by this comment will unintuitively cause "." to be
picked even when `-mmcu=avr5` is explicitly passed as an argument to the
driver:

        /* If this is a default argument, we can just ignore it.
        This is true even if this_arg begins with '!'.  Beginning
        with '!' does not mean that this argument is necessarily
        inappropriate for this library: it merely means that
        there is a more specific library which uses this
        argument.  If this argument is a default, we need not
        consider that more specific library.  */

The code that actually implements this is the check of default_arg() after
we've already failed the used_arg() check.

Perhaps it's not a valid configuration to have a default value in
`multilib_defaults` that does not correspond to ".", but if so, I think that's
weird.

Reply via email to