Page MenuHomePhabricator

[Driver] Enable selecting multiple multilibs

Authored by michaelplatings on Feb 1 2023, 3:29 AM.



This will enable layering multilibs on top of each other.
For example a multilib containing only a no-exceptions libc++ could be
layered on top of a multilib containing C libs. This avoids the need
to duplicate the C library for every libc++ variant.

This change doesn't expose the functionality externally, it only opens
the functionality up to be potentially used by ToolChain classes.

Diff Detail

Unit TestsFailed

120 msx64 debian > Clang.Driver::mips-mti-linux.c
Script: -- : 'RUN: at line 10'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/clang -### /var/lib/buildkite-agent/builds/llvm-project/clang/test/Driver/mips-mti-linux.c 2>&1 --target=mips-mti-linux -mips32r2 -mhard-float -no-pie -rtlib=platform -fuse-ld=ld --sysroot=/var/lib/buildkite-agent/builds/llvm-project/clang/test/Driver/Inputs/mips_mti_linux/sysroot | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck --check-prefix=CHECK-BE-HF-32R2 /var/lib/buildkite-agent/builds/llvm-project/clang/test/Driver/mips-mti-linux.c

Event Timeline

michaelplatings created this revision.Feb 1 2023, 3:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2023, 3:29 AM
michaelplatings requested review of this revision.Feb 1 2023, 3:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2023, 3:29 AM

Rebase and change llvm::SmallVector<Multilib, 1> to simply llvm::SmallVector<Multilib>

A couple of small suggestions but otherwise looks good to me.


Nit: the braces can be omitted here. No strong opinion as it may be better to keep consistency with the rest of the file rather than LLVM as a whole.


SelectedMultilibs.end() - 1 makes me a little nervous. This will work for the current container type (I think the standard requires it for vector and I don't think SmallVector would deviate from it. However in the unlikely event that the container changes and this isn't valid then this could break.

Perhaps use std::advance(SelectedMultilibs.end(), -1) which is more likely to break at compile time if this occurs.

Alternatively if this is just erasing all but the last element, maybe extract it, clear the container and reinsert.

michaelplatings marked 2 inline comments as done.

Rebase and apply changes requested by @peter.smith

michaelplatings retitled this revision from [NFC] Enable selecting multiple multilibs to [Driver] Enable selecting multiple multilibs.Feb 22 2023, 8:15 AM

flags -> tags

peter.smith accepted this revision.Mon, Mar 13, 9:26 AM

I've set approved from the Arm side. Please leave some time for people in the US time zone to leave any final comments or ask for extensions.

This revision is now accepted and ready to land.Mon, Mar 13, 9:26 AM