[lld/mac] Implement -arch_multiple
authorNico Weber <thakis@chromium.org>
Tue, 6 Jul 2021 00:52:09 +0000 (20:52 -0400)
committerNico Weber <thakis@chromium.org>
Tue, 6 Jul 2021 04:25:18 +0000 (00:25 -0400)
commit64be5b7d87139c5fa9cfbe9ee413dc15d04cedb7
treeda9a88d7773ccf81961541075112084c376f4f44
parent203b48c71a0db835bd0d6869311578dbd7cc8b71
[lld/mac] Implement -arch_multiple

This is the other flag clang passes when calling clang with two -arch
flags (which means with this, `clang -arch x86_64 -arch arm64 -fuse-ld=lld ...`
now no longer prints any warnings \o/). Since clang calls the linker several
times in that setup, it's not clear to the user from which invocation the
errors are. The flag's help text is

    Specifies that the linker should augment error and warning messages
    with the architecture name.

In ld64, the only effect of the flag is that undefined symbols are prefaced
with

    Undefined symbols for architecture x86_64:

instead of the usual "Undefined symbols:". So for now, let's add this
only to undefined symbol errors too. That's probably the most common
linker diagnostic.

Another idea would be to prefix errors and warnings with "ld64.lld(x86_64):"
instead of the usual "ld64.lld:", but I'm not sure if people would
misunderstand that as a comment about the arch of ld itself.
But open to suggestions on what effect this flag should have :) And we
don't have to get it perfect now, we can iterate on it.

Differential Revision: https://reviews.llvm.org/D105450
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/MachO/SymbolTable.cpp
lld/test/MachO/arch-multiple.s [new file with mode: 0644]