Skip to content

Commit 4482922

Browse files
committed
Add zippering support
Upstream build system zippering support. Setting the `SWIFT_ENABLE_MACCATALYST` flag will build the compatibility libraries with zippering enabled. Note that AppleClang and LLVM Clang use different flags to write zippered files. The Swift stdlib build doesn't know what clang we're using, so we can't ask it for the compiler ID to determine which whether we're using AppleClang or LLVM clang, hence the nasty `execute_process` trick to figure out whether the compiler that's actually compiling the stdlib knows about the flag or not.
1 parent 7323d32 commit 4482922

File tree

6 files changed

+39
-2
lines changed

6 files changed

+39
-2
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX "10.9")
460460
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS "7.0")
461461
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS "9.0")
462462
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS "2.0")
463+
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_MACCATALYST "13.1")
463464

464465
#
465466
# User-configurable debugging options.
@@ -585,6 +586,13 @@ option(SWIFT_THREADING_PACKAGE
585586
Valid package names are 'pthreads', 'darwin', 'linux', 'win32', 'c11', 'none'
586587
or the empty string for the SDK default.")
587588

589+
option(SWIFT_ENABLE_MACCATALYST
590+
"Build the Standard Library and overlays with MacCatalyst support"
591+
FALSE)
592+
593+
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST "14.5" CACHE STRING
594+
"Minimum deployment target version for macCatalyst")
595+
588596
#
589597
# End of user-configurable options.
590598
#

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,28 @@ function(_add_target_variant_c_compile_link_flags)
8282
DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}")
8383
list(APPEND result "-target" "${target}")
8484
if(target_variant)
85-
list(APPEND result "-target-variant" "${target_variant}")
85+
# Check if the C compiler supports `-target-variant` flag
86+
# TODO (etcwilde): This is a massive hack to deal with the fact that we
87+
# are lying to cmake about what compiler is being used. Normally we could
88+
# use `check_cxx_compiler_flag` here. Unfortunately, that uses a different
89+
# compiler since we swap out the C compiler part way through the build.
90+
file(WRITE "${CMAKE_BINARY_DIR}/stdlib/empty" "")
91+
execute_process(
92+
COMMAND
93+
"${CMAKE_C_COMPILER}"
94+
-Wno-unused-command-line-argument
95+
-target-variant x86_64-apple-ios14.5-macabi -x c -c - -o /dev/null
96+
INPUT_FILE
97+
"${CMAKE_BINARY_DIR}/stdlib/empty"
98+
OUTPUT_QUIET ERROR_QUIET
99+
RESULT_VARIABLE
100+
SUPPORTS_TARGET_VARIANT)
101+
102+
if(SUPPORTS_TARGET_VARIANT EQUAL 0)
103+
list(APPEND result "-target-variant" "${target_variant}")
104+
else()
105+
list(APPEND result "-darwin-target-variant" "${target_variant}")
106+
endif()
86107
endif()
87108
endif()
88109

stdlib/toolchain/Compatibility51/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ add_swift_target_library("${library_name}" STATIC
1919
DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS}
2020
DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS}
2121

22+
MACCATALYST_BUILD_FLAVOR "zippered"
23+
2224
INSTALL_IN_COMPONENT compiler
2325
INSTALL_WITH_SHARED)
2426

stdlib/toolchain/Compatibility56/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ add_swift_target_library("${library_name}" STATIC
2727
DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS}
2828
DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS}
2929

30+
MACCATALYST_BUILD_FLAVOR "zippered"
31+
3032
INSTALL_IN_COMPONENT compiler
3133
INSTALL_WITH_SHARED)
3234

stdlib/toolchain/CompatibilityConcurrency/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ add_swift_target_library("${library_name}" STATIC
1414
DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS}
1515
DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS}
1616

17+
MACCATALYST_BUILD_FLAVOR "zippered"
18+
1719
INSTALL_IN_COMPONENT compiler
1820
INSTALL_WITH_SHARED)
1921

stdlib/toolchain/CompatibilityThreading/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ add_swift_target_library(swiftCompatibilityThreading OBJECT_LIBRARY
1111
DEPLOYMENT_VERSION_OSX ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX}
1212
DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS}
1313
DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS}
14-
DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS})
14+
DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS}
15+
16+
MACCATALYST_BUILD_FLAVOR "zippered")

0 commit comments

Comments
 (0)