[macho] add support for emitting macho files with two build version load commands
authorAlex Lorenz <arphaman@gmail.com>
Wed, 8 Dec 2021 01:51:44 +0000 (17:51 -0800)
committerAlex Lorenz <arphaman@gmail.com>
Wed, 8 Dec 2021 02:17:47 +0000 (18:17 -0800)
commit0756aa397856d88f458c6836b24d36ca60fd1044
tree7ce36f0a717971b602e85b4b6492b6660bcfceef
parent5ff52be5d98a621db6de079ad09d0f94854938e8
[macho] add support for emitting macho files with two build version load commands

This patch extends LLVM IR to add metadata that can be used to emit macho files with two build version load commands.
It utilizes "darwin.target_variant.triple" and "darwin.target_variant.SDK Version" metadata names for that,
which will be set by a future patch in clang.

MachO uses two build version load commands to represent an object file / binary that is targeting both the macOS target,
and the Mac Catalyst target. At runtime, a dynamic library that supports both targets can be loaded from either a native
macOS or a Mac Catalyst app on a macOS system. We want to add support to this to upstream to LLVM to be able to build
compiler-rt for both targets, to finish the complete support for the Mac Catalyst platform, which is right now targetable
by upstream clang, but the compiler-rt bits aren't supported because of the lack of this multiple build version support.

Differential Revision: https://reviews.llvm.org/D112189
13 files changed:
llvm/include/llvm/IR/Module.h
llvm/include/llvm/MC/MCAssembler.h
llvm/include/llvm/MC/MCObjectFileInfo.h
llvm/include/llvm/MC/MCStreamer.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/IR/Module.cpp
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCAssembler.cpp
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/MC/MachObjectWriter.cpp
llvm/test/MC/MachO/darwin-target-variant-reverse.ll [new file with mode: 0644]
llvm/test/MC/MachO/darwin-target-variant.ll [new file with mode: 0644]