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

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.

Differential Revision: https://reviews.llvm.org/D118875
This commit is contained in:
Alex Lorenz 2022-02-14 14:20:28 -08:00
parent 251640ab57
commit f5153d9e72
2 changed files with 15 additions and 0 deletions

View File

@ -298,6 +298,14 @@ macro(darwin_add_builtin_library name suffix)
-target "${LIB_ARCH}-apple-${base_os}${DARWIN_${LIBOS}_BUILTIN_MIN_VER}-simulator")
endif()
if ("${COMPILER_RT_ENABLE_MACCATALYST}" AND
"${LIB_OS}" MATCHES "^osx$")
# Build the macOS builtins with Mac Catalyst support.
list(APPEND builtin_cflags
-target ${LIB_ARCH}-apple-macos${DARWIN_osx_BUILTIN_MIN_VER}
-darwin-target-variant ${LIB_ARCH}-apple-ios13.1-macabi)
endif()
set_target_compile_flags(${libname}
${sysroot_flag}
${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}

View File

@ -3,6 +3,7 @@
# .o files. This is particularly useful in producing larger, more complex
# runtime libraries.
include(BuiltinTests)
include(CheckIncludeFile)
include(CheckCXXSourceCompiles)
include(GNUInstallDirs)
@ -138,6 +139,12 @@ if(APPLE)
set(OSX_SYSROOT_FLAG "")
endif()
try_compile_only(COMPILER_RT_HAS_DARWIN_TARGET_VARIANT_FLAG
FLAGS
"-target" "x86_64-apple-macos10.15"
"-darwin-target-variant" "x86_64-apple-ios13.1-macabi"
"-Werror")
option(COMPILER_RT_ENABLE_MACCATALYST "Enable building for Mac Catalyst" ${COMPILER_RT_HAS_DARWIN_TARGET_VARIANT_FLAG})
option(COMPILER_RT_ENABLE_IOS "Enable building for iOS" On)
option(COMPILER_RT_ENABLE_WATCHOS "Enable building for watchOS - Experimental" Off)
option(COMPILER_RT_ENABLE_TVOS "Enable building for tvOS - Experimental" Off)