diff options
author | Alex Lorenz <arphaman@gmail.com> | 2022-02-02 00:19:49 -0800 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2022-02-02 08:30:39 -0800 |
commit | 116c1bea65ac268bc46a2373220c81d02fc0a256 (patch) | |
tree | 294819c7088249fa8de575c7cfd3aa1fe51b8b94 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 6440197ba5bfc05c1fda74e11f6dbe93c1b5dea6 (diff) | |
download | llvm-116c1bea65ac268bc46a2373220c81d02fc0a256.zip llvm-116c1bea65ac268bc46a2373220c81d02fc0a256.tar.gz llvm-116c1bea65ac268bc46a2373220c81d02fc0a256.tar.bz2 |
[clang][macho] add clang frontend support for emitting macho files with two build version load commands
This patch extends clang frontend 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.
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/D115415
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 553a0b3..7bf45bb 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -4404,6 +4404,9 @@ static void GenerateTargetArgs(const TargetOptions &Opts, if (!Opts.SDKVersion.empty()) GenerateArg(Args, OPT_target_sdk_version_EQ, Opts.SDKVersion.getAsString(), SA); + if (!Opts.DarwinTargetVariantSDKVersion.empty()) + GenerateArg(Args, OPT_darwin_target_variant_sdk_version_EQ, + Opts.DarwinTargetVariantSDKVersion.getAsString(), SA); } static bool ParseTargetArgs(TargetOptions &Opts, ArgList &Args, @@ -4431,6 +4434,15 @@ static bool ParseTargetArgs(TargetOptions &Opts, ArgList &Args, else Opts.SDKVersion = Version; } + if (Arg *A = + Args.getLastArg(options::OPT_darwin_target_variant_sdk_version_EQ)) { + llvm::VersionTuple Version; + if (Version.tryParse(A->getValue())) + Diags.Report(diag::err_drv_invalid_value) + << A->getAsString(Args) << A->getValue(); + else + Opts.DarwinTargetVariantSDKVersion = Version; + } return Diags.getNumErrors() == NumErrorsBefore; } |