From 3d71dbb04b8a6a1c4d5a86debc834c59da471251 Mon Sep 17 00:00:00 2001 From: Eric Miotto <1094986+edymtt@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:06:42 -0800 Subject: [PATCH] CMake: allow to only build Core and Onone when building the stdlib (#69747) This is needed for some Apple internal configurations that needs to build the standard library in pieces to construct an SDK. Given the limited audience, only introduce this flag in CMake. Addresses rdar://118178539 --- stdlib/cmake/modules/StdlibOptions.cmake | 7 +++++++ stdlib/public/CMakeLists.txt | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/stdlib/cmake/modules/StdlibOptions.cmake b/stdlib/cmake/modules/StdlibOptions.cmake index 6c8bd8b43f29f..a23f379e6486b 100644 --- a/stdlib/cmake/modules/StdlibOptions.cmake +++ b/stdlib/cmake/modules/StdlibOptions.cmake @@ -99,6 +99,13 @@ option(SWIFT_STDLIB_EMIT_API_DESCRIPTORS "Emit api descriptors for the standard library" FALSE) +option(SWIFT_STDLIB_BUILD_ONLY_CORE_MODULES + "Build only the core subset of the standard library, + ignoring additional libraries such as Concurrency, Distributed and StringProcessing. + This is an option meant for internal configurations inside Apple + that need to build the standard libraries in chunks when constructing an SDK" + FALSE) + if("${SWIFT_HOST_VARIANT_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS) set(SWIFT_STDLIB_ENABLE_PRESPECIALIZATION_default TRUE) elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX") diff --git a/stdlib/public/CMakeLists.txt b/stdlib/public/CMakeLists.txt index 20364f2470d52..86115cbf8ea75 100644 --- a/stdlib/public/CMakeLists.txt +++ b/stdlib/public/CMakeLists.txt @@ -166,7 +166,12 @@ if(SWIFT_BUILD_STDLIB) add_subdirectory(stubs) add_subdirectory(core) add_subdirectory(SwiftOnoneSupport) +endif() +if(SWIFT_BUILD_STDLIB AND NOT SWIFT_STDLIB_BUILD_ONLY_CORE_MODULES) + # In some internal Apple configurations we have the need + # to build Core and Onone separately from the rest + # of the stdlib if(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING) add_subdirectory(Differentiation) endif()