Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0.0] [CMake] [Darwin] Don't build the SDK overlays by default on Apple platforms #76580

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,16 @@ option(SWIFT_BUILD_CLANG_OVERLAYS
"Build Swift overlays for the clang builtin modules"
TRUE)

# The SDK overlay is provided by the SDK itself on Darwin platforms.
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default FALSE)
else()
set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default TRUE)
endif()

option(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY
"Build dynamic variants of the Swift SDK overlay"
TRUE)
"${SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default}")

option(SWIFT_BUILD_STATIC_SDK_OVERLAY
"Build static variants of the Swift SDK overlay"
Expand Down
2 changes: 1 addition & 1 deletion benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ function(swift_benchmark_compile)

if(NOT SWIFT_BENCHMARK_BUILT_STANDALONE)
set(stdlib_dependencies "swift-frontend" "swiftCore-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
if((SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS) AND SWIFT_BUILD_SDK_OVERLAY)
list(APPEND stdlib_dependencies "swiftDarwin-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
endif()
foreach(stdlib_dependency ${UNIVERSAL_LIBRARY_NAMES_${SWIFT_BENCHMARK_COMPILE_PLATFORM}})
Expand Down
6 changes: 5 additions & 1 deletion cmake/modules/DarwinSDKs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ if(swift_build_freestanding AND (SWIFT_FREESTANDING_FLAVOR STREQUAL "apple"))
configure_target_variant(FREESTANDING-R "FREESTANDING Release" FREESTANDING R "Release")
configure_target_variant(FREESTANDING-S "FREESTANDING MinSizeRelease" FREESTANDING S "MinSizeRelease")

set(SWIFT_FREESTANDING_TEST_DEPENDENCIES "Darwin")
if(SWIFT_BUILD_SDK_OVERLAY)
set(SWIFT_FREESTANDING_TEST_DEPENDENCIES "Darwin")
else()
set(SWIFT_FREESTANDING_TEST_DEPENDENCIES "")
endif()
endif()

# Compatible cross-compile SDKS for Darwin OSes: IOS, IOS_SIMULATOR, TVOS,
Expand Down
16 changes: 9 additions & 7 deletions stdlib/private/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
if(SWIFT_BUILD_SDK_OVERLAY)
if(SWIFT_BUILD_SDK_OVERLAY
OR (SWIFT_BUILD_TEST_SUPPORT_MODULES
AND NOT SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default
AND (SWIFT_ENABLE_REFLECTION
OR NOT SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)))
# SwiftPrivateThreadExtras makes use of Darwin/Glibc, which is part of the
# SDK overlay. It can't be built separately from the SDK overlay.
# SDK overlay. If the SDK overlay doesn't build by default, then it should
# be available in the SDK and DifferentiationUnittest can still be built.
# However, the overlay in the Apple SDKs requires the standard library to
# have reflection enabled.
if(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING)
add_subdirectory(DifferentiationUnittest)
endif()
endif()

if(SWIFT_BUILD_SDK_OVERLAY OR SWIFT_BUILD_TEST_SUPPORT_MODULES)
add_subdirectory(SwiftPrivate)
add_subdirectory(RuntimeUnittest)
add_subdirectory(StdlibUnicodeUnittest)
Expand All @@ -18,9 +22,7 @@ if(SWIFT_BUILD_SDK_OVERLAY OR SWIFT_BUILD_TEST_SUPPORT_MODULES)
# SwiftPrivateThreadExtras to ensure that the dependency targets are setup in
# the correct order for Windows.
add_subdirectory(StdlibUnittest)
endif()

if(SWIFT_BUILD_SDK_OVERLAY)
add_subdirectory(OSLog)

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
Expand Down
7 changes: 3 additions & 4 deletions stdlib/public/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ if(SWIFT_BUILD_STDLIB)
add_subdirectory(core)
add_subdirectory(SwiftOnoneSupport)

if(SWIFT_BUILD_CLANG_OVERLAYS)
if(SWIFT_BUILD_CLANG_OVERLAYS OR SWIFT_BUILD_TEST_SUPPORT_MODULES)
add_subdirectory(ClangOverlays)
endif()
endif()
Expand Down Expand Up @@ -287,13 +287,12 @@ if(SWIFT_BUILD_REMOTE_MIRROR)
add_subdirectory(SwiftRemoteMirror)
endif()

if(SWIFT_BUILD_SDK_OVERLAY OR SWIFT_BUILD_TEST_SUPPORT_MODULES)
if(SWIFT_BUILD_SDK_OVERLAY OR (SWIFT_BUILD_TEST_SUPPORT_MODULES AND SWIFT_BUILD_DYNAMIC_SDK_OVERLAY_default))
add_subdirectory(Platform)
endif()

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

if(WINDOWS IN_LIST SWIFT_SDKS)
add_subdirectory(Windows)
Expand Down
4 changes: 2 additions & 2 deletions test/Driver/loaded_module_trace_foundation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
// CHECK: "arch":"{{[^"]*}}"
// CHECK: "swiftmodules":[

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

// CHECK-DAG: "{{[^"]*}}/ObjectiveC.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
// CHECK-DAG: "{{[^"]*}}/Dispatch.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
// CHECK-DAG: "{{[^"]*}}/Darwin.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
// CHECK-DAG: "{{[^"]*}}/Darwin.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
// CHECK-DAG: "{{[^"]*}}/Foundation.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
// CHECK-DAG: "{{[^"]*}}/Swift.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
// CHECK-DAG: "{{[^"]*}}/SwiftOnoneSupport.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
Expand Down
2 changes: 1 addition & 1 deletion test/Driver/loaded_module_trace_header.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// CHECK: "swiftmodules":[
// CHECK-DAG: "{{[^"]*}}/ObjectiveC.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
// CHECK-DAG: "{{[^"]*}}/Dispatch.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
// CHECK-DAG: "{{[^"]*}}/Darwin.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
// CHECK-DAG: "{{[^"]*}}/Darwin.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
// CHECK-DAG: "{{[^"]*}}/Foundation.swiftmodule{{(\\/[^"]+[.]swift(module|interface))?}}"
// CHECK-DAG: "{{[^"]*}}/Swift.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
// CHECK-DAG: "{{[^"]*}}/SwiftOnoneSupport.swiftmodule{{(\\/[^"]+[.]swiftmodule)?}}"
Expand Down
7 changes: 0 additions & 7 deletions test/SIL/Serialization/deserialize_darwin.sil

This file was deleted.

4 changes: 4 additions & 0 deletions test/embedded/concurrency-actors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx

// The Darwin SDK overlay module in the macOS SDK cannot be imported in
// embedded Swift mode.
// XFAIL: OS=macosx

import _Concurrency

actor Number {
Expand Down
4 changes: 4 additions & 0 deletions test/embedded/concurrency-async-let.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx

// The Darwin SDK overlay module in the macOS SDK cannot be imported in
// embedded Swift mode.
// XFAIL: OS=macosx

import _Concurrency

func fib(_ n: Int) -> Int {
Expand Down
4 changes: 4 additions & 0 deletions test/embedded/concurrency-simple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx

// The Darwin SDK overlay module in the macOS SDK cannot be imported in
// embedded Swift mode.
// XFAIL: OS=macosx

import _Concurrency

public func test() async -> Int {
Expand Down
4 changes: 4 additions & 0 deletions test/embedded/darwin-bridging-header.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

// The Darwin SDK overlay module in the macOS SDK cannot be imported in
// embedded Swift mode.
// XFAIL: OS=macosx

// BEGIN BridgingHeader.h

#include <unistd.h>
Expand Down
4 changes: 4 additions & 0 deletions test/embedded/darwin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

// The Darwin SDK overlay module in the macOS SDK cannot be imported in
// embedded Swift mode.
// XFAIL: OS=macosx

import Darwin

@main
Expand Down
4 changes: 2 additions & 2 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1498,8 +1498,8 @@ if run_vendor == 'apple':
'%s -modulewrap -target %s' %
(config.swiftc, config.variant_triple))
config.target_swift_emit_pcm = (
'%s -emit-pcm -target %s' %
(config.swiftc, config.variant_triple))
'%s -emit-pcm -target %s -sdk %r' %
(config.swiftc, config.variant_triple, config.variant_sdk))
subst_target_swift_frontend_mock_sdk_after = \
target_options_for_mock_sdk_after
config.target_sil_opt = (
Expand Down
3 changes: 2 additions & 1 deletion utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import multiprocessing
import os
import platform

import android.adb.commands

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

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

option('--build-swift-static-sdk-overlay', toggle_true,
Expand Down
3 changes: 2 additions & 1 deletion utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


import multiprocessing
import platform

from build_swift import argparse
from build_swift import defaults
Expand Down Expand Up @@ -80,7 +81,7 @@
'build_runtime_with_host_compiler': False,
'build_stdlib_deployment_targets': ['all'],
'build_subdir': None,
'build_swift_dynamic_sdk_overlay': True,
'build_swift_dynamic_sdk_overlay': platform.system() != "Darwin",
'build_swift_dynamic_stdlib': True,
'build_swift_inspect': False,
'build_swift_external_generic_metadata_builder': True,
Expand Down