|
1 | 1 | cmake_minimum_required(VERSION 3.19.6) |
2 | 2 |
|
| 3 | + |
| 4 | +# set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1) |
| 5 | + |
3 | 6 | # TODO: Fix RPATH usage to be CMP0068 compliant |
4 | 7 | # Disable Policy CMP0068 for CMake 3.9 |
5 | 8 | # rdar://37725888 |
@@ -196,9 +199,13 @@ set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One |
196 | 199 | no effect on the target libraries (the standard library and the runtime).") |
197 | 200 |
|
198 | 201 | # 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) |
202 | 209 |
|
203 | 210 | # The following only works with the Ninja generator in CMake >= 3.0. |
204 | 211 | set(SWIFT_PARALLEL_LINK_JOBS "" CACHE STRING |
@@ -390,13 +397,25 @@ option(SWIFT_CHECK_INCREMENTAL_COMPILATION |
390 | 397 | "Check if incremental compilation works when compiling the Swift libraries" |
391 | 398 | FALSE) |
392 | 399 |
|
| 400 | +option(SWIFT_ENABLE_ARRAY_COW_CHECKS |
| 401 | + "Compile the stdlib with Array COW checks enabled (only relevant for assert builds)" |
| 402 | + FALSE) |
| 403 | + |
393 | 404 | option(SWIFT_REPORT_STATISTICS |
394 | 405 | "Create json files which contain internal compilation statistics" |
395 | 406 | FALSE) |
396 | 407 |
|
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}") |
400 | 419 |
|
401 | 420 | # |
402 | 421 | # User-configurable experimental options. Do not use in production builds. |
@@ -487,7 +506,7 @@ endif() |
487 | 506 | # Use dispatch as the system scheduler by default. |
488 | 507 | # For convenience, we set this to false when concurrency is disabled. |
489 | 508 | set(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") |
491 | 510 | set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE) |
492 | 511 | endif() |
493 | 512 |
|
@@ -589,6 +608,20 @@ set(SWIFT_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin") |
589 | 608 | set(SWIFT_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib") |
590 | 609 | if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "") |
591 | 610 | set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR}") |
| 611 | + set(SWIFT_EXEC_FOR_LIBSWIFT "${CMAKE_Swift_COMPILER}") |
| 612 | +elseif(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING" OR LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS") |
| 613 | + # If cross-compiling we don't have to bootstrap. We can just use the previously |
| 614 | + # built native swiftc to build libswift. |
| 615 | + message(STATUS "Building libswift with native host tools instead of bootstrapping") |
| 616 | + set(LIBSWIFT_BUILD_MODE "HOSTTOOLS") |
| 617 | + set(SWIFT_EXEC_FOR_LIBSWIFT "${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swiftc") |
| 618 | +endif() |
| 619 | + |
| 620 | +if(LIBSWIFT_BUILD_MODE STREQUAL "HOSTTOOLS" OR LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS") |
| 621 | + if(SWIFT_ENABLE_ARRAY_COW_CHECKS) |
| 622 | + message(STATUS "array COW checks disabled when building libswift with host libraries") |
| 623 | + set(SWIFT_ENABLE_ARRAY_COW_CHECKS FALSE) |
| 624 | + endif() |
592 | 625 | endif() |
593 | 626 |
|
594 | 627 | # This setting causes all CMakeLists.txt to automatically have |
@@ -933,7 +966,7 @@ if(SWIFT_INCLUDE_TOOLS) |
933 | 966 | message(STATUS " Build type: ${CMAKE_BUILD_TYPE}") |
934 | 967 | message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}") |
935 | 968 | message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}") |
936 | | - message(STATUS " libswift: ${SWIFT_TOOLS_ENABLE_LIBSWIFT}") |
| 969 | + message(STATUS " libswift: ${LIBSWIFT_BUILD_MODE}") |
937 | 970 | message(STATUS "") |
938 | 971 | else() |
939 | 972 | message(STATUS "Not building host Swift tools") |
@@ -1040,6 +1073,9 @@ if(SWIFT_ENABLE_DISPATCH) |
1040 | 1073 | include(Libdispatch) |
1041 | 1074 | endif() |
1042 | 1075 |
|
| 1076 | +add_bootstrapping_target(0) |
| 1077 | +add_bootstrapping_target(1) |
| 1078 | + |
1043 | 1079 | # Add all of the subdirectories, where we actually do work. |
1044 | 1080 |
|
1045 | 1081 | ############### |
|
0 commit comments