This is an archive of the discontinued LLVM Phabricator instance.

[NFC][Driver] Change MultilibBuilder interface

Authored by michaelplatings on May 25 2023, 6:08 AM.



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.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 6:08 AM
Herald added a subscriber: abrachet. · View Herald Transcript
michaelplatings requested review of this revision.May 25 2023, 6:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 6:08 AM
simon_tatham accepted this revision.Jun 5 2023, 7:32 AM
simon_tatham added a subscriber: simon_tatham.

LGTM: I agree that the new notation is easier to understand for anyone not already used to the old one.

However, please wait at least a day for other people and time zones to have a chance to respond.

This revision is now accepted and ready to land.Jun 5 2023, 7:32 AM
This revision was automatically updated to reflect the committed changes.
phosek added inline comments.Jun 6 2023, 10:25 PM

I think it would be cleaner to swap the order of arguments and give the boolean argument a default value. When setting the optional argument, ideally we would always use put the argument in the comment which is a standard convention in LLVM.

I also think that Required is not the best name because it might suggest that Required=false means that the argument is optional. A better name might be something like Negate or Disallow which would also match the ! notation.

Here's a concrete example of what I have in mind:

Multilibs.push_back(MultilibBuilder("asan+noexcept", {}, {})
                        .flag("-fexceptions", /*Negate=*/false)
michaelplatings marked an inline comment as done.Jun 7 2023, 2:38 AM
michaelplatings added inline comments.

OK, I've created D152353

/*Negate=*/false would mean the flag is not negated so I've changed that to /*Negate=*/true.