This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][builtins] build the macOS compiler-rt built-ins with Mac Catalyst support
ClosedPublic

Authored by arphaman on Feb 2 2022, 11:36 PM.

Details

Summary

This patch extends compiler-rt's cmake config to build macOS builtins with both macOS and Mac Catalyst support. This is done by telling the compiler to emit macho files with two build version load commands. This is the follow-up to the clang driver support here: https://reviews.llvm.org/D118862

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.

Diff Detail

Event Timeline

arphaman created this revision.Feb 2 2022, 11:36 PM
arphaman requested review of this revision.Feb 2 2022, 11:36 PM
bc-lee added a subscriber: bc-lee.Feb 3 2022, 12:34 PM
bc-lee added a comment.Feb 4 2022, 1:01 AM

Hi, I built and tested clang using this patch and https://reviews.llvm.org/D118862. It works great.
The current patch adds the -darwin-target-variant flag to all object files for MacOS targets in the compiler_rt's builtin library. However, users building compiler_rt may have compilers that don't support such flag, so it would be nice to have a CMake option to enable compiler flags like COMPILER_RT_ENABLE_CATALYST.

Hi, I built and tested clang using this patch and https://reviews.llvm.org/D118862. It works great.
The current patch adds the -darwin-target-variant flag to all object files for MacOS targets in the compiler_rt's builtin library. However, users building compiler_rt may have compilers that don't support such flag, so it would be nice to have a CMake option to enable compiler flags like COMPILER_RT_ENABLE_CATALYST.

Good point. I will update the patch and add detection for the Mac catalyst support that detects if clang supports it with a flag .

arphaman updated this revision to Diff 408621.Feb 14 2022, 2:21 PM

Add checking for -darwin-target-variant support

ravikandhadai accepted this revision.Feb 21 2022, 4:37 PM

LGTM. Thanks Alex.

This revision is now accepted and ready to land.Feb 21 2022, 4:37 PM
thakis added a subscriber: thakis.Feb 22 2022, 7:56 AM

Is landing this blocked on anything?

No, I will land it today.

Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2022, 7:32 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript