Skip to content

Commit a97fc33

Browse files
[6.0.0] [CMake] [Darwin] Don't build the SDK overlays by default on Apple platforms
The Apple SDKs have been providing the Darwin overlay since macOS 10.14.4, iOS 12.2, et al. More recently the SDK version has diverged from the Swift version making them incompatible. Stop building the overlay from Swift. Once the SDK overlays aren't being built, the clang overlays need to be built in testing. rdar://115192929
1 parent ff4d121 commit a97fc33

16 files changed

+55
-28
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,16 @@ option(SWIFT_BUILD_CLANG_OVERLAYS
247247
"Build Swift overlays for the clang builtin modules"
248248
TRUE)
249249

250+
# The SDK overlay is provided by the SDK itself on Darwin platforms.
251+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
252+
set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default FALSE)
253+
else()
254+
set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default TRUE)
255+
endif()
256+
250257
option(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY
251258
"Build dynamic variants of the Swift SDK overlay"
252-
TRUE)
259+
"${SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default}")
253260

254261
option(SWIFT_BUILD_STATIC_SDK_OVERLAY
255262
"Build static variants of the Swift SDK overlay"

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ function(swift_benchmark_compile)
714714

715715
if(NOT SWIFT_BENCHMARK_BUILT_STANDALONE)
716716
set(stdlib_dependencies "swift-frontend" "swiftCore-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
717-
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
717+
if((SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) AND SWIFT_BUILD_SDK_OVERLAY)
718718
list(APPEND stdlib_dependencies "swiftDarwin-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
719719
endif()
720720
foreach(stdlib_dependency ${UNIVERSAL_LIBRARY_NAMES_${SWIFT_BENCHMARK_COMPILE_PLATFORM}})

cmake/modules/DarwinSDKs.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ if(swift_build_freestanding AND (SWIFT_FREESTANDING_FLAVOR STREQUAL "apple"))
4848
configure_target_variant(FREESTANDING-R "FREESTANDING Release" FREESTANDING R "Release")
4949
configure_target_variant(FREESTANDING-S "FREESTANDING MinSizeRelease" FREESTANDING S "MinSizeRelease")
5050

51-
set(SWIFT_FREESTANDING_TEST_DEPENDENCIES "Darwin")
51+
if(SWIFT_BUILD_SDK_OVERLAY)
52+
set(SWIFT_FREESTANDING_TEST_DEPENDENCIES "Darwin")
53+
else()
54+
set(SWIFT_FREESTANDING_TEST_DEPENDENCIES "")
55+
endif()
5256
endif()
5357

5458
# Compatible cross-compile SDKS for Darwin OSes: IOS, IOS_SIMULATOR, TVOS,

stdlib/private/CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
if(SWIFT_BUILD_SDK_OVERLAY)
1+
if(SWIFT_BUILD_SDK_OVERLAY
2+
OR (SWIFT_BUILD_TEST_SUPPORT_MODULES
3+
AND NOT SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default
4+
AND (SWIFT_ENABLE_REFLECTION
5+
OR NOT SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)))
26
# SwiftPrivateThreadExtras makes use of Darwin/Glibc, which is part of the
3-
# SDK overlay. It can't be built separately from the SDK overlay.
7+
# SDK overlay. If the SDK overlay doesn't build by default, then it should
8+
# be available in the SDK and DifferentiationUnittest can still be built.
9+
# However, the overlay in the Apple SDKs requires the standard library to
10+
# have reflection enabled.
411
if(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING)
512
add_subdirectory(DifferentiationUnittest)
613
endif()
7-
endif()
8-
9-
if(SWIFT_BUILD_SDK_OVERLAY OR SWIFT_BUILD_TEST_SUPPORT_MODULES)
1014
add_subdirectory(SwiftPrivate)
1115
add_subdirectory(RuntimeUnittest)
1216
add_subdirectory(StdlibUnicodeUnittest)
@@ -18,9 +22,7 @@ if(SWIFT_BUILD_SDK_OVERLAY OR SWIFT_BUILD_TEST_SUPPORT_MODULES)
1822
# SwiftPrivateThreadExtras to ensure that the dependency targets are setup in
1923
# the correct order for Windows.
2024
add_subdirectory(StdlibUnittest)
21-
endif()
2225

23-
if(SWIFT_BUILD_SDK_OVERLAY)
2426
add_subdirectory(OSLog)
2527

2628
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")

stdlib/public/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ if(SWIFT_BUILD_STDLIB)
242242
add_subdirectory(core)
243243
add_subdirectory(SwiftOnoneSupport)
244244

245-
if(SWIFT_BUILD_CLANG_OVERLAYS)
245+
if(SWIFT_BUILD_CLANG_OVERLAYS OR SWIFT_BUILD_TEST_SUPPORT_MODULES)
246246
add_subdirectory(ClangOverlays)
247247
endif()
248248
endif()
@@ -287,13 +287,12 @@ if(SWIFT_BUILD_REMOTE_MIRROR)
287287
add_subdirectory(SwiftRemoteMirror)
288288
endif()
289289

290-
if(SWIFT_BUILD_SDK_OVERLAY OR SWIFT_BUILD_TEST_SUPPORT_MODULES)
290+
if(SWIFT_BUILD_SDK_OVERLAY OR (SWIFT_BUILD_TEST_SUPPORT_MODULES AND SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default))
291291
add_subdirectory(Platform)
292292
endif()
293293

294294
if(SWIFT_BUILD_SDK_OVERLAY)
295-
# On Apple platforms, we aren't building any overlays (other than Darwin in
296-
# Platform above). Instead, we're picking them up from the SDK.
295+
# On Apple platforms, we aren't building any overlays. Instead, we're picking them up from the SDK.
297296

298297
if(WINDOWS IN_LIST SWIFT_SDKS)
299298
add_subdirectory(Windows)

test/Driver/loaded_module_trace_foundation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
// CHECK: "arch":"{{[^"]*}}"
1010
// CHECK: "swiftmodules":[
1111

12-
// Darwin, Swift and SwiftOnoneSupport is expected to be locally built;
12+
// Swift and SwiftOnoneSupport is expected to be locally built;
1313
// everything else comes from the SDK, built from swiftinterface.
1414

1515
// CHECK-DAG: "{{[^"]*}}/ObjectiveC.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
1616
// CHECK-DAG: "{{[^"]*}}/Dispatch.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
17-
// CHECK-DAG: "{{[^"]*}}/Darwin.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
17+
// CHECK-DAG: "{{[^"]*}}/Darwin.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
1818
// CHECK-DAG: "{{[^"]*}}/Foundation.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
1919
// CHECK-DAG: "{{[^"]*}}/Swift.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
2020
// CHECK-DAG: "{{[^"]*}}/SwiftOnoneSupport.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"

test/Driver/loaded_module_trace_header.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// CHECK: "swiftmodules":[
1212
// CHECK-DAG: "{{[^"]*}}/ObjectiveC.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
1313
// CHECK-DAG: "{{[^"]*}}/Dispatch.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
14-
// CHECK-DAG: "{{[^"]*}}/Darwin.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
14+
// CHECK-DAG: "{{[^"]*}}/Darwin.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
1515
// CHECK-DAG: "{{[^"]*}}/Foundation.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
1616
// CHECK-DAG: "{{[^"]*}}/Swift.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
1717
// CHECK-DAG: "{{[^"]*}}/SwiftOnoneSupport.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"

test/SIL/Serialization/deserialize_darwin.sil

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/embedded/concurrency-actors.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
// REQUIRES: optimized_stdlib
1010
// REQUIRES: OS=macosx
1111

12+
// The Darwin SDK overlay module in the macOS SDK cannot be imported in
13+
// embedded Swift mode.
14+
// XFAIL: OS=macosx
15+
1216
import _Concurrency
1317

1418
actor Number {

test/embedded/concurrency-async-let.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
// REQUIRES: optimized_stdlib
1010
// REQUIRES: OS=macosx
1111

12+
// The Darwin SDK overlay module in the macOS SDK cannot be imported in
13+
// embedded Swift mode.
14+
// XFAIL: OS=macosx
15+
1216
import _Concurrency
1317

1418
func fib(_ n: Int) -> Int {

test/embedded/concurrency-simple.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
// REQUIRES: optimized_stdlib
1010
// REQUIRES: OS=macosx
1111

12+
// The Darwin SDK overlay module in the macOS SDK cannot be imported in
13+
// embedded Swift mode.
14+
// XFAIL: OS=macosx
15+
1216
import _Concurrency
1317

1418
public func test() async -> Int {

test/embedded/darwin-bridging-header.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
// REQUIRES: VENDOR=apple
1212
// REQUIRES: OS=macosx
1313

14+
// The Darwin SDK overlay module in the macOS SDK cannot be imported in
15+
// embedded Swift mode.
16+
// XFAIL: OS=macosx
17+
1418
// BEGIN BridgingHeader.h
1519

1620
#include <unistd.h>

test/embedded/darwin.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
// REQUIRES: VENDOR=apple
1010
// REQUIRES: OS=macosx
1111

12+
// The Darwin SDK overlay module in the macOS SDK cannot be imported in
13+
// embedded Swift mode.
14+
// XFAIL: OS=macosx
15+
1216
import Darwin
1317

1418
@main

test/lit.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,8 +1498,8 @@ if run_vendor == 'apple':
14981498
'%s -modulewrap -target %s' %
14991499
(config.swiftc, config.variant_triple))
15001500
config.target_swift_emit_pcm = (
1501-
'%s -emit-pcm -target %s' %
1502-
(config.swiftc, config.variant_triple))
1501+
'%s -emit-pcm -target %s -sdk %r' %
1502+
(config.swiftc, config.variant_triple, config.variant_sdk))
15031503
subst_target_swift_frontend_mock_sdk_after = \
15041504
target_options_for_mock_sdk_after
15051505
config.target_sil_opt = (

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import multiprocessing
1010
import os
11+
import platform
1112

1213
import android.adb.commands
1314

@@ -1145,7 +1146,7 @@ def create_argument_parser():
11451146
help='build static variants of the Swift standard library')
11461147

11471148
option('--build-swift-dynamic-sdk-overlay', toggle_true,
1148-
default=True,
1149+
default=platform.system() != "Darwin",
11491150
help='build dynamic variants of the Swift SDK overlay')
11501151

11511152
option('--build-swift-static-sdk-overlay', toggle_true,

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
import multiprocessing
11+
import platform
1112

1213
from build_swift import argparse
1314
from build_swift import defaults
@@ -80,7 +81,7 @@
8081
'build_runtime_with_host_compiler': False,
8182
'build_stdlib_deployment_targets': ['all'],
8283
'build_subdir': None,
83-
'build_swift_dynamic_sdk_overlay': True,
84+
'build_swift_dynamic_sdk_overlay': platform.system() != "Darwin",
8485
'build_swift_dynamic_stdlib': True,
8586
'build_swift_inspect': False,
8687
'build_swift_external_generic_metadata_builder': True,

0 commit comments

Comments
 (0)