5 Commits

Author SHA1 Message Date
Michael Platings
b4507dcaea [NFC][Driver] Change MultilibBuilder flags argument order
Follow up to D151437

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D152353
2023-06-08 10:02:52 +01:00
Michael Platings
ce8fa36e59 [NFC][Driver] Change Multilib flag representation
This new representation means that a valid command line option may
potentially be used directly as a multilib flag without any translation.

To indicate that a flag is required not to be present, its first
character is replaced with '!', which is intended for consistency with
the logical not operator in many programming languages.

Reviewed By: simon_tatham

Differential Revision: https://reviews.llvm.org/D151438
2023-06-07 05:53:04 +01:00
Michael Platings
47b431d661 [NFC][Driver] Change MultilibBuilder interface
Decouple the interface of the MultilibBuilder flag method from how flags
are stored internally. Likewise change the addMultilibFlag function.

Currently a multilib flag like "-fexceptions" means a multilib is
*incompatible* with the -fexceptions command line option, which is
counter-intuitive. This change is a step towards changing this scheme.

Differential Revision: https://reviews.llvm.org/D151437
2023-06-07 05:53:04 +01:00
Michael Platings
d30bc9e912 [Driver] Change multilib selection algorithm
The new algorithm is:
1. Find all multilibs with flags that are a subset of the requested
   flags.
2. If more than one multilib matches, choose the last.

In addition a new selection mechanism is permitted via an overload of
MultilibSet::select() for which multiple multilibs are returned.
This allows layering multilibs on top of each other.

Since multilibs are now ordered within a list, they no longer need a
Priority field.

The new algorithm is different to the old algorithm, but in practise
the old algorithm was always used in such a way that the effect is the
same.
The old algorithm was to find the set intersection of the requested
flags (with the first character of each removed) with each multilib's
flags (ditto), and for that intersection check whether the first
character matched. However, ignoring the first characters, the
requested flags were always a superset of all the multilibs flags.
Therefore the new algorithm can be used as a drop-in replacement.

The exception is Fuchsia, which needs adjusting slightly to set both
fexceptions and fno-exceptions flags.

Differential Revision: https://reviews.llvm.org/D142905
2023-03-24 06:58:07 +00:00
Michael Platings
850dab0f25 [NFC] Class for building MultilibSet
The functionality in MultilibSet for creating it is tied to its current
implementation. Putting that code in a separate class is an enabler for
changing the MultilibSet implementation.

Differential Revision: https://reviews.llvm.org/D142893
2023-02-22 09:24:48 +00:00