11cmake_minimum_required (VERSION 3.19.6)
22
3+
4+ # set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)
5+
36# TODO: Fix RPATH usage to be CMP0068 compliant
47# Disable Policy CMP0068 for CMake 3.9
58# rdar://37725888
@@ -196,9 +199,13 @@ set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
196199 no effect on the target libraries (the standard library and the runtime)." )
197200
198201# NOTE: We do not currently support building libswift with the Xcode generator.
199- cmake_dependent_option(SWIFT_TOOLS_ENABLE_LIBSWIFT
200- "Enable building libswift and linking libswift into the compiler itself." FALSE
201- "NOT CMAKE_GENERATOR STREQUAL \" Xcode\" " FALSE )
202+ cmake_dependent_option(LIBSWIFT_BUILD_MODE "How to build libswift. Possible values are
203+ OFF: the compiler is built without libswift
204+ HOSTTOOLS: libswift is built with a pre-installed toolchain
205+ BOOTSTRAPPING: libswift is built with a 2-stage bootstrapping process
206+ BOOTSTRAPPING-WITH-HOSTLIBS: libswift is built with a 2-stage bootstrapping process,
207+ but the compiler links against the host system swift libs (macOS only)"
208+ OFF "NOT CMAKE_GENERATOR STREQUAL \" Xcode\" " OFF )
202209
203210# The following only works with the Ninja generator in CMake >= 3.0.
204211set (SWIFT_PARALLEL_LINK_JOBS "" CACHE STRING
@@ -390,13 +397,25 @@ option(SWIFT_CHECK_INCREMENTAL_COMPILATION
390397 "Check if incremental compilation works when compiling the Swift libraries"
391398 FALSE )
392399
400+ option (SWIFT_ENABLE_ARRAY_COW_CHECKS
401+ "Compile the stdlib with Array COW checks enabled (only relevant for assert builds)"
402+ FALSE )
403+
393404option (SWIFT_REPORT_STATISTICS
394405 "Create json files which contain internal compilation statistics"
395406 FALSE )
396407
397- option (SWIFT_DISABLE_OBJC_INTEROP
398- "Disable Objective-C interoperability even on platforms what would normally have it"
399- FALSE )
408+ # Only Darwin platforms enable ObjC interop by default.
409+ if ("${SWIFT_HOST_VARIANT_SDK} " MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)" )
410+ set (SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default TRUE )
411+ else ()
412+ set (SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default FALSE )
413+ endif ()
414+
415+ # Used by stdlib/toolchain as well, so this cannot be in stdlib/CMakeLists.txt
416+ option (SWIFT_STDLIB_ENABLE_OBJC_INTEROP
417+ "Should stdlib be built with Obj-C interop."
418+ "${SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default} " )
400419
401420#
402421# User-configurable experimental options. Do not use in production builds.
@@ -487,7 +506,7 @@ endif()
487506# Use dispatch as the system scheduler by default.
488507# For convenience, we set this to false when concurrency is disabled.
489508set (SWIFT_CONCURRENCY_USES_DISPATCH FALSE )
490- if (SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND NOT SWIFT_STDLIB_SINGLE_THREADED_RUNTIME )
509+ if (SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND " ${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR} " STREQUAL "dispatch" )
491510 set (SWIFT_CONCURRENCY_USES_DISPATCH TRUE )
492511endif ()
493512
@@ -506,6 +525,18 @@ if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
506525 endif ()
507526endif ()
508527
528+ set (SWIFT_STDLIB_AVAILABILITY_DEFINITIONS
529+ "SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2"
530+ "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0"
531+ "SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4"
532+ "SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0"
533+ "SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5"
534+ "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0"
535+ "SwiftStdlib 5.6:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999"
536+ "SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" # Unknown future release
537+ CACHE STRING
538+ "Availability macros for stdlib versions" )
539+
509540#
510541# Include CMake modules
511542#
@@ -589,6 +620,20 @@ set(SWIFT_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
589620set (SWIFT_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR} /${CMAKE_CFG_INTDIR} /lib" )
590621if ("${SWIFT_NATIVE_SWIFT_TOOLS_PATH} " STREQUAL "" )
591622 set (SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR} " )
623+ set (SWIFT_EXEC_FOR_LIBSWIFT "${CMAKE_Swift_COMPILER} " )
624+ elseif (LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING" OR LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS" )
625+ # If cross-compiling we don't have to bootstrap. We can just use the previously
626+ # built native swiftc to build libswift.
627+ message (STATUS "Building libswift with native host tools instead of bootstrapping" )
628+ set (LIBSWIFT_BUILD_MODE "HOSTTOOLS" )
629+ set (SWIFT_EXEC_FOR_LIBSWIFT "${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /swiftc" )
630+ endif ()
631+
632+ if (LIBSWIFT_BUILD_MODE STREQUAL "HOSTTOOLS" OR LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS" )
633+ if (SWIFT_ENABLE_ARRAY_COW_CHECKS)
634+ message (STATUS "array COW checks disabled when building libswift with host libraries" )
635+ set (SWIFT_ENABLE_ARRAY_COW_CHECKS FALSE )
636+ endif ()
592637endif ()
593638
594639# This setting causes all CMakeLists.txt to automatically have
@@ -933,7 +978,7 @@ if(SWIFT_INCLUDE_TOOLS)
933978 message (STATUS " Build type: ${CMAKE_BUILD_TYPE} " )
934979 message (STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS} " )
935980 message (STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO} " )
936- message (STATUS " libswift: ${SWIFT_TOOLS_ENABLE_LIBSWIFT } " )
981+ message (STATUS " libswift: ${LIBSWIFT_BUILD_MODE } " )
937982 message (STATUS "" )
938983else ()
939984 message (STATUS "Not building host Swift tools" )
@@ -1040,6 +1085,9 @@ if(SWIFT_ENABLE_DISPATCH)
10401085 include (Libdispatch)
10411086endif ()
10421087
1088+ add_bootstrapping_target(0)
1089+ add_bootstrapping_target(1)
1090+
10431091# Add all of the subdirectories, where we actually do work.
10441092
10451093###############
0 commit comments