arphaman created this revision.
arphaman added reviewers: ravikandhadai, dexonsmith.
Herald added subscribers: ributzka, mgorny, dberris.
arphaman requested review of this revision.

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.


https://reviews.llvm.org/D118875

Files:
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake


Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===================================================================
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -298,6 +298,13 @@
          -target 
"${LIB_ARCH}-apple-${base_os}${DARWIN_${LIBOS}_BUILTIN_MIN_VER}-simulator")
   endif()
 
+  if ("${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.0-macabi)
+  endif()
+
   set_target_compile_flags(${libname}
     ${sysroot_flag}
     ${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}


Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===================================================================
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -298,6 +298,13 @@
          -target "${LIB_ARCH}-apple-${base_os}${DARWIN_${LIBOS}_BUILTIN_MIN_VER}-simulator")
   endif()
 
+  if ("${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.0-macabi)
+  endif()
+
   set_target_compile_flags(${libname}
     ${sysroot_flag}
     ${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to