From 116c1bea65ac268bc46a2373220c81d02fc0a256 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Wed, 2 Feb 2022 00:19:49 -0800 Subject: [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 --- clang/lib/CodeGen/ModuleBuilder.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'clang/lib/CodeGen/ModuleBuilder.cpp') diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp index f6642a7..50b7fd8 100644 --- a/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/clang/lib/CodeGen/ModuleBuilder.cpp @@ -146,6 +146,11 @@ namespace { const auto &SDKVersion = Ctx->getTargetInfo().getSDKVersion(); if (!SDKVersion.empty()) M->setSDKVersion(SDKVersion); + if (const auto *TVT = Ctx->getTargetInfo().getDarwinTargetVariantTriple()) + M->setDarwinTargetVariantTriple(TVT->getTriple()); + if (auto TVSDKVersion = + Ctx->getTargetInfo().getDarwinTargetVariantSDKVersion()) + M->setDarwinTargetVariantSDKVersion(*TVSDKVersion); Builder.reset(new CodeGen::CodeGenModule(Context, HeaderSearchOpts, PreprocessorOpts, CodeGenOpts, *M, Diags, CoverageInfo)); -- cgit v1.1